Sunday, 10 April 2016

Program to draw circle using Cartesian coordinates

C++ program to draw a circle using Cartesian Coordinates technique 

Solution:

#include<iostream.h>
#include<graphics.h>
#include<conio.h>
#include<math.h>
void main()
{
int xc, yc, x, y, r;
cout<<"please enter center point of the circle";
cin>>xc>>yc;
cout<<"please enter the radius of the circle";
cin>>r;
int gd=DETECT, gm;
initgraph(&gd,&gm, "..\\bgi");
for(x=r-xc; x<=r+xc; x++)
{
y=yc+sqrt((r*r-(x-xc)*(x-xc)));
putpixel(x,y, RED);
y=yc-sqrt((r*r-(x-xc)*(x-xc)));
putpixel(x,y, BLUE);
}
getch();
}




output: 



Solution of homework 2

Write a C++ Program to print start on the screen.

Solution: 
#include<iostream.h>
#include<graphics.h>
#include<conio.h>
void main()
{
int x1,x2,x3,x4,x5,y1,y2,y3,y4,y5;
cout<< "please enter 1st point coordinates";
cin>>x1>>y1;
cout<< "please enter 2nd point coordinates";
cin>>x2>>y2;
cout<< "please enter 3rd point coordinates";
cin>>x3>>y3;
cout<< "please enter 4th point coordinates";
cin>>x4>>y4;
cout<< "please enter 5th point coordinates";
cin>>x5>>y5;
int gd=DETECT, gm;
initgraph(&gd,&gm, "..\\bgi");
line(x1,y1,x2,y2); getch();
line(x3,y3,x4,y4); getch();
line(x3,y3,x5,y5); getch();
line(x1,y1,x4,y4); getch();
line(x2,y2,x5,y5); getch();
Output: 
















 

Solution of homework 1

Write a C++ Program to print the entire screen with BROWN color.
in my case Screen Size: 600*480

Solution:
 #include<iostream.h>
#include<graphics.h>
#include<conio.h>
void main()
{
cout<<"Program to print entire screen with BROWN color";
int gd=DETECT, gm;
initgraph(&gd,&gm, "..\\bgi");
for(int x=0;x<600; x++)
for(int y=0; y<480;y++)
{
putpixel(x,y, BROWN);
 }
getch();

}


Output

Tuesday, 22 March 2016

Time Table

Time Table for the course

Theory Session:
                           Day                                    Time
                          Monday                          1200 - 1300
                          Tuesday                          1100 - 1200

Lab Session:
                         Monday                           1430 - 1530
                         Tuesday                           1430 - 1530
                         Friday                              1430 - 1530



Note: 80% attendance is compulsory to appear in exam

Lab 1

Implementation of Line Incremental Algorithm

#include<graphics.h>
#include<iostream.h>
#include<conio.h>
void main()
{

int px1, px2, py1, py2, b;
float m;
int dy, dx;
cout<<"Dear please enter P1 points to draw a line";
cin>>px1>>py1;
cout<<"Dear please enter P2 points to draw a line";
cin>>px2>>py2;
dy=py2-py1; //py1-py2;
dx=px2-px1; //px1-px2;
m=float(dy/dx);
b=py1-m*px1;
//b=py2-m*px2;
int gd=DETECT, gm;
initgraph(&gd, &gm,"..\\bgi");
if(m==1)
{
    for(;px1<=px2;px1++)
    {
        putpixel(px1,py1, WHITE);
        py1++;
    }
}
else
    {
        if(m<1)
        {
            for(;px1<=px2;)
            {
                putpixel(px1, py1, GREEN);
                px1++;
                py1=m*px1+b;
            }
        }
else
    {
        for(;py1<=py2;)
        {
            putpixel(px1, py1, RED);
            py1++;
            px1=(py1-b)/m;
        }
    }

}

getch();
}

Monday, 21 March 2016

How to use codeblocks IDE for Graphics

Please watch the video and do as instructed in it
Click here to watch Video

Assiginment

Assignment No 1 and 2
1 is not graded

Assignment no1: 
Title:Submit a report in detail of the following topics:
  1. History of Computer Graphics
  2. Video Display Devices:
  •  Refresh Cathode-Ray Tubes
  • Raster-Scan Displays
  • Random-Scan Displays
  • Color CRT Monitors
  • Direct-View Storage Tubes
  • Flat-Panel Displays
  • Three-Dimensional Viewing Devices
Due date: 31/2/2016
Copy paste is poison for your knowledge-base, avoid it.

Assignment no 2:
Titile: Fill the entire screen using putpixel function with green color and calculate the maximum rows and columns. 
Marks: 5
Due date: 22/3/2016
 
Video Display Devices