Commit Graph

48 Commits

Author SHA1 Message Date
adroitwhiz
26d2677409 Also pass in drawable to useNearest
This makes the code messier but I'm not sure what else to do since the
texture filtering method to be used depends on the drawable's properties
(e.g. transform, enabled effects). We still need to pass in the scale
separately because in the main rendering path, we multiply it by the
screen-space scale factor.
2020-09-30 17:05:17 -04:00
adroitwhiz
f4d5e52a8f Clarify SVGSkin.useNearest comments 2020-09-30 17:04:08 -04:00
adroitwhiz
97605f9e55 Move useNearest to skin classes 2020-09-30 17:04:06 -04:00
DD Liu
46274c7908 Merge pull request #649 from adroitwhiz/no-vector-blur
Always use SVG mipmaps that match or exceed the skins' screen-space size
2020-08-04 17:17:03 -04:00
adroitwhiz
d9c854f1fc Remove setRotationCenter API 2020-06-23 02:29:14 -04:00
adroitwhiz
0d86ec92ed Don't blur vector skins 2020-06-22 17:33:45 -04:00
adroitwhiz
26988e398f Clean up SVGSkin 2020-06-22 17:33:45 -04:00
adroitwhiz
e7b1504117 Move matrix + silhouette updates into method 2020-05-19 16:02:12 -04:00
adroitwhiz
10a6d87eb6 Premultiplied alpha, take 2 2020-01-23 14:41:53 -05:00
Chris Willis-Ford
fed02ca582 Merge pull request #544 from adroitwhiz/fix-vector-silhouette
Fix SVGSkin silhouettes
2020-01-13 14:34:52 -05:00
adroitwhiz
2985f2ac54 Fix SVGSkin silhouettes 2020-01-10 06:24:01 -05:00
adroitwhiz
6d9cec8222 Set zero-sized SVG MIPs to empty texture 2020-01-09 01:09:47 -05:00
adroitwhiz
6662a7d556 Address review feedback
Co-Authored-By: Chris Willis-Ford <cwillisf@users.noreply.github.com>
2020-01-07 10:47:10 -05:00
adroitwhiz
bf5d666737 Synchronous SVG mipmaps 2019-11-26 16:48:45 -05:00
Katie Broida
f17252624e Add SVGMIP as a wrapper for WebGL textures to handle creating textures at a different scale and updating them
Check scale for largest MIP
2019-10-28 13:53:10 -04:00
Karishma Chadha
c25d1f37b8 Add/update methods to Skin class to handle an empty skin. 2019-10-07 13:11:58 -04:00
Karishma Chadha
11665299bc Revert "Put Skin Alter Push Back In" 2019-09-26 09:39:05 -05:00
Michael "Z" Goddard
110371b029 synchronously store SVGRenderer props used in SVGSkin
Some APIs need SVGSkin to update some of its values immediately when changing
the SVG. Namely size needs to be synchronously set. However rotation center
doesn't need to be set at that time so we can leave it to update where it
currently is.
2019-09-16 17:22:27 -04:00
Karishma Chadha
2a1d215e50 Revert "Revert "Revert "Revert "Skin alter push"""" 2019-09-12 13:43:32 -04:00
Karishma Chadha
1cd9e54834 Revert "Revert "Revert "Skin alter push""" 2019-09-12 13:24:03 -04:00
adroitwhiz
94257a4214 Set SVG skin size synchronously 2019-08-13 16:38:45 -04:00
Karishma Chadha
7c4393787b Revert "Revert "Skin alter push"" 2019-08-13 11:42:51 -04:00
Karishma Chadha
4a28cffcd4 Revert "Skin alter push" 2019-08-13 11:22:27 -04:00
Michael "Z" Goddard
24b535eb76 cache svg renderer size and view offset 2019-06-18 17:18:48 -04:00
Michael "Z" Goddard
e31934f6a9 update Skin textures with ImageData
When possible pass ImageData to texture creation and updating to help
remove chance of references that keep canvas and underlying data from
being garbage collected.
2019-03-19 17:52:21 -04:00
DD Liu
cc448951f9 Update silhouette after getting texture at a new scale 2019-01-22 13:58:59 -05:00
Paul Kaplan
bb84abab87 Revert "Merge pull request #394 from paulkaplan/defer-silhouette-updates"
This reverts commit a5f852fcc2, reversing
changes made to e616ab5d35.
2019-01-14 16:51:26 -05:00
Paul Kaplan
07544595fd Implement updateSilhouette to allow updates to happen when needed 2019-01-09 14:22:08 -05:00
Paul Kaplan
6e072ea026 Revert "Increase maximum texture size and back it off if GL fails to render" 2019-01-08 15:59:09 -05:00
DD Liu
0676e0f54a Use callback for loop, and update maxTextureScale during callback 2019-01-07 10:00:31 -05:00
DD Liu
5be561133d Increase maximum texture size and back it off if GL fails to render 2019-01-05 00:43:55 -05:00
Mx Corey Frang
2b8371e5af Rewrite isTouchingDrawables on CPU (#263)
* avoid gl.readPixels at all costs
2018-04-27 16:19:25 -04:00
Karishma Chadha
ac1f5564a3 Bitmap (+ double resolution) support. 2018-04-22 21:30:28 -04:00
DD
d46cc4fec7 Merge branch 'develop' into pull231 2018-01-19 17:33:17 -05:00
Paul Kaplan
8a04fcd541 Cache image element in the SVG renderer. 2018-01-17 09:46:07 -05:00
Christopher Willis-Ford
89b5ed32d0 First pass at re-rasterizing SVGs when scaled 2018-01-17 01:05:44 -05:00
Christopher Willis-Ford
bc423cef46 Use require, not import, for SVG renderer 2018-01-12 13:12:55 -08:00
Christopher Willis-Ford
413c1d8027 Extract svg-renderer out into a separate module 2018-01-12 10:56:28 -08:00
Christopher Willis-Ford
9307e09031 Use bilinear filtering except when we shouldn't
Use bilinear filtering unless the Drawable is angled by a multiple of 90
degrees and is either a raster image (like a BitmapSkin) or is around
its native resoluion. This makes both bitmaps and vectors look better in
most cases. This is roughly the same logic that Scratch 2.0 used; we may
want to tweak it over time to see if we can make it even better.
2017-11-29 20:55:50 -08:00
Michael "Z" Goddard
a0df7153bc Add Skin.isTouching
Use Silhouette to implement Skin.isTouching in subclasses.
2017-11-15 17:41:46 -05:00
Ray Schamp
3c6511d94e Generate docs from src, publish to gh-pages
Fix any broken JSDoc syntax. Unfortunately there is no way to document tuples like `{[int, int]}` for a `[width, height]` array. We could possibly fix this and make the code more readable with `{width: number, height: number}` instead of tuples.

Remove single `@fileoverview` from Rectangle.js, since it was the only file with one and was weird to have that one module show up on the docs home page.

Add a `docs` script to `package.json`, run it from `npm test`, so invalid docs will cause tests to fail (eventually we may want to start using eslint-plugin-jsdoc to catch these errors with the linter alone).
2017-02-21 14:46:24 -05:00
Christopher Willis-Ford
959c635f58 SVG: compensate for viewbox offset
In Scratch 2.0, an SVG costume's origin is stored relative to that SVG's
viewbox. In order to use the origin values correctly, then, we need to
compensate for the viewbox offset.
2017-02-14 15:59:45 -08:00
Ray Schamp
9a8f4f2a88 Fix SVG size calculation
It was being incorrectly calculated based on devicePixelRatio.

Fixes LLK/scratch-gui#73. Thanks to @cwillisf for figuring it out!
2017-02-07 10:48:47 -05:00
Ray Schamp
c478ebec35 Use explicit rotationCenter argument
This is more explicit than the previous behavior, and more in line with the way we supply the costumeResolution
2017-01-25 09:28:58 -05:00
Ray Schamp
875a5a3ec1 Calculate rotation center if it's not supplied
When a new skin is added, previously the rotation center was set to `[0, 0]`.  In the case of costumes and backdrops added from libraries, the center should be calculated from the bounding box of the imported skin.

Toward LLK/scratch-gui#18
2017-01-13 13:10:20 -05:00
Christopher Willis-Ford
6a0798062b Make a Skin emit an event when it is altered
This allows any `Drawable` using the `Skin` to update its transform as
necessary.
2016-12-29 10:46:12 -08:00
Christopher Willis-Ford
ba5deb9936 Minor cleanup after Drawable/Skin refactor
- Add & correct a few comments
- Make `Drawable` IDs work like `Skin` IDs
- Remove some dead code
- Fix costume resolution in `BitmapSkin` before first `setBitmap` call
- Rename `Drawable` & `Skin` management variables in `RenderWebGL` to
  clarify their purpose and better distinguish them from each other
- Remove problematic premature optimization in `_drawThese`
- Fix missing return statement in `Skin`'s `setRotationCenter`
- Fix mismatch between getTexture & getUniforms in the `Skin` class
2016-12-28 14:38:48 -08:00
Christopher Willis-Ford
64c5991486 Split Skin functionality out of Drawable
There is now a `Skin` base class along with `SVGSkin` and `BitmapSkin`
classes for vector and bitmap skin support. Loading a skin by URL is in
the process of being deprecated. In the future skin data should be
downloaded outside the renderer and supplied through new `create*Skin`
API calls.
2016-12-28 12:17:45 -08:00