Skip to content

Commit

Permalink
feat: testing scenario (#58)
Browse files Browse the repository at this point in the history
* feat: simplify toolbox blocks for testing discussion

* feat: add simpleCircle scenario

* chore: format

* chore: remove commented out code
  • Loading branch information
rachel-fenichel authored Sep 23, 2024
1 parent e2ebdf0 commit 1632187
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 122 deletions.
122 changes: 0 additions & 122 deletions src/blocks/toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,6 @@ export const toolbox = {
},
},
},
{
kind: 'block',
type: 'p5_stroke',
inputs: {
COLOR: {
shadow: {
type: 'colour_picker',
},
},
},
},
{
kind: 'block',
type: 'p5_fill',
inputs: {
COLOR: {
shadow: {
type: 'colour_picker',
},
},
},
},
{
kind: 'block',
type: 'colour_random',
Expand All @@ -59,105 +37,5 @@ export const toolbox = {
},
},
},
{
kind: 'block',
type: 'p5_ellipse',
inline: 'true',
inputs: {
X: {
shadow: {
type: 'math_number',
fields: {
NUM: 100,
},
},
},
Y: {
shadow: {
type: 'math_number',
fields: {
NUM: 100,
},
},
},
WIDTH: {
shadow: {
type: 'math_number',
fields: {
NUM: 50,
},
},
},
HEIGHT: {
shadow: {
type: 'math_number',
fields: {
NUM: 50,
},
},
},
},
},
{
kind: 'block',
type: 'math_random_int',
inputs: {
FROM: {
shadow: {
type: 'math_number',
fields: {
NUM: 0,
},
},
},
TO: {
shadow: {
type: 'math_number',
fields: {
NUM: 400,
},
},
},
},
},
{
kind: 'block',
type: 'controls_repeat_ext',
inputs: {
TIMES: {
block: {
type: 'math_number',
fields: {
NUM: 5,
},
},
},
},
},
{
kind: 'block',
type: 'math_arithmetic',
fields: {
OP: 'ADD',
},
inputs: {
A: {
shadow: {
type: 'math_number',
fields: {
NUM: 1,
},
},
},
B: {
shadow: {
type: 'math_number',
fields: {
NUM: 1,
},
},
},
},
},
],
};
1 change: 1 addition & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
onchange="document.forms.options.submit()">
<option value="sun">sun</option>
<option value="blank">blank canvas</option>
<option value="simpleCircle">simple circle</option>
</select>
</form>
</div>
Expand Down
74 changes: 74 additions & 0 deletions test/loadTestBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,79 @@ const blankCanvas = {
},
};

const simpleCircle = {
'blocks': {
'languageVersion': 0,
'blocks': [
{
'type': 'p5_setup',
'id': '5.{;T}3Qv}Awi:1M$:ut',
'x': 0,
'y': 75,
'deletable': false,
'inputs': {
'STATEMENTS': {
'block': {
'type': 'p5_canvas',
'id': 'spya_H-5F=K8+DhedX$y',
'deletable': false,
'movable': false,
'fields': {
'WIDTH': 400,
'HEIGHT': 400,
},
'next': {
'block': {
'type': 'p5_background_color',
'id': 'i/Hvi~^DYffkN/WpT_Ck',
'inputs': {
'COLOR': {
'shadow': {
'type': 'colour_picker',
'id': 'B:zpi7kg+.GF_Dutd9GL',
'fields': {
'COLOUR': '#9999ff',
},
},
},
},
},
},
},
},
},
},
{
'type': 'p5_draw',
'id': '3iI4f%2#Gmk}=OjI7(8h',
'x': 0,
'y': 332,
'deletable': false,
'inputs': {
'STATEMENTS': {
'block': {
'type': 'simple_circle',
'id': '_}!@OHwjAb,2Gi8nT0}L',
'inline': true,
'inputs': {
'COLOR': {
'shadow': {
'type': 'colour_picker',
'id': 'gq(POne}j:hVw%C3t{vx',
'fields': {
'COLOUR': '#f59b42',
},
},
},
},
},
},
},
},
],
},
};

/**
* Loads saved state from local storage into the given workspace.
* @param {Blockly.Workspace} workspace Blockly workspace to load into.
Expand All @@ -185,6 +258,7 @@ export const load = function (workspace, scenarioString) {
const scenarioMap = {
'blank': blankCanvas,
'sun': sunnyDay,
'simpleCircle': simpleCircle,
};

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

0 comments on commit 1632187

Please sign in to comment.