Step 17: Coding the Canvas (Part 2)

Goal:


We will draw a line using the prevX, prevY, currentX, and currentY blocks.

The prev blocks contain the position a user’s finger was at when they first touched the screen.

The current blocks contain the position a user’s finger is currently touching.

We will get these points and draw a line between them every time a finger is moved across the Canvas, letting us doodle!

Steps:

  1. On the “when Canvas1.Dragged” block, hover your mouse over “prevX”.
  2. Then grab the “get prevX” block and place it inside the input of “call Canvas1.DrawLine” labeled “x1”.
  3. Do the same thing for prevY and place it inside “y1”.
  4. Do the same thing for currentX and place it inside “x2”.
  5. Do the same thing for currentY and place it inside “y2”.

Code:


Click to replay