🧪 Version 0.3.1 is our alpha release candidate. Please send us bug reports and suggestions!

Sketchingpy

Creative coding and interactive science everywhere for everyone: web, desktop, mobile, Jupyter, and more. Open source!

Reference for translate

Change the location of the origin. This is part of the reference section.

Purpose

Change the transform matrix such that any drawing afterwards is moved by a set amount.

Snippet

Draw an offset rectangle.
sketch.translate(50, 0)  # Translate 50 pixels to the right
sketch.rect(0, 250, 150, 200)  # Draw the rectangle at an offset position of 50, 250.

Parameters

  • x: The number of pixels to offset horizontally.
  • y: The number of pixels to offset vertically.

Examples

Availability

Available on all platforms.

See also