Disable use of more accurate timer temporarilly due to performance.
However, with the rearrange and introduction of the 'nowObj' it turns
out most of the delay is in resolving 'self.performance'... so keeping
this cached in nowObj actually mitigates most of the delay.
Changed mathop to call new math util
Changed sin & cos to round correctly (to get 0)
Added testing for the new math util function
Added testing for the new mathop functions
This saves popping, destroying, recreating, and pushing the stack frame,
and then reassigning the warp mode attribute for every block to block
step in the execution.
Run-time Optimisation
The thread.stackFrames array is accessed all the time to retrieve the
'parent' stack frame. This is done using as index of [this.stack.length
- 1]. However, a lot of the time this evaluated to [-1]. Although this
results in null, which is fine, to get to this javascript actually
defers from a numeric array lookup to an object lookup using the string
"-1". This is roughly 100 times slower to compute and so a simple catch
for negative indexes is well worth the extra check.
When popping down the stack frame it is assumed that you keep using the
previous warp state rather than looking at the warp state of the level
you just popped out to. This causes the loss of screen updates if the
warping block was the last statement in a loop as the loop does not obey
it's 'non warp' status.
Had to update the test scripts to handle the alpha channel, also I note
that all the hex tests are using CSS notation, not scratch notation
(which is 0x not #)
Changes include:
- Added missing JSDoc for items in `scratch3_pen.js` and `target.js`.
- Moved constants used by `Scratch3PenBlocks` into the class.
- Created a constant for minimum and maximum pen size.
- Added `util/clone.js` to host cloning functionality.
- Pen blocks now check for the renderer before trying to use it.
- The pen integration test covers all blocks, though `clear`, `stamp`,
and `pen down` will skip some of their functionality when there is no
renderer.
Also, fix a math error in `Color.rgbToHsv`.
Newly covered functions:
- `toRbgColorObject` from `util/cast.js`
- `hsvToRgb` from `util/colors.js`
- `rgbToHsv` from `util/colors.js`
- `mixRgb` from `util/colors.js`
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.
* Move Node output: /dist.js => /dist/node/scratch-vm.js
* Move web output: /vm{.js,.min.js} => /dist/web/scratch-vm{.js,.min.js}
* Update build output references in package.json and the playground's index.html
* Move the VirtualMachine class out of index.js into its own file, referenced by index.js. The VirtualMachine class is otherwise unchanged.
* Add .gitattributes rules for new file types which were added to this repository without specifying their text/binary attributes
* Turn on source maps in webpack and add corresponding .gitignore rule
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.
This allows costume data to reach listeners even when the sprite isn't the editing target.
Filter out non-editing target reports in the playground to match previous behavior.
These events signal when any threads are running or when all threads have stopped running. This maps to whether the green flag or the stop button should be illuminated in the GUI.
* 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
* Add days since 2000 block
* Empty line addition
* Add semicolin
* Empty line addition
* Tabed
* Remove extra line
* Make it exactly like scratch 2 was
* Fixed spacing
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
* Implement "go to" block
* Add a missing semicolon
My text editor doesn't automatically insert them and I'm not used to using
semicolons so much. :(
* Implement go-to-random
* Clean up the go-to-random code a bit
* Add rounding to _random_ picks
* Add scratch3_procedures and no-op for defnoreturn
* Add mutation adapter to parse mutations in CREATE/CHANGE events
* Add mutation-to-XML
* Update spec map for Blockly procedure names
* Placeholder for procedure special cases
* Basic stepping to procedures
* Remove extra case
* Validation for changeBlock
* 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)
* Markup/CSS adjustments
* Move assets to folder
* Strip extra font-family
* More robust handling of project-load fail state
* Move empty project creation to its own function
* Move green flag/stop back out of the tab
* Restore default id
* Remove Fallback Project
* Added A Newline and Removed Fallback Project
* Made The SB2 Project Import Field Fit In More With All Other Textboxes
* Better Description Of SB2 Import Field
* Oops!
* The XML Import Area Doses Not Need To Be Resizable!
* That Didn't Work As Planned
* Now it won't rezize
* Added SB3New
* Add Code For SB3New
* Better 404
* Indentation
* NodeJS complains about quotes
* Moved And Renamed SB3New
* Renamed Refrences
* Prefix With ./
* Typo
* Newline Fix
* Scratch Cat By Default!
* Single Quotes And Max Legth Fixed
* Better Comment Above loadProject
* Move newProject to index.js
* Added Dependincies to index.js
* Deleted newProject.js
* Removed Unneeeded Semicolon
* @param {?string}
* Added SVG For Scxratch Cat
* Now Uses Scratch Cat Offline (REQUIRES PULL REQUEST MADE TO SCRATCH-RENDER TO BE MERGED OR IT WILL NOT WORK)
* Added Stage PNG
* Added Stage Creation
* Fix Sizing Issues
* Import And Compatibility With Less Hacky Image Import (Scratch-Render)
* Import And Compatibility With Less Hacky Image Import (Scratch-Render)
* Fixed Line Length
* Added Navigation Bar
* Added CSS For Drop Down Menus
* Nicer Scale
* Nicer Dropdowns
* Remobved Dropdown CSS (It Didn't Work)
* Add Scratch Player Bar CSS
* Add Scratch Player Bar HTML
* 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
* Strip out old script glowing in thread management
* Add new tracking mechanism for glowing scripts
* Track parents and use them to determine script glows
* Use top-block for a thread if there's nothing on the stack
* Remove `console.log`
* 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
* Fix SB2 variable imports!
* Fix expectedArg field types
* motion_pointindirection uses math_angle
* Fix "think for secs" expected input
* Add handling for empty input case (empty if-else, for example)
* Fix opcodes for if_else, repeat_until, set tempo
* Specialized number fields for SB2 import
* Convert color picker numbers to hex in SB2 import
* KEY_OPTIONS -> KEY_OPTION
* Backdrop blocks get BACKDROP
* Update toolbox XML to match naming changes
* Merge in math_angle case
* Move color converter to its own utility
* Fix merge conflicts
* Add negative color check.
* Fix keyoptions naming
* Pen JSON tweak post-scratch-blocks update
* Always add `next` to block representation
* Add `shadow` property to inputs, to maintain obscured shadows
* Create obscured shadows in SB2 import
* Add XML import of obscured shadows
* Alias SB2 shadow inputs to block inputs
* Add shadow to inputs on "delete inputs" test
* Add a small test to ensure obscured shadows are preserved
* Add more obscured shadow tests
* Key pressed hat
* Tabs -> Spaces
* Oops
* Edge activate
* Fix hat
Phew...
* I forgot to change it also here
:/ :/ :\
* Minor fixes for TravisCi
* Minor docs
* Line length