Commit Graph

178 Commits

Author SHA1 Message Date
Ray Schamp
997062c851 Add JSDoc for requestSnapshot 2018-09-18 15:55:49 -04:00
Ray Schamp
90b1c47c3e Add getter for the renderer's canvas
Resolves #309
2018-09-18 15:21:01 -04:00
Ray Schamp
550cd7aacf Add ability to get a snapshot of the next frame 2018-09-18 15:01:22 -04:00
Michael "Z" Goddard
4c8bc5d806 Framebuffer PenSkin (#319)
* draw pen skin lines and stamps to a framebuffer

* skip reading pixels and draw stamp to framebuffer

* update silhouette with readPixels

* draw pen canvas to buffer when its dirty

Composite lines and stamps on browser preferred side (cpu/gpu) until
the export texture is needed. Then blend the canvas with the current
buffer contents.

Updating this way invalidates useProgram optimization and the renderer
currently does not have a way to know this.

* draw lines on framebuffer through fragment shader

* optimize draw regions and pen skin matrix creation

* control draw regions

* mobile gpus need high precision floats for line drawing

* optimize cpu pen line math

* sampled pen line caps

* sampleless pen skin lines, lint, document pen skin buffer ops

* add PenSkin._canvasDirty to constructor

* remove DRAW_MODE_line

* comment PenSkin reused memory, use memory in drawRectangle

* turn draw region id's into optional method handlers

A region ID object may have an enter and exit method on it that are
used by default when entering and exiting that region.

* remove old DRAW_MODE_line precision setting

* standardize vert lines on 4 spaces

* fixup! turn draw region id's into optional method handlers

* do not draw when updating pen skin silhouette

* do not premultiply stamp colors by alpha

* fixup! do not draw when updating pen skin silhouette

* do not premultiply line color

* add a small rim around the line for aliasing

* variable pen line alias amount

* reverse offset pen line on y axis by relative alias amount

Reverse the offset to keep small line overlap to a minimum.

* fixup! reverse offset pen line on y axis by relative alias amount

* medium precision gpu floats
2018-08-08 14:30:51 -04:00
Mx Corey Frang
c54a928f0a Touching color implementation (#312)
* Touching color draft implementation

* New constant for CPU/GPU render split determined, removing query param

* Small fix for pick tests
2018-08-08 14:20:35 -04:00
Mx Corey Frang
6863613d20 Optimizing isTouching while creating a drawableTouches for sensing mouse pointer (#325)
* Allow 'isTouching' and 'pick' to still work on invisible drawables.

* Always ignore visibility for isTouching on drawable

* Filter invisble drawbles in isTouchingDrawable per rules of collision

* polish up some docs/get logic 👍

* leftover line from deleted comment

* revert to ghosted pick behavior

* Add clientSpaceToScratchBounds method

* fix lint

* add some pick tests
2018-08-07 10:56:28 -04:00
Karishma Chadha
11671ee885 Add API for getting the drawable order of a given drawable. 2018-07-24 11:05:38 -04:00
Karishma Chadha
5205f9cb87 Fix up comments. 2018-05-21 09:47:57 -04:00
Karishma Chadha
ce4296be82 Make layer group required and get rid of explicitly ordered layer groups. 2018-05-20 22:07:38 -04:00
Karishma Chadha
2dac278f90 Fix lint errors. 2018-05-20 19:40:21 -04:00
Karishma Chadha
39ce51c6f0 Store offsets for each layer group and use full draw list for updates. 2018-05-20 18:56:39 -04:00
Karishma Chadha
b7ac54293d @type tag does not permit descriptions. 2018-05-16 11:17:57 -04:00
Karishma Chadha
2a4f6f9f02 Add layer groups to control explicit and implicit layer ordering. 2018-05-15 22:06:27 -04:00
DD
3be6a4d4a8 Fix jsdoc 2018-05-04 10:22:47 -04:00
Paul Kaplan
0b849296c0 Merge pull request #268 from paulkaplan/fix-blurry-fullscreen
Scale the drawable scale by the ratio of pixel size to native size.
2018-05-02 07:43:07 -04:00
Paul Kaplan
085931cb4f Scale the drawable scale by the ratio of pixel size to native size.
This makes the vector sprites not blurry in fullscreen mode
2018-04-30 16:33:35 -04:00
Mx Corey Frang
2b8371e5af Rewrite isTouchingDrawables on CPU (#263)
* avoid gl.readPixels at all costs
2018-04-27 16:19:25 -04:00
DD
26f2039f39 We decided that it should not be the renderers responsibility to know a detail about how the paint editor works, and have the bitmap resolution passed in instead 2018-04-26 17:58:48 -04:00
DD Liu
d9c5b595a2 Merge pull request #264 from fsih/updateBitmap
Add updateBitmapSkin to renderer
2018-04-25 14:11:57 -04:00
DD
a49c455d9b Update bitmap 2018-04-24 17:01:59 -04:00
Karishma Chadha
1f574d6ee3 Provide an api to get the calulated rotation center from the rendered costume 2018-04-20 00:01:41 -04:00
Paul Kaplan
bbcf6f73d3 Add method for getting the size of a skin by skin id.
Renamed the `getSkinSize` method to `getCurrentSkinSize`, since it was
using the drawables current skin. Added a new `getSkinSize` method that
works by skin id.
2018-04-10 10:00:54 -04:00
Paul Kaplan
e02cc5ae03 Merge pull request #248 from paulkaplan/fix-bubble-bounds
Add "get bounds for bubble" method.
2018-03-23 14:35:52 -04:00
Paul Kaplan
0b731b92a6 Add "get bounds for bubble" method.
Note there was an inconsequential coordinate flip in the original
transformation code, which was fixed in order for the sliced bounds to
work. The change is at line 388
2018-03-23 10:58:21 -04:00
Chris Willis-Ford
f8c781c163 Merge pull request #227 from cwillisf/use-browser-field
Update packaging to use UMD and the browser field
2018-01-24 15:21:16 -08:00
Christopher Willis-Ford
7dd707db17 Revert getWebGLContext => getContext change
This change allowed TWGL to create a WebGL 2 context when available and
fall back to WebGL 1 when that's the only option. This should in theory
be harmless, but deserves more extensive testing before rolling it out.
2018-01-11 10:07:42 -08:00
Christopher Willis-Ford
e958e4bfff Fix playground, plus misc. cleanup
The playground was trying to build with a now-missing entry point.
Also, I fixed some JSDoc comments, added HTML labels, etc. until IDEA
had no meaningful complaints about `playground/index.html`.
2018-01-10 17:42:38 -08:00
Christopher Willis-Ford
07a6ae57be Check & report if browser supports this renderer
`RenderWebGL`'s constructor will now throw if TWGL init fails. There's
also a new static method to check whether or not we expect TWGL init to
succeed.
2018-01-10 12:28:54 -08:00
Chris Willis-Ford
1afae3acbd Merge pull request #204 from cwillisf/use-linear-filtering
Use bilinear filtering except when we shouldn't
2017-12-11 11:54:57 -08:00
Paul Kaplan
43aa62e747 Update comment 2017-12-11 09:15:24 -05:00
Christopher Willis-Ford
96f416467d Remove 3 unnecessary blank lines 2017-12-08 16:36:04 -08:00
Paul Kaplan
1c4e166aa8 Return false instead of undefined 2017-12-08 12:38:04 -05:00
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
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
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
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
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
griffpatch
10762c7f7c Fix misunderstanding of mask3b now that I can bypass the build failure and test 2017-11-16 08:33:10 +00: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
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
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
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
553af92910 Update references to the old skin 2017-08-31 17:04:05 -04:00
DD
fa12b523c9 Don't change the skin ID when making a new one 2017-08-31 11:38:44 -04:00