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.
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`.
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.
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.
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`.
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
Some callbacks used a variable called `instance` to stash `this` for use
inside the callback. Now that those callbacks have been converted from
`function` to `=>`, they can just use `this` instead.
- Move build outputs into `dist/`
- Make build output file names more consistent
- Update `playground/index.html` for new output file name
- Explicitly specify target => Node output is much smaller
- Minor fixes / cleanup in `.gitignore` and `src/index*.js`
* Start of an SVG rendering quirks mode
* Provide font defaults in SVG quirks mode
* Remove svg-to-image dependency
* Remove fonts and use package fonts instead.
* try/finally for getBBox
When running on Windows, Webpack seems to more reliably notice altered
files when running in polling mode. We already use the `--watch-poll`
argument in the `watch` script, but this change adds equivalent settings
to the config used in the `start` script by `webpack-dev-server`.
The whirl effect's direction was reversed in Scratch 2.0 with the
introduction of Stage3D. This "bug" has existed for long enough to
become the expected whirl direction. This change adjusts the Scratch 3.0
whirl direction to match the Scratch 2.0 3D whirl direction instead of
the Scratch 2.0 2D whirl direction.
* Add Rectangle utility and use it in Drawable.getBounds
* Add `getAABB`, `getFastBounds`.
* Add width and height getters to Rectangle
* Add rectangle clamp
* Optimized isTouchingColor
* Optimized isTouchingDrawables
* Rectangle.ceil -> Rectangle.snapToInt
* Refactor to common _touchingQueryCandidates
* Split helper into two
Tracking the version under one `-prerelease` channel allows other packages to depend on `^0.1.0-prerelease` for the most up to date version.
Track the git sha for the release in package.json
Reuse the json package needed for writing the sha to retrieve the package.json version field
If another package wants to import `src/index.js`, it needs to replicate the loader config in `webpack.config.js`. To avoid this, package the module in `dist.js` and set that as the module to require.
I changed `main` to point to this so that other packages can just `require('scratch-blocks')`, but it would also work for our purposes to add `"webpack": "./dist.js"` if we want to keep `src/index.js` as `main`.