These blocks implement pen features as found in Scratch 2.0
Supporting changes include:
- `Target` is now an event emitter
- `RenderedTarget` now emits an event when it moves
- `Target` can now store arbitrary "extra" data, called "custom state"
in the code, using a `Target`'s `setCustomState` and `getCustomState`
methods. This is used to store per-target pen state without requiring
`Target` or `RenderedTarget` to know anything about the pen.
- `Cast` can now cast to an RGB color object.
- `Color` now has functions to convert between RGB and HSV, constants
for for black & white, and a `mixRgb` function to lerp between two
colors.
This prevents sending `NaN`s to the renderer as the rotation center, which prevents the initial render of the costume/backdrop.
Towards LLK/scratch-gui#18
Previously it assumed every costume to have a `bitmapResolution` property which doesn't apply to vector costumes. This caused the renderer to not render added SVG costumes when they were added with setCostume.
* Add "touching" block, layers blocks
* Keep in fence, if on edge bounce, fix to touching edge
* Fix degtoRad in "if on edge, bounce"
* Fixes from review
Use it before loading projects so targets don't accumulate when multiple projects are loaded on the same instance.
Move check to see if the clone is the original clone onto the block implementation so all clones can be removed.
Fixes#274
* Import lists and variables from SB2
* Switch to Variable and List objects
* Add Clone.lookupOrCreateVariable, Clone.getVariable, Clone.setVariable
* Add (get, set, change) variable blocks.
* Copy variables and lists on clone instantiation
* Move variable options closer to blocks
* Add list primitives
* Move variable and lists storage to `Target` instead of `Clone`
* Move _computeIndex to a Cast function
* Rename `getList` -> `getListAsString`
* Renames renames
* Remove extra check in Cast.isNaN
* Provide property to Clone to distinguish "original" clones
* Provide method to clone a clone's properties
* Don't report clones in the UI target list
* Add target info to Thread
* Allow hats to skip clones (for green flag)
* Green flag skips clones
* Implement "create clone" and hat
* Pass the runtime to sprites and clones (for start hats)
* Clone disposal; trigger hats after drawable initializes.
* Separate stop threads for target; fix handling of stop button
* Remove extraneous `skipClones` property
* Add global clone limit
* Don't allow a non-clone to delete itself.
* Rename `cloneClone` -> `makeClone`
* Variable updates in runtime.js
* Synchronous drawable initialization (until we put it back to promises)
* Fill out color utilities
* Amend Color.decimalToHex name
* Add `Cast.toScaledRgbColor`
* Add touching color, color touching color blocks
* Fix scale of Cast.toRgbColor
* Fix format of colors to use renderer-style lists
* Update `Color.decimalToRgb`
* Lint self
* Add `Clone.prototype.getCostumeIndexByName`, keep in range
* Add basic costume primitives from Scratch 2.0
* Add costume getter block
* Add properties and methods for distinguishing stage and sprites-vs-clones
* Add backdrop-related looks blocks
* Fix up "switch to backdrop" to be working
* Costume/backdrop reporters are 1-indexed
* Fire "when backdrop switched" hats
* Cut cloning helpers for a separate PR
* Disable many blocks on the stage
* Refactor into _setCostumeOrBackdrop; implement switch backdrop and wait
* Fire hats even when backdrop unchanged