1 / 12

Dark GDK Colors

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.

merlin
Download Presentation

Dark GDK Colors

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Dark GDK Colors COMP 310

  2. RGB Color System 8 bits 32 bits

  3. 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

  4. 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

  5. dbClear function • Example: dbClear(255, 0, 0);

  6. dbClear function dbClear(0, 255, 0);

  7. dbClear function • dbClear(0, 0, 0);

  8. 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(); }

  9. 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);

  10. Drawing in Color • dbInk function • Changes the current drawing colors in shapes and text • General format: • dbInk(foreground, background);

  11. 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(); }

  12. Practice • Drawing the Italian flag

More Related