GSDP:GAM100/CProcessing/triangle()

From Inside
Jump to: navigation, search

triangle()

Description

The triangle() function draws a triangle to the screen given three points. The filled color of the triangle can be set with fill() and the stroke outline can be changed with stroke() .

Parameters

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

  • x1 - (float) the first point's horizontal position
  • y1 - (float) the first point's vertical position
  • x2 - (float) the second point's horizontal position
  • y2 - (float) the second point's vertical position
  • x3 - (float) the third point's horizontal position
  • y3 - (float) the third point's vertical position

Example

void update() 
{
    // set the fill color to red
    fill(color(255, 0, 0, 255));

    // draw a triangle with three points
    triangle(100.0f, 100.0f,  // point 1
             200.0f, 100.0f,  // point 2
             200.0f, 200.0f); // point 3

    // set the fill color to dark blue
    fill(color(0, 0, 160, 255));

    // draw a triangle with three points
    triangle(0.0f, 0.0f,        // point 1
             mouseX, mouseY,    // point 2
             pmouseX, pmouseY); // point 3
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>