130 likes | 293 Views
Dark GDK Colors. COMP 310. RGB Color System. 8 bits. 32 bits. RGB Color System. In the RGB color system all colors are created by mixing various shades of red, green, and blue.
E N D
Dark GDK Colors COMP 310
RGB Color System 8 bits 32 bits
RGB Color System • In the RGB color system all colors are created by mixing various shades of red, green, and blue. • color channels – when you define a color, you specify a value in the range of 0 through 255 for each of the colors channels. • dbClear function
dbClear function • Clears the Dark GDK window and fills it with a specified color. • General format: • dbClear(red, green, blue); • The higher the number for a channel, the brighter that color component will be
dbClear function • Example: dbClear(255, 0, 0);
dbClear function dbClear(0, 255, 0);
dbClear function • dbClear(0, 0, 0);
Ejemplo Programación #include “DarkGDK.h” void DarkGDK() { // Clear the screen to red. dbClear(255, 0, 0); // Wait for 1 second. dbWait(1000); // Clear the screen to white. dbClear( 255, 255, 255); // Wait for 1 second. dbWait(1000); // Clear the screen to blue dbClear(0, 0, 255); // Wait for 1 second. dbWait(1000); dbWaitKey(); }
DWORD data type • Typically used to store RGB colors. • dbRGB function • Format the individual bits in a DWORD variable • Example: • DWORD brightRed; • brightRed = dbRGB(255, 0, 0); • Another example: • DWORD brightRed = dbRGB(255, 0, 0);
Drawing in Color • dbInk function • Changes the current drawing colors in shapes and text • General format: • dbInk(foreground, background);
Drawing in Color #include “DarkGDK.h” void DarkGDK() { //Declare variables for blue, magenta, white, and black. DWORD blue = dbRGB(0, 0, 255); DWORD magenta = dbRGB(255, 0, 255); DWORD white = dbRGB(255, 255, 255); DWORD black = dbRGB(0, 0, 0); //Clear the screen to a blue background dbClear(0, 0, 255); // Change the current drawing color to magenta dbInk(magenta, black); //Draw a box dbBox(50, 50, 590, 430); // Change the current drawing color to white dbInk(white, black); //Draw a circle dbCircle(320, 240, 100); dbWaitKey(); }
Practice • Drawing the Italian flag