forked from sugarlabs/musicblocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasicblocks.js
101 lines (94 loc) · 3.14 KB
/
basicblocks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Copyright (c) 2014-20 Walter Bender
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the The GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// You should have received a copy of the GNU Affero General Public
// License along with this library; if not, write to the Free Software
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
// Definition of basic blocks common to all branches
// Some names changed between the Python verison and the
// JS version so look up name in the conversion dictionary.
/* global setupRhythmBlockPaletteBlocks,setupRhythmBlocks,setupMeterBlocks,setupPitchBlocks,setupIntervalsBlocks,setupToneBlocks,
setupOrnamentBlocks,setupVolumeBlocks,setupDrumBlocks,setupWidgetBlocks,setupFlowBlocks,setupNumberBlocks,setupActionBlocks,
setupBoxesBlocks,setupBooleanBlocks,setupHeapBlocks,setupDictBlocks,setupExtrasBlocks,setupProgramBlocks,setupGraphicsBlocks
setupPenBlocks,setupMediaBlocks,setupSensorsBlocks,setupEnsembleBlocks */
/* exported initBasicProtoBlocks,BACKWARDCOMPATIBILIYDICT */
const BACKWARDCOMPATIBILIYDICT = {
fullscreen: "vspace",
fillscreen2: "fillscreen",
sandwichclampcollapsed: "clamp",
ifelse: "ifthenelse",
xcor: "x",
ycor: "y",
seth: "setheading",
remainder2: "mod",
plus2: "plus",
product2: "multiply",
division2: "divide",
minus2: "minus",
stack: "do",
hat: "action",
stopstack: "break",
clean: "clear",
setxy2: "setxy",
greater2: "greater",
less2: "less",
equal2: "equal",
random2: "random",
setvalue: "setshade",
setchroma: "setgrey",
setgray: "setgrey",
gray: "grey",
chroma: "grey",
value: "shade",
hue: "color",
startfill: "beginfill",
stopfill: "endfill",
string: "text",
shell: "turtleshell"
};
// Define blocks here. Note: The blocks are placed on the palettes
// from bottom to top, i.e., the block at the top of a palette will be
// the last block added to a palette.
/**
* @public
* @param {Object} palettes
* @param {Object} blocks
* @returns {void}
*/
function initBasicProtoBlocks(palettes, blocks) {
blocks.palettes = palettes;
setupRhythmBlockPaletteBlocks();
setupRhythmBlocks();
setupMeterBlocks();
setupPitchBlocks();
setupIntervalsBlocks();
setupToneBlocks();
setupOrnamentBlocks();
setupVolumeBlocks();
setupDrumBlocks();
setupWidgetBlocks();
setupFlowBlocks();
setupNumberBlocks();
setupActionBlocks();
setupBoxesBlocks();
setupBooleanBlocks();
setupHeapBlocks();
setupDictBlocks();
setupExtrasBlocks();
setupProgramBlocks();
setupGraphicsBlocks();
setupPenBlocks();
setupMediaBlocks();
setupSensorsBlocks();
setupEnsembleBlocks();
// Push protoblocks onto their palettes.
for (const protoblock in blocks.protoBlockDict) {
if (blocks.protoBlockDict[protoblock].palette != null) {
blocks.protoBlockDict[protoblock].palette.add(blocks.protoBlockDict[protoblock]);
}
}
}