265 Commits

Author SHA1 Message Date
TheBrokenRail
ec2361cf91 Fix IE/Edge Support (#85) 2017-02-18 14:06:45 -05:00
Ray Schamp
68600e794d Return null for invalid drawableIDs 2017-02-18 12:18:04 -05:00
Ray Schamp
6dd3c0ed81 Don't clip drawables to stage when extracting 2017-02-17 17:37:05 -05:00
Ray Schamp
e035cadb04 Don't apply ghost when extracting drawables 2017-02-17 17:36:47 -05:00
Ray Schamp
3bc00176ed Refactor _drawThese to take options
So the number of arguments doesn't get out of hand
2017-02-17 17:35:45 -05:00
Ray Schamp
a65ea3daed Add method to retrieve drawable pixel data
Towards LLK/scratch-gui#66
2017-02-17 14:51:04 -05:00
SillyInventor
4eacde74e6 Round pixelBase to allow for non-integer SVG widths in _getConvexHullPointsForDrawable 2017-02-15 14:14:03 -05:00
griffpatch
f3b3f0aca7 Feature - Fencing again
This is a resubmission of the same scripts that got reverted. The actual
issues was within scratch-vm.
2017-02-15 16:19:08 +00:00
Ray Schamp
42e5e724c2 Revert "Feature fencing" 2017-02-15 09:38:23 -05:00
SillyInventor
9c51cf0a04 Switch to getFastBounds from get bounds, and add check for if the hull points are empty. 2017-02-14 19:58:22 -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
griffpatch
b39bb4d3fd Fencing Take 3
Refactor to accept and return a position as an array of ints [x, y]
2017-02-14 09:08:32 +00:00
griffpatch
1a3e9845d0 Merge remote-tracking branch 'refs/remotes/LLK/develop' into feature/fencing 2017-02-14 08:30:42 +00:00
griffpatch
100625c6d7 Fencing 2017-02-14 08:30:07 +00:00
griffpatch
fea7643e7e rename fencing method 2017-02-11 14:23:05 +00:00
Chris Willis-Ford
4d8b5da491 Merge pull request #84 from CSnap/fix_SkinMeasurements
Initialize Measurement
2017-02-10 12:04:54 -08:00
Chris Willis-Ford
fd4ef087d5 Merge pull request #79 from LLK/greenkeeper/initial
Update dependencies to enable Greenkeeper 🌴
2017-02-10 11:42:13 -08:00
SillyInventor
dc53feaf41 Initialize Measurement 2017-02-10 14:21:45 -05:00
Chris Willis-Ford
a0b3a687cd Merge pull request #81 from griffpatch/bug/alphaChannelConversion
Bug alphachannelconversion
2017-02-09 07:49:56 -08:00
griffpatch
4e21184854 Lint Issues
Comments too long
2017-02-09 10:04:48 +00:00
griffpatch
aa993779bb Feature - Fencing of drawables
Provide a method in the scratch-render to return the fenced coordinates
of a drawable moving to a given position.
2017-02-09 09:56:27 +00:00
griffpatch
4dba5db28d Alpha channel conversion
I wasn't so clever with this - I'm sorry. Now that I have managed to
link up my local render & vm projects I am able to fix the issue
properly. Many appologies!
2017-02-09 08:36:57 +00: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
Christopher Willis-Ford
805ec54f57 chore: adapt code for Webpack 2 2017-02-03 11:01:29 -08:00
griffpatch
6f5acfee7b Bug in alpha channel conversion
This is groundwork required by the issue:
https://github.com/LLK/scratch-vm/issues/393
2017-01-27 12:26:11 +00:00
Chris Willis-Ford
9841de85f1 Merge pull request #74 from CSnap/clear_fix
Clear Button Fix
2017-01-25 09:51:57 -05:00
Ray Schamp
2fc9005c60 Merge pull request #70 from rschamp/bugfix/new-skins-without-rotationCenter
Calculate rotation center if it's not supplied
2017-01-25 09:43:24 -05:00
Ray Schamp
bf2863921c Carry rotationCenter assignment to create*Skin 2017-01-25 09:29:29 -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
SillyInventor
ea786aa4bd set canvas to dirty when clearing pen canvas 2017-01-24 19:44:47 -05:00
Christopher Willis-Ford
5eef82a9dc Add missing jsdoc for _setAttributes on PenSkin 2017-01-20 13:16:22 -08:00
Christopher Willis-Ford
3bdb1fff1f Small changes & fixes from VM integration
Changes include:
- Implement pen clear
- Upack pen-related location parameters
- Fix inverted vertical position on pen actions
- Remove canvas debug content
- Set `strokeStyle` instead of `fillStyle`
- Remove location parameter from stamp operation: always stamp in place
2017-01-19 11:22:32 -08: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
1531ea8ae6 Fix outdated method of collecting size 2017-01-11 10:05:36 -08:00
Christopher Willis-Ford
f7fd05cfba Use skin-relative coordinates for Pen actions 2017-01-10 15:22:33 -08:00
Christopher Willis-Ford
78c0d09c72 Flip y coordinate for internal renders
Scratch uses y=up, whereas WebGL and the Canvas element both use y=down.
To make this work, we set a non-conventional projection matrix when
rendering to the stage. Some of the internal renders (touching color,
stamp, etc.) were using a y-flipped projection matrix, though, which
means that the output was double-flipped and would appear incorrect. For
the touching-color block this just meant a cosmetic issue: the debug
canvas looks upside-down. For pen stamp, though, it's a real issue since
the stamp was appearing upside down on the stage.

This change ensures that the projection matrix for every internal render
follows WebGL / Canvas conventions, and that we only y-flip on the final
render to the stage.
2017-01-10 12:56:32 -08:00
Christopher Willis-Ford
f29ed34ddc Implement pen point, line, and stamp
Also clean up the code around our calls to `readPixels`:
- Use `Uint8Array` instead of `Buffer` to hold the pixels
- Use `ImageData.data.set` instead of a `for` loop when copying pixels
  to a canvas
2017-01-10 11:47:45 -08:00
Christopher Willis-Ford
140c0fbf37 Merge skin classes, convert PenDrawable to PenSkin
Merge the "skin classes" work from another branch and move/convert the
pen work from `PenDrawable` to `PenSkin`.
2017-01-05 16:25:53 -08:00
Christopher Willis-Ford
1f0cd4b61f Fix resource leaks discovered while testing
- `Drawable` now removes its `Skin` on `dispose`, disconnecting events.
- Creating a new `Drawable` doesn't always create a new `Skin` any more:
  now it can share an existing skin.
- Don't throw when asked to update the properties of a `Drawable` that
  has already been destroyed. This seems like a VM bug but was causing
  overwhelming output in the browser for some projects.
2016-12-29 13:42:58 -08:00
Christopher Willis-Ford
6643469ff2 Remember to fill the URL cache... 2016-12-29 11:06:54 -08: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
Christopher Willis-Ford
4730a057ff Move Drawable.NONE into new RenderConstants
This constant will soon be shared with another class.
2016-12-22 12:58:58 -08:00
Christopher Willis-Ford
e3a05743b0 Handle changing the stage's native size, tell pen
The `setStageSize` wasn't working correctly. This change fixes that and
also notifies active `PenDrawable` instances about the resize. This was
implemented by making the renderer an `EventEmitter`.
2016-12-21 16:13:57 -08:00
Christopher Willis-Ford
2a64c1dd18 Convert pen to subclass of Drawable: PenDrawable
To test, load the playground and type `renderer.createPenDrawable()`
into the JS console. Note that the pen layer is now just another
drawable object, so it can move and use effects.
2016-12-21 11:36:29 -08:00
Christopher Willis-Ford
c6356f71ff Move uniforms, skins, transform back to Drawable
It turns out that it might make sense for the pen to share these
features. Splitting them out would likely work too, but would introduce
unnecessary complexity.
2016-12-20 15:29:22 -08:00
Christopher Willis-Ford
2dafa70ff7 Use sprite shader for pen 2016-12-20 15:22:54 -08:00
Christopher Willis-Ford
8164fef77e Split Drawable into interface & implementation
The skin-based implementation of `Drawable` has been moved into a new
class called `SkinnedDrawable`. This makes room for `PenLayer` to become
a new type of `Drawable`.
2016-12-15 15:51:56 -08:00
Christopher Willis-Ford
14b34f4b3c WIP pen layer
This is the absolute basics of a working pen layer. Still to do:
- Make it so that the pen layer can be in the drawables list so that it
  can be in front of the backdrop but behind other Drawables.
- Remove current debug canvas operations
- Add pen layer API
2016-12-15 13:35:37 -08:00