triangle()

Shape / 2D Primitives

Description

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

NameTypeDescription
x1floatx-coordinate of the first vertex
y1floaty-coordinate of the first vertex
x2floatx-coordinate of the second vertex
y2floaty-coordinate of the second vertex
x3floatx-coordinate of the third vertex
y3floaty-coordinate of the third vertex

Returns

void

Related

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(); } }