Processing provides the method triangle
in order to draw a triangle. The code below draws a nearly equilateral triangle of 25 pixels between each defining point.
void setup() {
size(500, 500);
background(0);
}
void draw() {
triangle(0, 0, 25, 0, 12, 12);
}
The signature of triangle
is as so:
triangle(x1, y1, x2, y2, x3, y3);
Each x
point corresponds to the point's x axis, and y
to the y axis. The three points will be joined to form a triangle.