Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

COMPUTER GRAPHICS - Use figure *************B Solve Practice Exercise 2.3.1. Wri

ID: 3886777 • Letter: C

Question

COMPUTER GRAPHICS - Use figure *************B

Solve Practice Exercise 2.3.1. Write the program and name your source code as checker.cpp.

Requirement: Make the checkerboard use two random colors every time you run your program.

Practice Exercises. 2.3.1. Drawing the checkerboard. (Try your hand at this before looking at the answers.) Write the routine checkerboard (int size) that draws the checkerboard shown in Figure 2.31b. Place the checkerboard with its lower left corner at (0,0). Each of the 64 squares has length size pixels. Choose two nice colors for the squares. Solution: The ij-th square has lower left corner at (i*size,j"size) for i = 0, and-0.7. The color can be made to alternate between (r, g, b) and (r2, g,, b,) using if((i + j) %2-0) // if i + j is even glColor3f( r1, gl, bl); else glColor3f (r2, g2, b2)

Explanation / Answer

#include<graphics.h>
#include<conio.h>
#include<iostream.h>
void main()
{
int gd = DETECT,gm;
clrscr();
initgraph(&gd,&gm," ");
setcolor(5);
line(20,50,20,180);
line(20,50,100,50);
line(20,70,100,70);
line(20,90,100,90);
line(20,110,100,110);
line(100,50,100,110);
circle(60,80,10);
line(52,80,68,80);
line(60,72,60,88);
setfillstyle(SOLID_FILL,22);
floodfill(21,51,5);
setfillstyle(SOLID_FILL,7);
floodfill(21,75,5);
setfillstyle(SOLID_FILL,2);
floodfill(21,95,5);
setfillstyle(SOLID_FILL,7);
floodfill(81,75,5);
setfillstyle(SOLID_FILL,7);
floodfill(61,81,5);
getch();
closegraph();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote