triangle()
Shape / 2D PrimitivesDescription
Draws a triangle to the screen using the coordinates of its three vertices.
Syntax
void triangle(float x1, float y1, float x2, float y2, float x3, float y3)
Parameters
| Name | Type | Description |
|---|---|---|
| x1 | float | x-coordinate of the first vertex |
| y1 | float | y-coordinate of the first vertex |
| x2 | float | x-coordinate of the second vertex |
| y2 | float | y-coordinate of the second vertex |
| x3 | float | x-coordinate of the third vertex |
| y3 | float | y-coordinate of the third vertex |
Returns
voidRelated
Under the Hood
From Processing.h:
void triangle(float x1,float y1,float x2,float y2,float x3,float y3);
void triangle(float,float,float,float,float,float);
inline void triangle(A x1,B y1,C x2,D y2,E x3,F y3){ _api::triangle((float)x1,(float)y1,(float)x2,(float)y2,(float)x3,(float)y3);
void triangle(float x1, float y1, float x2, float y2, float x3, float y3);
inline void triangle(float x1,float y1,float x2,float y2,float x3,float y3){ if(PApplet::g_papplet) PApplet::g_papplet->triangle(x1,y1,x2,y2,x3,y3); }
inline void PGraphics::triangle(float x1,float y1,float x2,float y2,float x3,float y3){ if(PApplet::g_papplet) PApplet::g_papplet->triangle(x1,y1,x2,y2,x3,y3); }
Under the Hood
From Processing.cpp:
void PApplet::triangle(float x1, float y1, float x2, float y2, float x3, float y3) {
if (doFill) {
applyFill();
glBegin(GL_TRIANGLES);
glVertex2f(x1, y1);
glVertex2f(x2, y2);
glVertex2f(x3, y3);
glEnd();
}
if (doStroke) {
applyStroke();
glLineWidth(strokeW);
glBegin(GL_LINE_LOOP);
glVertex2f(x1, y1);
glVertex2f(x2, y2);
glVertex2f(x3, y3);
glEnd();
restoreLighting();
}
}