Painting with NetLogo

That's what the visual display looks like whenever the setup/clear button is pressed.

1. You can paint with patches: use the moue to click on any of the colors at the top and then paint by coloring the patches below the mouse when the mouse button is pressed.

2. You can paint with a turtle (the turtle does the drawing) with pen-size equal to the width slider when the mouse button is pressed.

3. You can erase both patches and drawing simultaneously with the Eraser.
Here's the code, with the good stuff missing (the semi-colon starts a comment on a line)


globals [mcolor]

to setup
  ca
  resize-world -70 70 -70 70
  set-patch-size 3
  set mcolor red
  crt 1
  ask turtles [
    set color red 
    set size 3
  ]
  palette
end

to palette
  ; this procedure draws the palette onto the patches where pycor > 60
end

to patch-paint
  ; this procedure paints by recoloring the patches when the mouse button is pressed
end

to turtle-paint
  ; this procedure paints by moving the turtle and using it to draw when the mouse button is pressed
end
    
to turtle-eraser
  ; this procedure erases both the drawn lines and the patches when the mouse button is pressed
end