Tuesday, September 29, 2020
Monday, September 28, 2020
Wednesday, September 23, 2020
Thursday, March 12, 2020
Computer Shape Drawing with C Programming
Computer Shape Drawing with C Programming
In Following program Computer System Shape is drawn with the help of inbuilt functions available in graphics.h header file from C- language.
Program:
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm,i;
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
for(i=0;i<50;i++)
{
delay(100);
//monitor Drawing
rectangle(100,100,400,300);
setcolor(5);
rectangle(95,95,405,305);
moveto(150,150);
rectangle(230,305,260,400);
floodfill(232,307,5);
rectangle(180,400,310,450);
floodfill(183,403,5);
rectangle(182,402,308,448);
//CPU Drawing
setcolor(8);
rectangle(500,100,600,450);
rectangle(505,105,595,445);
rectangle(520,120,540,200);
rectangle(550,120,570,200);
rectangle(510,210,580,400);
floodfill(506,106,8);
line(305,450,500,450);
//mouse drawing
setcolor(6);
ellipse(400,400,0,360,15,25);
line(385,390,415,390);
line(395,390,395,375);
line(405,390,405,375);
floodfill(400,400,6);
setcolor(60-i);
outtext("WELCOME TO PROGRAMMING");
moveto(520,250);
outtext("MYG");
}
getch();
}
Output:
Tuesday, March 3, 2020
2D Transformations in Computer Graphics
2D Transformations
Definition: 2D Transformation modifies
the coordinates of object to change the orientation, size or shape of the
object.
In 2D (2- Dimensional) transformation
we are using two axes i.e. X- axis and
Y-axis to represent object. Any point on 2D plane is represented as A (x1, y1)
where x1 is distance from origin on X-axis and y1 is distance from origin.as
shown in figure below.
Different 2D Transformations:
a. Translation: Changing
position of object from one place to other.
b. Rotation: Angular displacement of object with
some angle (ϴ)
c. Scaling:
Increasing or
decreasing size of object.
d. Reflection: Mirror image of the object.
e. Shear:
Deformation/Slanting
in the shape of the object.
2D transformations can be broadly divided into Active and Passive type of Transformations.Those transformations are called active in which shape of object changed. In passive transformation shape of object will remain unchanged after operation.
Scaling and Shear are active 2D transformations while Translation, Rotation and Reflection are passive 2D transformations.
Subscribe to:
Posts (Atom)

