meta data for this page
  •  

Rectangle

A two dimensional shape made with four straight sides where all interior angles are right angles (90°).

 Rectangle

Learn about rectangles at MathIsFun.com

The size specifies the size across X and Y axis. Rectangles can be created at a requested center.

Defaults:

  • size : [2, 2]
  • center : [0, 0]
const myshape = rectangle({size: [3, 4])
const myshape = rectangle({size: [3, 4], center: [5, 5])

Square

 Square

The specialized square primitive also exists, but requires only one number value for all sides.

Defaults:

  • size : 2
  • center : [0, 0]
const myshape = square({size: 3)
const myshape = square({size: 3, center: [5, 5])

Rounded Rectangle


Rounded rectangles can be created by specifying a roundRadius for the corners.

Defaults:

  • size : [2, 2]
  • center : [0, 0]
  • roundedRadius: 0.2
  • segments: 32
const myshape = roundedRectangle({size: [10, 20], roundRadius: 2})
const myshape = roundedRectangle({size: [10, 20], roundRadius: 2, center: [5, 5], segments: 64})