Made the example colorful
This commit is contained in:
parent
41cee3b156
commit
c753ef751c
|
|
@ -30,7 +30,7 @@ int main(void)
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - pie chart");
|
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - pie chart");
|
||||||
|
|
||||||
// Pie slice angles (must sum to 360)
|
// Pie slice angles (must sum to 360)
|
||||||
const int angles[] = { 30, 10, 45, 35, 60, 38, 75, 67 };
|
const float angles[] = { 30.0f, 10.0f, 45.0f, 35.0f, 60.0f, 38.0f, 75.0f, 67.0f };
|
||||||
const int anglesCount = (int)(sizeof(angles)/sizeof(angles[0]));
|
const int anglesCount = (int)(sizeof(angles)/sizeof(angles[0]));
|
||||||
|
|
||||||
const float radius = 150.0f;
|
const float radius = 150.0f;
|
||||||
|
|
@ -56,14 +56,18 @@ int main(void)
|
||||||
|
|
||||||
for (int i = 0; i < anglesCount; i++)
|
for (int i = 0; i < anglesCount; i++)
|
||||||
{
|
{
|
||||||
// Gradient gray color per slice
|
float hue = (i/(float)anglesCount)*360.0f;
|
||||||
unsigned char gray = (unsigned char)((i/(float)anglesCount)*255.0f);
|
float sat = 0.75f;
|
||||||
|
float val = 0.95f;
|
||||||
|
|
||||||
|
// Convert HSV to RGBA
|
||||||
|
Color col = ColorFromHSV(hue, sat, val);
|
||||||
|
|
||||||
// Draw pie piece using DrawCircleSector()
|
// Draw pie piece using DrawCircleSector()
|
||||||
DrawCircleSector(center, radius, lastAngleDeg, lastAngleDeg + (float)angles[i],
|
DrawCircleSector(center, radius, lastAngleDeg, lastAngleDeg + angles[i],
|
||||||
segments, (Color){ gray, gray, gray, 255 });
|
segments, col);
|
||||||
|
|
||||||
lastAngleDeg += (float)angles[i];
|
lastAngleDeg += angles[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawText("Pie chart drawing example", 260, 400, 20, LIGHTGRAY);
|
DrawText("Pie chart drawing example", 260, 400, 20, LIGHTGRAY);
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.7 KiB |
Loading…
Reference in New Issue
Block a user