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
  • Example
  • Syntax
  • Description
  1. Reference
  2. Shapes
  3. 2D

triangle()

Triangle - Draws a triangle with the given inputs

Previoussquare()Nextcircle()

Last updated 2 years ago

Example

triangle(100, 100, 200, 300,300,100)

Syntax

triangle(x1, y1, x2, y2, x3, y3)
Input
Description

x1

x co-ordinate of the left corner

y1

y co-ordinate of the left corner

x2

x co-ordinate of the middle corner

y2

y co-ordinate of the middle corner

x3

x co-ordinate of the right corner

y3

y co-ordinate of the right corner

Description

triangle() draws a triangle on the canvas, using the inputs to determine the positions of the 3 corners. Even though this is the simplest 2D shape, it takes the most complicated form of input, since total freedom to specify the shape is given.

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 .

Strivemath
here