Skip to content

Commit ad213f5

Browse files
feat: make draw code only run once (#70)
1 parent 51df48f commit ad213f5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/blocks/p5_generators.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ forBlock['text_print'] = function (block, generator) {
1919
forBlock['p5_setup'] = function (block, generator) {
2020
const statements = generator.statementToCode(block, 'STATEMENTS');
2121
const code = `sketch.setup = function() {
22-
${statements}};\n`;
22+
${statements}
23+
// Only run draw code once.
24+
sketch.noLoop();
25+
};
26+
`;
2327
return code;
2428
};
2529

0 commit comments

Comments
 (0)