Skip to content

Commit

Permalink
turtle.js: Add block to show/hide triangle on canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbazzan committed Sep 27, 2024
1 parent f60b93d commit c6dae19
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions turtle.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
// NB: when pen is true, we draw otherwise we move without drawing
function penUp(){ pen = false; }
function penDown(){ pen = true; }
function hideTriangle(){ visible = false; }
function showTriangle(){ visible = true; }
function recenter(){ pos = {x: WIDTH/2, y: HEIGHT/2 }; }

function reset(){
Expand Down Expand Up @@ -103,6 +105,8 @@
Menu.item("Pen up", penUp);
Menu.item("Pen down", penDown);
Menu.item("Back to center", recenter);
Menu.item("Show triangle", showTriangle);
Menu.item("Hide triangle", hideTriangle);

script.addEventListener('beforeRun', clear, false);
script.addEventListener('afterRun', drawTriangle, false);
Expand Down

0 comments on commit c6dae19

Please sign in to comment.