GSDP:GAM100/CProcessing/CP Color Create()

From Inside
Jump to navigation Jump to search



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.


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


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)
    // 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);