meta data for this page
  •  

This is an old revision of the document!


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.

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.

let myshape = roundedRectangle({size: [10, 20], roundRadius: 2})
let myshape = roundedRectangle({size: [10, 20], roundRadius: 2, center: [5, 5], segments: 64})