i sharing tech news and software info and website design development tips and trick, computer tips and many more

  • Breaking News

    Welcome to RazLove Blog, You Want to Earn Money Online Go https://fast2way.com/

    Thursday, 13 April 2017

                             Computer Graphis File

                                      Department Of Computer Engineering


    Practical -1

    AIM:- Write a Program in C++ to Draw a Line.

    #include<stdio.h>
    #include<graphics.h>
    #include<conio.h>

    void main()
    {
    int gd=DETECT,gm;
    intgraph(&gd, &gm,"c:\\TC\\BGI");
    line(100,100,200,200);
    getch();

    }


          Output:-
                                          







    Practical -2
    AIM:- Write a Program to intersect two Lines.
    #include<stdio.h>
    #include<graphics.h>
    #include<conio.h>
    void main()
    {
    int gd=DETECT,gm;
    initgraph(&gd, &gm,"C:\\TC\\BGI");
    setcolor(7);
    line(10,100,100,100);
    line(30,50,30,200);
    getch();
    }



           Output:-

                                 








    Practical -3

    AIM:- C++  Program To draw circle

    #include<stdio.h>
    #include<iostream.h>
    #include<conio.h>
    #include<dos.h>
    void main()
    {
    int gd=DETECT,GM;
    initgraph(&gd, &gm,"C:\\TC\\BGI");
    Circle(30,40,60,50);
    getch();
    }

               Output:-




                                       













    Practical -4
    Aim:- C++ Program to draw a Trangle

    #include<stdio.h>
    #include<conio.h>
    #include<graphics.h>
    #include<iostream.h>
    #include<dos.h>
    #inlude<math.h>
    void main()
    {
    clrscr();
    int gdrive=detect,gmode;
    initgraph(&gdrive,&gmode,"c:\\tc\\bgi");
    line(20,80,60,30);
    line(60,30,100,80);
    line(20,80,100,80);
    getch();
    }

                   Output:-


                                                



    Practical -5

    Aim:-  C++  Program to darow a rectangle

    #include<stdio.h>
    #include<conio.h>
    #include<graphics.h>
    #include<dos.h>
    void main()
    {
    int gd=DETECT,gm;
    initgraph(&gd,&gm,"C://TC//BGI");
    rectangle(150,50,300,150);

    getch();

    }

              Output:-
                                               






    Practical -06

    AIM-write a program to print line using DDA algorithm

    #include<stdio.h>
    #include<iostream.h>
    #include<conio.h>
    #include<graphics.h>
    #include<math.h>
    void main()
    {
    int gd=DETECT,gm;
    initgraph(&gd,&gm,"c:\\tc\\bgi");
    int x,y,dy,dx;
    int x1,y1,x2,y2,i,length;
    cout<<"enter cordinate of starting point";
    cin>>x1>>y1;
    cout<<"enter the cordinate of end point";
    cin>>x2>>y2;
    dx=abs(x2-x1);
    dy=abs(y2-y1);
    if(dx>=dy)
    length=dx;
    else
    length=dy;
    dx=dx/length;
    dy=dy/length;
    x=x1;
    y=y1;
    i=1
    while(i<=length)
    {
    putpixel(x,y,RED);
    x=x+dx;
    y=y+dy;
    i++;
    }
    getch();
    }
























    Practical -07
    Aim:-Write a program in C++ to implement  translatoin

    #include<stdio.h>
    #include<iostream.h>
    #include<conio.h>
    #include<graphics.h>
    #include<math.h>
    void main()
    {
    int gd=DETECT,gm,x1,x2,y1,y2,tx,ty;
    initgraph(&gd,&gm,"c:\\tc\\bgi");
    cout <<"enter the first coordinate of a line";
    cin>>x1>>y1;
    cout<<"enter the second coordinate of line " ;
    cin>>x2>>y2;
    line(x1,y1,x2,y2);
    cout<<"enter the translation vector";
    cin>>tx>>ty;
    setcolor(RED

    x1=x1+tx;
    y1=y1+ty;
    x2=x2+tx;
    y2=y2+ty;
    line(x1,y1,x2,y2);
    getch();
    }

    Output:-
                                   

    Practical -08

    Aim-write a program to perform scaling

    #include<stdio.h>
    #include<iostream.h>
    #include<conio.h>
    #include<graphics.h>
    #include<math.h>
    void main()
    {
    int gd=DETECT,gm;
    initgraph(&gd,&gm,"c:\\tc\\bgi");
    float x1,y1,x2,y2,sx,sy;
    cout <<"enter the first coordinate of a line";
    cin>>x1>>y1;
    cout<<"enter the second coordinate of line " ;
    cin>>x2>>y2;
    line(x1,y1,x2,y2);
    cout<<"enter the scaling vector";
    cin>>sx>>sy;
    setcolor(RED);
    x1=x1*sx;
    y1=y1*sy;
    x2=x2*sx;
    y2=y2*sy;
    line(x1,y1,x2,y2);
    getch();
    }


    Output:-
                 
                 
    Practical -09

    Aim- Write a Program to perform rotation

    #include<stdio.h>
    #include<iostream.h>
    #include<graphics.h>
    #include<conio.h>
    #include<math.h>
    void main()
    {
    int gd=DETECT,gm;
    initgraph(&gd,&gm,"c:\\tc\\bgi");
    int x1,y1,x2,y2,x,y,xn,yn;
    float r1,r2,r3,r4,th;
    cout<<"enter the end points";
    cin>>x1>>y1;
    cout<<"enter the second points";
    cin>>x2>>y2;




    line(x1,y1,x2,y2);
    cout<<"enter the angle";
    cin>>th;
    r1=cos((th*3.14)/180);
    r2=sin((th*3.14)/180);
    r3=-sin((th*3.14)/180);
    r4=cos((th*3.14)/180);
    xn=((x2*r1)-(y2*r2));
    yn=((x2*r3)-(y2*r4));
    line(x1,y1,xn,yn);
    getch();
    }


    No comments:

    Post a Comment

    Contact Form

    Name

    Email *

    Message *