GSDP:GAM100/CProcessing/CP Color Create()
From Inside
< GSDP:GAM100 | CProcessing
CP_Color_Create()
Description
Create a CP_Color from given red, green, blue, and alpha values. The input values must be in the range of 0 to 255. CP_Color_Create() can be used to create a variable or used to pass a CP_Color directly as a function parameter.
Parameters
CP_Color_Create(int r, int g, int b, int a)
- r - (int) the red value of the color
- g - (int) the green value of the color
- b - (int) the blue value of the color
- a - (int) the alpha value of the color
Example
void init()
{
// Use the CP_Color_Create function to create a variable
CP_Color color1 = CP_Color_Create(255, 40, 100, 255);
// Set the background with color1 (berry red)
CP_Settings_Background(color1);
// Create a color and pass it directly as a function parameter
CP_Settings_Fill(CP_Color_Create(0, 200, 255, 255));
// Draw a rectangle at the top left of the screen (blue)
float rectWidth = CP_System_GetCanvasWidth() * 0.5f;
float rectHeight = CP_System_GetCanvasHeight() * 0.5f;
CP_Graphics_DrawRect(0, 0, rectWidth, rectHeight);
}