Skip to content

Commit 1632187

Browse files
feat: testing scenario (#58)
* feat: simplify toolbox blocks for testing discussion * feat: add simpleCircle scenario * chore: format * chore: remove commented out code
1 parent e2ebdf0 commit 1632187

File tree

3 files changed

+75
-122
lines changed

3 files changed

+75
-122
lines changed

src/blocks/toolbox.js

Lines changed: 0 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,6 @@ export const toolbox = {
1818
},
1919
},
2020
},
21-
{
22-
kind: 'block',
23-
type: 'p5_stroke',
24-
inputs: {
25-
COLOR: {
26-
shadow: {
27-
type: 'colour_picker',
28-
},
29-
},
30-
},
31-
},
32-
{
33-
kind: 'block',
34-
type: 'p5_fill',
35-
inputs: {
36-
COLOR: {
37-
shadow: {
38-
type: 'colour_picker',
39-
},
40-
},
41-
},
42-
},
4321
{
4422
kind: 'block',
4523
type: 'colour_random',
@@ -59,105 +37,5 @@ export const toolbox = {
5937
},
6038
},
6139
},
62-
{
63-
kind: 'block',
64-
type: 'p5_ellipse',
65-
inline: 'true',
66-
inputs: {
67-
X: {
68-
shadow: {
69-
type: 'math_number',
70-
fields: {
71-
NUM: 100,
72-
},
73-
},
74-
},
75-
Y: {
76-
shadow: {
77-
type: 'math_number',
78-
fields: {
79-
NUM: 100,
80-
},
81-
},
82-
},
83-
WIDTH: {
84-
shadow: {
85-
type: 'math_number',
86-
fields: {
87-
NUM: 50,
88-
},
89-
},
90-
},
91-
HEIGHT: {
92-
shadow: {
93-
type: 'math_number',
94-
fields: {
95-
NUM: 50,
96-
},
97-
},
98-
},
99-
},
100-
},
101-
{
102-
kind: 'block',
103-
type: 'math_random_int',
104-
inputs: {
105-
FROM: {
106-
shadow: {
107-
type: 'math_number',
108-
fields: {
109-
NUM: 0,
110-
},
111-
},
112-
},
113-
TO: {
114-
shadow: {
115-
type: 'math_number',
116-
fields: {
117-
NUM: 400,
118-
},
119-
},
120-
},
121-
},
122-
},
123-
{
124-
kind: 'block',
125-
type: 'controls_repeat_ext',
126-
inputs: {
127-
TIMES: {
128-
block: {
129-
type: 'math_number',
130-
fields: {
131-
NUM: 5,
132-
},
133-
},
134-
},
135-
},
136-
},
137-
{
138-
kind: 'block',
139-
type: 'math_arithmetic',
140-
fields: {
141-
OP: 'ADD',
142-
},
143-
inputs: {
144-
A: {
145-
shadow: {
146-
type: 'math_number',
147-
fields: {
148-
NUM: 1,
149-
},
150-
},
151-
},
152-
B: {
153-
shadow: {
154-
type: 'math_number',
155-
fields: {
156-
NUM: 1,
157-
},
158-
},
159-
},
160-
},
161-
},
16240
],
16341
};

test/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
onchange="document.forms.options.submit()">
9494
<option value="sun">sun</option>
9595
<option value="blank">blank canvas</option>
96+
<option value="simpleCircle">simple circle</option>
9697
</select>
9798
</form>
9899
</div>

test/loadTestBlocks.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,79 @@ const blankCanvas = {
176176
},
177177
};
178178

179+
const simpleCircle = {
180+
'blocks': {
181+
'languageVersion': 0,
182+
'blocks': [
183+
{
184+
'type': 'p5_setup',
185+
'id': '5.{;T}3Qv}Awi:1M$:ut',
186+
'x': 0,
187+
'y': 75,
188+
'deletable': false,
189+
'inputs': {
190+
'STATEMENTS': {
191+
'block': {
192+
'type': 'p5_canvas',
193+
'id': 'spya_H-5F=K8+DhedX$y',
194+
'deletable': false,
195+
'movable': false,
196+
'fields': {
197+
'WIDTH': 400,
198+
'HEIGHT': 400,
199+
},
200+
'next': {
201+
'block': {
202+
'type': 'p5_background_color',
203+
'id': 'i/Hvi~^DYffkN/WpT_Ck',
204+
'inputs': {
205+
'COLOR': {
206+
'shadow': {
207+
'type': 'colour_picker',
208+
'id': 'B:zpi7kg+.GF_Dutd9GL',
209+
'fields': {
210+
'COLOUR': '#9999ff',
211+
},
212+
},
213+
},
214+
},
215+
},
216+
},
217+
},
218+
},
219+
},
220+
},
221+
{
222+
'type': 'p5_draw',
223+
'id': '3iI4f%2#Gmk}=OjI7(8h',
224+
'x': 0,
225+
'y': 332,
226+
'deletable': false,
227+
'inputs': {
228+
'STATEMENTS': {
229+
'block': {
230+
'type': 'simple_circle',
231+
'id': '_}!@OHwjAb,2Gi8nT0}L',
232+
'inline': true,
233+
'inputs': {
234+
'COLOR': {
235+
'shadow': {
236+
'type': 'colour_picker',
237+
'id': 'gq(POne}j:hVw%C3t{vx',
238+
'fields': {
239+
'COLOUR': '#f59b42',
240+
},
241+
},
242+
},
243+
},
244+
},
245+
},
246+
},
247+
},
248+
],
249+
},
250+
};
251+
179252
/**
180253
* Loads saved state from local storage into the given workspace.
181254
* @param {Blockly.Workspace} workspace Blockly workspace to load into.
@@ -185,6 +258,7 @@ export const load = function (workspace, scenarioString) {
185258
const scenarioMap = {
186259
'blank': blankCanvas,
187260
'sun': sunnyDay,
261+
'simpleCircle': simpleCircle,
188262
};
189263

190264
const data = JSON.stringify(scenarioMap[scenarioString]);

0 commit comments

Comments
 (0)