Pencil Code Reference > drawon

 

drawon draw on a sprite

drawon is used to draw on a turtle or sprite to create new shapes.

drawon lets you create new shapes by using creating a sprite to serve as a new canvas and drawing on it with a turtle to create your own shape, e.g. a new creature.

First, name a sprite and a turtle by setting variables. By default, a new sprite is semi-transparent 256 pixel square, but you can change its color and size. In this example, we are going to draw a dot on a sprite using the turtle.

s = new Sprite

color: gray

t = new Turtle

t.drawon s

t.dot orange, 100

Using clip, we could also make the sprite the shape of that dot.

Moving New Shapes

We use pen, dot and sync to create and move shapes in our next example. sync makes the shapes move in sequence instead of at the same time.

s = new Sprite
  color: gray
t = new Turtle
t.drawon s
t.dot red, 100
t.pen blue, 10
t.fd 100
t.pen null
t.ht()
sync s, t
s.lt 45
s.fd 100

See Sprite to make a blank, turtle-like object on which you can draw or use to display graphics.