🧪 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 draw_rect

Draw a rectangle. This is part of the reference section.

Purpose

Draw a rectangle or, if width and height are the same, a square.

Snippet

Draw a rectangle at x coordinate of 100 and y coordinate of 150 using a width of 20 pixels and height of 40 pixels. Note that a width and height of zero in corner mode is the same as draw_pixel.
sketch.set_rect_mode('center')
sketch.draw_rect(100, 150, 20, 40)

Parameters

  • x1: The x location at which to draw the rectangle.
  • y1: The y location at which to draw the rectangle.
  • x2: Horizontal size. Note that a width of zero in corner mode sets a single pixel row.
  • y2: Vertical size. Note that a widtdh of zero in corner mode sets a single pixel column.

Examples

Availability

Available for all platforms.

See also