P5 Python Docs
  • Getting Started
  • Simple mode
  • Reference
    • Shapes
      • 2D
        • point()
        • line()
        • rect()
        • square()
        • triangle()
        • circle()
        • ellipse()
        • arc()
        • quad()
        • beginShape()
      • 3D
        • plane()
        • box()
        • sphere()
        • cone()
        • cylinder()
        • ellipsoid()
        • torus()
    • Controlling the environment
      • coordinateMode()
      • rectMode()
      • ellipseMode()
      • frameRate()
      • setup()
      • draw()
    • Built-in Variables
      • Environment
      • Keyboard
      • Mouse
    • Built-in Functions
      • keyIsDown()
      • millis()
      • second()
      • minute()
      • hour()
      • translate()
      • rotate()
      • createSlider()
      • createGraphics()
      • createVector()
    • Events
      • Keyboard
        • keyPressed()
        • keyReleased()
      • Mouse
        • mouseMoved()
        • mouseDragged()
        • mousePressed()
        • doubleClicked()
        • mouseWheel()
    • Text
      • text()
      • textSize()
      • textAlign()
    • Math
      • drawTickAxes()
      • random()
      • randomGaussian()
      • dist()
      • linmap()
      • bounce()
      • wave()
    • Colour and Outline
      • colorMode()
      • fill()
      • stroke()
      • strokeWeight()
      • background()
    • Images & Audio
      • loadImage() and image()
      • loadSound()
    • 3D Controls
      • orbitControl()
      • translate()
      • rotateZ()
      • rotateX()
      • rotateY()
      • scale()
Powered by GitBook
On this page
  • How are 2D Shapes drawn?
  • Shortcut to common shapes
  1. Reference
  2. Shapes

2D

These pages explain how to use the 2D primitives in the library

PreviousShapesNextpoint()

Last updated 2 years ago

How are 2D Shapes drawn?

In 2D mode, shapes are defined by a sequence of vertices that are then connected into edges to form a closed region.

Shortcut to common shapes

Some shapes have a known configuration of vertices (for example, we all know what the vertices of a square look like), and this gives us an advantage to use other simpler information (like the center of the square, and the length of its sides), and from that, we can calculate all the other vertices.

Vertices

quad(x1, y1, x2, y2, x3, y3, x4, y4)

Shortcut

rect(x, y, size, size)

The region can be filled with any color using , and the edges can be colored using .

Shapes like , , , , offer that shortcut. You can always resort to using , , or .

Find these documents helpful? Let the people who made them help your child learn to code at !

We'd love to hear your Feedback/Comments .

fill()
stroke()
circle()
ellipse()
arc()
square()
rect()
beginShape()
triangle()
quad()
Strivemath
here
Cover

beginShape() - General Polygon

Cover

rect() - Rectangle

Cover

triangle() - Triangle

Cover

point() - Point

Cover

line() - Line

Cover

ellipse() - Ellipse

Cover

circle() - Circle

Cover

arc() - Arc

Cover

quad() - Quadrilateral

This is what the final shape looks like