mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-25 07:22:33 -05:00
Convert pen blocks into an "internal" extension
This commit is contained in:
parent
e4830dfe51
commit
6757fb6de9
2 changed files with 110 additions and 17 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
const ArgumentType = require('../extension-support/argument-type');
|
||||||
|
const BlockType = require('../extension-support/block-type');
|
||||||
const Cast = require('../util/cast');
|
const Cast = require('../util/cast');
|
||||||
const Clone = require('../util/clone');
|
const Clone = require('../util/clone');
|
||||||
const Color = require('../util/color');
|
const Color = require('../util/color');
|
||||||
|
@ -235,24 +237,116 @@ class Scratch3PenBlocks {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the block primitives implemented by this package.
|
* @returns {{id: string, name: string, blocks: []}} metadata for this extension and its blocks.
|
||||||
* @return {object.<string, Function>} Mapping of opcode to Function.
|
|
||||||
*/
|
*/
|
||||||
getPrimitives () {
|
getInfo () {
|
||||||
return {
|
return {
|
||||||
pen_clear: this.clear,
|
id: 'pen',
|
||||||
pen_stamp: this.stamp,
|
name: 'Pen',
|
||||||
pen_pendown: this.penDown,
|
blocks: [
|
||||||
pen_penup: this.penUp,
|
{
|
||||||
pen_setpencolortocolor: this.setPenColorToColor,
|
opcode: 'clear',
|
||||||
pen_changepencolorby: this.changePenHueBy,
|
blockType: BlockType.COMMAND,
|
||||||
pen_setpencolortonum: this.setPenHueToNumber,
|
arguments: {
|
||||||
pen_changepenshadeby: this.changePenShadeBy,
|
NUM1: {
|
||||||
pen_setpenshadeto: this.setPenShadeToNumber,
|
type: ArgumentType.NUMBER
|
||||||
pen_changepensizeby: this.changePenSizeBy,
|
},
|
||||||
pen_setpensizeto: this.setPenSizeTo,
|
NUM2: {
|
||||||
pen_changepentransparencyby: this.changePenTransparencyBy,
|
type: ArgumentType.NUMBER
|
||||||
pen_setpentransparencyto: this.setPenTransparencyTo
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
opcode: 'stamp',
|
||||||
|
blockType: BlockType.COMMAND
|
||||||
|
},
|
||||||
|
{
|
||||||
|
opcode: 'penDown',
|
||||||
|
blockType: BlockType.COMMAND,
|
||||||
|
text: 'pen down'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
opcode: 'penUp',
|
||||||
|
blockType: BlockType.COMMAND,
|
||||||
|
text: 'pen up'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
opcode: 'setPenColorToColor',
|
||||||
|
blockType: BlockType.COMMAND,
|
||||||
|
text: 'set pen color to [COLOR]',
|
||||||
|
arguments: {
|
||||||
|
COLOR: {
|
||||||
|
type: ArgumentType.COLOR
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
opcode: 'changePenHueBy',
|
||||||
|
blockType: BlockType.COMMAND,
|
||||||
|
text: 'change pen color by [COLOR]',
|
||||||
|
arguments: {
|
||||||
|
COLOR: {
|
||||||
|
type: ArgumentType.NUMBER,
|
||||||
|
defaultValue: 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
opcode: 'setPenHueToNumber',
|
||||||
|
blockType: BlockType.COMMAND,
|
||||||
|
text: 'set pen color to [COLOR]',
|
||||||
|
arguments: {
|
||||||
|
COLOR: {
|
||||||
|
type: ArgumentType.NUMBER,
|
||||||
|
defaultValue: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
opcode: 'changePenShadeBy',
|
||||||
|
blockType: BlockType.COMMAND,
|
||||||
|
text: 'change pen shade by [SHADE]',
|
||||||
|
arguments: {
|
||||||
|
SHADE: {
|
||||||
|
type: ArgumentType.NUMBER,
|
||||||
|
defaultValue: 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
opcode: 'setPenShadeToNumber',
|
||||||
|
blockType: BlockType.COMMAND,
|
||||||
|
text: 'set pen shade to [SHADE]',
|
||||||
|
arguments: {
|
||||||
|
SHADE: {
|
||||||
|
type: ArgumentType.NUMBER,
|
||||||
|
defaultValue: 50
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
opcode: 'changePenSizeBy',
|
||||||
|
blockType: BlockType.COMMAND,
|
||||||
|
text: 'change pen size by [SIZE]',
|
||||||
|
arguments: {
|
||||||
|
SIZE: {
|
||||||
|
type: ArgumentType.NUMBER,
|
||||||
|
defaultValue: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
opcode: 'setPenSizeTo',
|
||||||
|
blockType: BlockType.COMMAND,
|
||||||
|
text: 'set pen size to [SIZE]',
|
||||||
|
arguments: {
|
||||||
|
SIZE: {
|
||||||
|
type: ArgumentType.NUMBER,
|
||||||
|
defaultValue: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ const defaultBlockPackages = {
|
||||||
scratch3_looks: require('../blocks/scratch3_looks'),
|
scratch3_looks: require('../blocks/scratch3_looks'),
|
||||||
scratch3_motion: require('../blocks/scratch3_motion'),
|
scratch3_motion: require('../blocks/scratch3_motion'),
|
||||||
scratch3_operators: require('../blocks/scratch3_operators'),
|
scratch3_operators: require('../blocks/scratch3_operators'),
|
||||||
scratch3_pen: require('../blocks/scratch3_pen'),
|
|
||||||
scratch3_sound: require('../blocks/scratch3_sound'),
|
scratch3_sound: require('../blocks/scratch3_sound'),
|
||||||
scratch3_sensing: require('../blocks/scratch3_sensing'),
|
scratch3_sensing: require('../blocks/scratch3_sensing'),
|
||||||
scratch3_data: require('../blocks/scratch3_data'),
|
scratch3_data: require('../blocks/scratch3_data'),
|
||||||
|
|
Loading…
Reference in a new issue