Drawing and Animating Objects


Drawing and animating an object involve four steps:

  1. Initializing the object — Refer to Shapes
    A composite object can be created using the + operator or the add function
  2. Styling the object — Refer to Styling
  3. Animating the object — Refer to Animation
  4. Drawing the object — Use the draw() command

IMPORTANT: All draw() commands should be gathered and placed at the end of the source code.


Example:

set FRAME_RATE to 10
set CANVAS_WIDTH to 500
set CANVAS_HEIGHT to 500
set CANVAS_BACKGROUND to "#DEDEDE"
                
p_color: Text = "#C2B280"
txt: Text = "I'm not lying"
txt_box: Object
                
pinocchio: Object = circle(0, 250, 200)
nose = rectangle(-650, 250, 800, 15)
mouth = line(50, 290, 90, 290)
                
eye = circle(50, 230, 20)
eye.fill("#000000")
                
pinocchio += (mouth)
pinocchio.fill(p_color)
                
nose.fill(p_color)
nose.moveX(20, 1, 500)
                
txt_box.write(txt, 120, 120)
                
nose.draw(1, 500)
pinocchio.draw(1, 500)
eye.draw(1, 500)
txt_box.draw(1, 500)