How can we move things on the screen?

20 months ago by

How can we move things around the screen?


1 Answer

20 months ago by

The function used to move a shape around is translated.  If you have a picture called pic, then you can draw the same thing slightly to the top right, like this: translated(pic, 5, 5).

  • The first parameter to this function is a picture, which is the shape before you move it.
  • The second is how far to move the shape left or right.  Negative numbers are left, and positive numbers are right.
  • The third is how far to move the shape up or down. Negative numbers are down, and positive numbers are up.

If the picture you are moving already has parentheses, such as colored(solidCircle(1), red), that's okay.  Just put the entire expression describing the starting picture into the first parameter, and make sure your parentheses match.  For example: translated(colored(solidCircle(1), red), 5, 5).  Or, if the parentheses inside of parentheses are getting to be too much for you, you can start naming the parts with new variables instead to simplify.

Please login to add an answer/comment or follow this question.

Similar posts:
Search »