28 Commits

Author SHA1 Message Date
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 a5f852fcc23d1c46942b68bb792d7d1b95832e50, reversing
changes made to e616ab5d35307b26d7937c89388910f06321e5e6.
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