In classBuilt in class, straight after Activity 2.14's deck.
A palette of five monster colors, each drawn as a swatch with its three color numbers charted underneath. The swatch and the bars are the same information — one you read with your eyes, one you read as numbers. Then you take bits away and watch the colors fall apart.

Task 2: every color, and its numbers
'F' → Fullscreen
Create a new Raylib program named 2-15-color-data.
How to read the code blocks. Each task's code block shows your whole program, from line 1, as it should look when that task is finished.
The green lines marked with a + are the ones you add or change for that task — everything else is already in your file. Do not type the + sign.
This lab runs on the classroom computers, not in Juicemind. Close the window to end the program. Escape works too.
names and their reds, greens and blues. DrawSwatch builds each color with new Color and stores it in a variable of type Color, just as an int variable stores a number. The background is a color made the same way.greens and run it again. Only one swatch should change. Put it back.#:package Raylib-cs@8.0.0
using Raylib_cs;
string[] names = { "slime", "lava", "ice", "swamp", "ghost" };int[] reds = { 120, 230, 150, 90, 200 };int[] greens = { 220, 90, 210, 110, 190 };int[] blues = { 80, 40, 245, 60, 230 };
Raylib.InitWindow(800, 450, "Monster Palette");Raylib.SetTargetFPS(60);
while (!Raylib.WindowShouldClose()){ Raylib.BeginDrawing(); Raylib.ClearBackground(new Color(24, 26, 34, 255));
for (int i = 0; i < names.Length; i++) { DrawSwatch(i, 40 + i * 150); }
Raylib.EndDrawing();}
Raylib.CloseWindow();
void DrawSwatch(int index, int x){ Color color = new Color(reds[index], greens[index], blues[index], 255);
Raylib.DrawRectangle(x, 40, 110, 70, color); Raylib.DrawText(names[index], x, 120, 20, Color.White);}DrawChannels draws one bar per channel under each swatch, as tall as the channel's value, with the value printed below it. Its bars array holds three named colors, the way the other arrays hold numbers.#:package Raylib-cs@8.0.0
using Raylib_cs;
string[] names = { "slime", "lava", "ice", "swamp", "ghost" };int[] reds = { 120, 230, 150, 90, 200 };int[] greens = { 220, 90, 210, 110, 190 };int[] blues = { 80, 40, 245, 60, 230 };
Raylib.InitWindow(800, 450, "Monster Palette");Raylib.SetTargetFPS(60);
while (!Raylib.WindowShouldClose()){ Raylib.BeginDrawing(); Raylib.ClearBackground(new Color(24, 26, 34, 255));
for (int i = 0; i < names.Length; i++) { DrawSwatch(i, 40 + i * 150); DrawChannels(i, 40 + i * 150); }
Raylib.EndDrawing();}
Raylib.CloseWindow();
void DrawSwatch(int index, int x){ Color color = new Color(reds[index], greens[index], blues[index], 255);
Raylib.DrawRectangle(x, 40, 110, 70, color); Raylib.DrawText(names[index], x, 120, 20, Color.White);}
void DrawChannels(int index, int x){ int[] values = { reds[index], greens[index], blues[index] }; Color[] bars = { Color.Red, Color.Green, Color.Blue };
for (int c = 0; c < 3; c++) { int height = values[c] * 4 / 5;
Raylib.DrawRectangle(x + c * 38, 400 - height, 30, height, bars[c]); Raylib.DrawText($"{values[c]}", x + c * 38, 408, 16, Color.LightGray); }}DrawChannels and its call, and add DrawRow. It draws the whole palette again at a lower bit depth: levels is how many values each channel may take, and every channel is rounded down to its step.#:package Raylib-cs@8.0.0
using Raylib_cs;
string[] names = { "slime", "lava", "ice", "swamp", "ghost" };int[] reds = { 120, 230, 150, 90, 200 };int[] greens = { 220, 90, 210, 110, 190 };int[] blues = { 80, 40, 245, 60, 230 };
Raylib.InitWindow(800, 450, "Monster Palette");Raylib.SetTargetFPS(60);
while (!Raylib.WindowShouldClose()){ Raylib.BeginDrawing(); Raylib.ClearBackground(new Color(24, 26, 34, 255));
for (int i = 0; i < names.Length; i++) { DrawSwatch(i, 40 + i * 150); }
DrawRow(190, 4); DrawRow(310, 2);
Raylib.EndDrawing();}
Raylib.CloseWindow();
void DrawSwatch(int index, int x){ Color color = new Color(reds[index], greens[index], blues[index], 255);
Raylib.DrawRectangle(x, 40, 110, 70, color); Raylib.DrawText(names[index], x, 120, 20, Color.White);}
void DrawRow(int y, int levels){ int step = 256 / levels;
for (int i = 0; i < names.Length; i++) { int r = reds[i] - reds[i] % step; int g = greens[i] - greens[i] % step; int b = blues[i] - blues[i] % step;
Raylib.DrawRectangle(40 + i * 150, y, 110, 70, new Color(r, g, b, 255)); }
Raylib.DrawText($"{levels} levels per channel", 40, y + 78, 18, Color.LightGray);}levels in the main program, starting at 4, and pass it to the second DrawRow call.Both pictures are screenshots of this page's own programs.

Task 1

Task 3
new Color from the four arraysAnswer the following questions before submitting your work.
Submit three things to the dropbox: