Sem 4‎ > ‎CG LAB‎ > ‎

P3: WAP to... REDONE

posted Jan 1, 2012, 11:17 PM by Neil Mathew   [ updated Jan 1, 2012, 11:34 PM ]

What I learnt:
  •  In plotting points for drawpoly or fillpoly, if you're using fractions instead of decimal points, it should be followed by a decimal point. eg: instead of 0.5, use (1.0/2.0)

  • Functions like fillpoly(), filleclipse() creates a border on its own. Hense, both setcolor() and setfillstyle() can be used to customize the fill_ functions.

  • Take Note of the flying bird, use of arcs. Easy to implement, but looks difficult.

  • Room for improvement?
    Draw a boat, some floating lotus leaves, or a floating house boat.
    Make Sun so large, it's masked slightly by both mountains.
    


SOURCE CODE:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<graphics.h>
#include<conio.h>
 
void main()
{
int gdriver=DETECT, gmode;
initgraph(&gdriver,&gmode,"C:/TC/BGI");
 
setbkcolor(BLUE);    //1
setcolor(WHITE);             //2
line(0,3*getmaxy()/4,getmaxx(), 3*getmaxy()/4);  //3,4,5
 
 
setfillstyle(SOLID_FILL,LIGHTCYAN);       //6
floodfill(0,0,WHITE);                     //7
 
 
setcolor(RED);
setfillstyle(SOLID_FILL,YELLOW);
fillellipse(getmaxx()*(1.0/2.0),getmaxy()*(1.0/4.0),20,20);      //8
 
 
int points[]={
           0,getmaxy()*(3.0/4.0),
           getmaxx()*(1.0/4.0),0,
           getmaxx()*(1.0/2.0),getmaxy()*(3.0/4.0),
           0,getmaxy()*(3.0/4.0)
           };
int points2[]={
           getmaxx()*(1.0/2.0),getmaxy()*(3.0/4.0),
           getmaxx()*(3.0/4.0),0,
           getmaxx(),getmaxy()*(3.0/4.0),
           getmaxx()*(1.0/2.0),getmaxy()*(3.0/4.0)
           };
 
setfillstyle(SOLID_FILL,GREEN);
setcolor(WHITE);
fillpoly(4,points);                          //9
 
setcolor(WHITE);
drawpoly(4, points2);                        //10
floodfill(getmaxx()*(3.0/4.0) + 1.0, getmaxy()*(1.0/2.0),WHITE); 
                                                         
setcolor(BLACK);
arc(getmaxx()*(1.0/8.0), getmaxy()*(1.0/8.0),60,120,20);    //11
arc(getmaxx()*(1.0/8.0)+20, getmaxy()*(1.0/8.0),60,120,20);

getch();
closegraph();
}




OUTPUT: