Commit Graph

187 Commits

Author SHA1 Message Date
Paul Kaplan
7bb15c7444 Ignore sprite visibility for touching color 2017-12-08 12:27:45 -05:00
Paul Kaplan
8f3254470a Filter out drawables that are not visible. 2017-12-07 15:05:43 -05:00
Christopher Willis-Ford
61c75172d0 Remember: no Hungarian 2017-12-06 15:28:41 -08:00
Christopher Willis-Ford
408b259055 Simplify & document RGB->HSL conversion 2017-12-05 11:01:12 -08:00
Christopher Willis-Ford
e83673ffb8 Increase epsilon for RGB2HCV to fix mobile NaN
Some mobile GPUs end up dividing by "zero" with the previous epsilon
value. The larger epsilon doesn't cause any problems on systems which
didn't exhibit the bug (like my main dev machine).
2017-12-04 15:31:18 -08:00
Paul Kaplan
cde61630ab Merge pull request #207 from paulkaplan/double-render
Fix double render issue by clearing canvas just before drawing
2017-12-01 11:46:34 -05:00
Paul Kaplan
101b74455c Clear the canvas just before the image is ready to draw. 2017-12-01 10:22:35 -05:00
Paul Kaplan
8a1f3306b7 Check if x has been incremented to OR above the width.
Fixes a bug with the convex hull calculation where the bounds could not
be calculated for certain costumes with non-integer sizes.
2017-12-01 08:56:12 -05:00
Chris Willis-Ford
72af98d2cf Merge pull request #193 from griffpatch/touching-color-white
Touching color white always returns "true"
2017-11-20 17:25:42 -08:00
Chris Willis-Ford
8495c6c4e2 Merge pull request #196 from mzgoddard/alpha-shape
Emulate silhouette rendering for pick and _getConvexHullPointsForDrawable
2017-11-20 13:29:39 -08:00
Michael "Z" Goddard
59f6492742 Use isTouching methods in RenderWebGL.pick and getConvexHull
Use Drawable.isTouching and Skin.isTouching to implement pick and
_getConvexHullPointsForDrawable to emulate rendering the drawable's
silhouette and determining what is picked or the points for a convex
hull.
2017-11-20 14:00:37 -05:00
Michael "Z" Goddard
8bdf56705e Add Drawable.isTouching
Use EffectTransform and Skin.isTouching to implement
Drawable.isTouching.

Drawable.isTouching takes a world coordinate.
2017-11-20 13:46:34 -05:00
Chris Willis-Ford
77e3d63da9 Merge pull request #195 from mzgoddard/whirl-fisheye-without-condition
Whirl and Fisheye shaders without conditions
2017-11-16 16:47:17 -08:00
griffpatch
10762c7f7c Fix misunderstanding of mask3b now that I can bypass the build failure and test 2017-11-16 08:33:10 +00:00
Michael "Z" Goddard
a0df7153bc Add Skin.isTouching
Use Silhouette to implement Skin.isTouching in subclasses.
2017-11-15 17:41:46 -05:00
Michael "Z" Goddard
448c88e637 Add EffectTransform
EffectTransform transforms a point based on a Drawable's effect uniform
values mimicking the texcoord0 transformation in the shader. This way a
point in the Drawable space can know if its touching its silhouette
when the Drawable has effects active.
2017-11-15 17:41:46 -05:00
Michael "Z" Goddard
1926b49ebc Add Silhouette class
Silhouette emulates silhouette rendering. Performing tests like
RenderWebGL.pick can use Silhouette in place of reading a silhouette
rendering from the GPU.

Silhouette.isTouching(vec) takes a texture coordinate vector and checks
if the corresponding location is opaque or not for the underlying
information.
2017-11-15 17:39:59 -05:00
Michael "Z" Goddard
08e4523324 Change the fisheye shader so it does not need a conditional 2017-11-15 14:05:26 -05:00
Michael "Z" Goddard
1c9f148923 Change whirl shader so it does not need a conditional 2017-11-15 14:05:25 -05:00
griffpatch
539eb4ce05 Lint issues 2017-11-14 08:32:53 +00:00
griffpatch
3380aa938f Fix for Touching color white always returns "true" #710
So the issue is simple... We start by filling the detector canvas with
the color white, then layer over this the costumes we are want to detect
white colors in (but clip to the shape of the costumre we are detecting
against) then the areas that were clipped will still be white (the
background fill color). So we detect white no matter what.
2017-11-14 08:29:01 +00:00
Michael "Z" Goddard
b060c07db1 Compare new setRotationCenter values after truncating to 32bit
`Skin._rotationCenter` is a twgl vector or said another way a
Float32Array. JavaScript casts values stored in this array as 32 bit
floats instead of JavaScript's standard 64 bit floats. Comparing the
equality, like `setRotationCenter` does, of a 64 bit float against a
value stored in a 32 bit container will virtually always be false.
Truncating the new value into a 32 bit (losing precision) will give a
more useful comparison and remove a lot of current false positives.
2017-11-07 17:33:21 -05:00
Paul Kaplan
be1306387d Use zero if cannot parse stroke width 2017-10-12 15:59:45 -04:00
Paul Kaplan
04e9d6c414 Change toString to buildString 2017-10-11 13:41:42 -04:00
Paul Kaplan
69ae065b92 Text bubble rendering 2017-10-10 09:09:23 -04:00
Paul Kaplan
ebe2db2e02 Add utils for text wrapping, originally by CWF 2017-10-10 09:06:38 -04:00
Paul Kaplan
ab4046b852 Only enlarge by half stroke width on either side 2017-10-05 13:30:01 -04:00
Paul Kaplan
3565c95f83 Enlarge bounding box by largest stroke width. 2017-10-05 11:03:23 -04:00
Chris Willis-Ford
c0d0e78bbb Merge pull request #162 from joshlory/color-touching-tolerance
Match Scratch 2.0 threshold for `isTouchingColor`
2017-09-06 17:48:12 -06:00
Christopher Willis-Ford
737a94b04b Lint fixes 2017-09-06 15:50:01 -06:00
Chris Willis-Ford
9221fcec83 Merge pull request #165 from LLK/greenkeeper/eslint-4.6.1
chore(package): update eslint to version 4.6.1
2017-09-06 15:28:32 -06:00
Christopher Willis-Ford
49f7b06dbe Lint fixes 2017-09-06 15:23:28 -06:00
Paul Kaplan
d59089e1b5 Merge pull request #159 from paulkaplan/color-picking
Add color extraction method to renderer
2017-09-06 13:54:08 -04:00
Paul Kaplan
ca0004f043 Fix clear color 2017-09-06 13:50:22 -04:00
Paul Kaplan
471f03e310 Fixup from CWF comments on blending 2017-09-05 15:29:37 -04:00
DD Liu
ef7f1d2558 Merge pull request #163 from fsih/updateSvg2
Update references to the old skin
2017-08-31 17:17:54 -04:00
DD
553af92910 Update references to the old skin 2017-08-31 17:04:05 -04:00
DD Liu
4d04f3c646 Merge pull request #160 from fsih/updateSvg
Add updateSVGSkin
2017-08-31 13:17:49 -04:00
DD
fa12b523c9 Don't change the skin ID when making a new one 2017-08-31 11:38:44 -04:00
Josh Lory
1cfaf57e8b Match Scratch 2.0 threshold for isTouchingColor 2017-08-30 21:21:27 -07:00
Chris Willis-Ford
9736ced8df Merge pull request #155 from joshlory/drawable-aabb-tests
Add initial test coverage for Drawable.prototype.getAABB
2017-08-30 16:56:11 -07:00
DD
29366df1d0 Make updateSVGSkin work when converting from bitmap to SVG 2017-08-30 18:24:56 -04:00
DD
66f362faed Add updateSVGSkin 2017-08-30 17:47:13 -04:00
Paul Kaplan
c33f0e46ce Add color extraction method to renderer 2017-08-25 10:05:46 -04:00
Chris Willis-Ford
a23287ab5a Merge pull request #138 from a49594a/patch-2
fix the bug #131 Rotation center is incorrect while sprite is scaled by "changeSize" block or "setSize" block
2017-08-24 10:02:35 -07:00
Chris Willis-Ford
1ad55771a7 Merge pull request #156 from joshlory/fix-empty-sprite-rotation-center
Scratch 2.0 compat: don't modify rotation center of empty sprites
2017-08-18 12:14:30 -07:00
Josh Lory
0d1d7dab3a Scratch 2.0 compat: don't modify rotation center of empty sprites 2017-08-09 23:01:09 -07:00
Josh Lory
f8a754f71a Inline shader require statements, to allow using ShaderManager in tests 2017-08-09 18:50:07 -07:00
Paul Kaplan
46b8784217 Correctly convert input coords into scratch coords 2017-08-09 15:40:32 -04:00
Josh Lory
48bf025380 Fix scratch-render playground
Loading skin by URL is deprecated (see: 64c5991486).
2017-08-09 10:31:02 -07:00