GSDP:GAM100/CProcessing/CP Graphics DrawLine()
From Inside
< GSDP:GAM100 | CProcessing
CP_Graphics_DrawLine()
Description
Line is a function that draws a line using two points. For most shapes you can set the color using CP_Settings_Fill(), but a line is only a stroke, so you must use CP_Settings_Stroke() to set the color.
Parameters
CP_Graphics_DrawLine(x1, y1, x2, y2);
- x1 - (float) the first point's x position
- y1 - (float) the first point's y position
- x2 - (float) the second point's x position
- y2 - (float) the second point's y position
Example
void update()
{
// set the stroke color to orange
CP_Settings_Stroke(CP_Color_Create(255, 160, 20, 255));
// draw a line from (100, 100) to (100, 200)
// x1 y1 x2 y2
CP_Graphics_DrawLine(100.0f, 100.0f, 500.0f, 100.0f);
// set the stroke color to light blue
CP_Settings_Stroke(CP_Color_Create(0, 160, 255, 255));
// draw a line from the origin to the mouse position
CP_Graphics_DrawLine(0.0f, 0.0f, CP_Input_GetMouseX(), CP_Input_GetMouseY());
}
Related
- Main Page
- CP_Graphics_DrawRect()
- CP_Graphics_DrawEllipse()
- CP_Graphics_DrawCircle()
- CP_Graphics_DrawPoint()
- CP_Graphics_DrawTriangle()
- CP_Graphics_DrawQuad()
- CP_Graphics_DrawRectAdvanced()
- CP_Graphics_DrawEllipseAdvanced()
- CP_Graphics_DrawLineAdvanced()
- CP_Graphics_DrawTriangleAdvanced()
- CP_Graphics_DrawQuadAdvanced()
- CP_Graphics_BeginShape()
- CP_Graphics_AddVertex()
- CP_Graphics_EndShape()
- CP_Settings_Fill()
- CP_Settings_Stroke()
- CP_Settings_Background()
- CP_Color_Create()
- CP_Input_GetMouseX()
- CP_Input_GetMouseY()