GSDP:GAM100/CProcessing/CP Graphics DrawTriangle()

From Inside
Jump to: navigation, search

CP_Graphics_DrawTriangle()

Description

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

Parameters

CP_Graphics_DrawTriangle(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
    CP_Settings_Fill(CP_Color_Create(255, 0, 0, 255));

    // draw a triangle with three points
    CP_Graphics_DrawTriangle(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
    CP_Settings_Fill(CP_Color_Create(0, 0, 160, 255));

    // draw a triangle with three points
    CP_Graphics_DrawTriangle(0.0f, 0.0f,        // point 1
             CP_Input_GetMouseX(), CP_Input_GetMouseY(),    // point 2
             CP_Input_GetMousePreviousX(), CP_Input_GetMousePreviousY()); // point 3
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>