This document contains code for drawing various shapes and lines in C++ using graphics functions. It includes classes for a pixel, line, and circle. The line class contains methods for drawing a line using DDA and Bresenham's algorithms. Additional methods allow drawing thick lines and dotted lines. The circle class inherits from line and contains a method for drawing a circle by putting pixels on the circumference. The document provides code examples and outputs for each task.
This presentation contains information about touch panels i.e. how the touch screen works ,different technologies through which touch screens are made with its pros and cons.
Virtual reality-What you see is what you believe kaishik gundu
The recent and the most famous technology cruising in the world and has got good applications in the modern world.This is a small Slide Show on the topic
This presentation contains information about touch panels i.e. how the touch screen works ,different technologies through which touch screens are made with its pros and cons.
Virtual reality-What you see is what you believe kaishik gundu
The recent and the most famous technology cruising in the world and has got good applications in the modern world.This is a small Slide Show on the topic
Computer Graphics and Multimedia lab reportBijoy679
According to NU of Bangladesh for BSC Hons in CSE 6th semester, here you can find the solution about this subject according to the board question respectively.
Lecture 5 in the COMP 4010 course on Augmented and Virtual Reality. This lecture talks about spatial audio and tracking systems. Delivered by Bruce Thomas and Mark Billinghurst on August 23rd 2016 at University of South Australia.
Lecture 3 from the COMP 4010 course and Virtual and Augmented Reality. This lecture is about VR tracking, input and systems. Taught on August 7th, 2018 by Mark Billinghurst at the University of South Australia
COMP lecture 4 given by Bruce Thomas on August 16th 2017 at the University of South Australia about 3D User Interfaces for VR. Slides prepared by Mark Billinghurst.
Lecture 9 of the COMP 4010 course in AR/VR from the University of South Australia. This was taught by Mark Billinghurst on October 5th, 2021. This lecture describes VR input devices, VR systems and rapid prototyping tools.
Computer graphics lab report with code in cppAlamgir Hossain
This is the lab report for computer graphics in cpp language. Basically this course is only for the computer science and engineering students.
Problem list:
1.Program for the generation of Bresenham Line Drawing.
2. Program for the generation of Digital Differential Analyzer (DDA) Line Drawing.
3. Program for the generation of Midpoint Circle Drawing.
4. Program for the generation of Midpoint Ellipse Drawing.
5. Program for the generation of Translating an object.
6. Program for the generation of Rotating an Object.
7. Program for the generation of scaling an object.
All programs are coaded in cpp language .
hey friends
this computer graphics practicals was the time of my educational time , I am sharing with you.
i am software developer for more query contect on my e-mail id abhi.smarta02@gmail.com
Computer Graphics and Multimedia lab reportBijoy679
According to NU of Bangladesh for BSC Hons in CSE 6th semester, here you can find the solution about this subject according to the board question respectively.
Lecture 5 in the COMP 4010 course on Augmented and Virtual Reality. This lecture talks about spatial audio and tracking systems. Delivered by Bruce Thomas and Mark Billinghurst on August 23rd 2016 at University of South Australia.
Lecture 3 from the COMP 4010 course and Virtual and Augmented Reality. This lecture is about VR tracking, input and systems. Taught on August 7th, 2018 by Mark Billinghurst at the University of South Australia
COMP lecture 4 given by Bruce Thomas on August 16th 2017 at the University of South Australia about 3D User Interfaces for VR. Slides prepared by Mark Billinghurst.
Lecture 9 of the COMP 4010 course in AR/VR from the University of South Australia. This was taught by Mark Billinghurst on October 5th, 2021. This lecture describes VR input devices, VR systems and rapid prototyping tools.
Computer graphics lab report with code in cppAlamgir Hossain
This is the lab report for computer graphics in cpp language. Basically this course is only for the computer science and engineering students.
Problem list:
1.Program for the generation of Bresenham Line Drawing.
2. Program for the generation of Digital Differential Analyzer (DDA) Line Drawing.
3. Program for the generation of Midpoint Circle Drawing.
4. Program for the generation of Midpoint Ellipse Drawing.
5. Program for the generation of Translating an object.
6. Program for the generation of Rotating an Object.
7. Program for the generation of scaling an object.
All programs are coaded in cpp language .
hey friends
this computer graphics practicals was the time of my educational time , I am sharing with you.
i am software developer for more query contect on my e-mail id abhi.smarta02@gmail.com
hey friends,
This is all about on Oracle, finest way to learning Oracle SQL so use this tutorial . for more query contact my e-mail id abhi.smarta02@gmail.com
Unix and Shell Programming,
Q P Code: 60305.
Additional Mathematics I
Q P Code: 60306
Computer Organization and Architecture
Q P Code: 62303
Data Structures Using C
Q P Code: 60303
Discrete Mathematical Structures
Q P Code: 60304
Engineering Mathematics - III
Q P Code: 60301
Soft Skill Development
Q P Code: 60307
It is an attempt to make the students of IT understand the basics of programming in C in a simple and easy way. Send your feedback for rectification/further development.
Ex.1 Write a program to print the following pattern
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Ex.2 Write a program to find bigger of three integers.
Ex.3 Write a program to calculate GCD between two numbers.
Ex.4 Write a program to find transpose of matrix.
Ex.5 Write a program which deletes an element from an array & display all other elements.
Ex.6 Write a program to calculate XA+YB where A & B are matrix & X=2, Y=3.
Ex.7 Write a program to calculate the total amount of money in the piggy bank, given that coins of Rs.10, Rs.5, Rs.2, RS.1.
& many more.....
JCConf 2020 - New Java Features Released in 2020Joseph Kuo
In 2020, Java 14 and 15 are released with many great features, including ZGC, Shenandoah GC, helpful NullPointerExceptions, pattern matching for instanceof, switch expressions, text blocks, records, hidden classes, and sealed classes. They not only improve performance of GC and Java applications, but also introduce new syntax to ease our effort to write more readable and efficient code. Let's take a look at those features!
https://cyberjos.blog/java/seminar/jcconf-2020-new-java-features-released-in-2020/
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
About
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Technical Specifications
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
Key Features
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface
• Compatible with MAFI CCR system
• Copatiable with IDM8000 CCR
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
Application
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SE Computer, Programming Laboratory(210251) University of Pune
1. Programming Laboratory (210251)
Index
Batch: C1 & C2
Title Date Sign
Group A
1.
Writing a C++ Program to emulate CPU Architecture (Central
Bus) Develop register, ALU level GUI to display results.
2. Writing a C++ class for displaying pixel or point on the screen.
3.
Write a C++ class for a Line drawing method using overloading
DDA and Bresenham’s Algorithms, inheriting the pixel or point.
4. Write a C++ class for a circle drawing inheriting line class.
Group B
1.
Write a program in C++ to draw a line with line style (Thick,
Thin, Dotted).
2. Write a program in C++ to draw a circle of desired radius.
3.
Write a C++ program to draw convex polygons (Square,
Rectangle, Triangle).
4.
Write a program in C++ to test that given point is inside the
polygon.
5. Write a C++ program to fill polygon using scan line algorithm.
6.
Write a Java program to draw a line with line style (Thick, Thin,
Dotted).
Group C
1. Use Maya to draw a Bouncing ball animation.
2. Programming Laboratory (210251)
Title: Writing a C++ Program to emulate CPU Architecture (Central Bus) Develop register,
ALU level GUI to display results.
Aim: To understand the working of CPU architecture, perform some arithmetic operation using
ALU and display results.
C++ code:
#include<string.h>
#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
#include<stdlib.h>
#include<math.h>
#include<ctype.h>
#include<stdio.h>
class computer
{
int c1;
int j;
char n1[5],n2[5];
char *d1;
int a1,b1;
char a[5];
int poly[20];
public:
computer()
{ j=0;
}
void biu();
void alu();
void flags();
void registers();
void segments();
void buses();
void exp1();
void display();
};
void computer::biu()
{
rectangle(300,20,600,470); //CPU
poly[]={340,35,335,100,355,100,360,70,395,100,415,100,410,35,340,35};//draw CPU polygon
setfillstyle(1,RED);
char ope[2];
2
3. Programming Laboratory (210251)
ope[0]=a[2];
ope[1]='0';
outtextxy(340,45,"Operation");
outtextxy(370,60,ope);
}
void computer::segments()
{
rectangle(320,130,420,230); //segments
for(int k=1;k<5;k++)
{ int a=320;
int b=130+20*k;
int c= 420;
int d=130+20*k;
line(a,b,c,d);
}
outtextxy(330,133,"ES=0000h");
outtextxy(330,153,"DS=0000h");
outtextxy(330,173,"CS:0000h");
outtextxy(330,193,"IP:0001h");
outtextxy(330,213,"DI:ALU");
rectangle(480,28,560,50); //memory interface
outtextxy(494,38,"Memory ");
rectangle(480,80,540,180); // instn queue
for(k=1;k<5;k++)
{ int a=480;
int b=80+20*k;
int c= 540;
int d=80+20*k;
line(a,b,c,d);
}
outtextxy(510,167,"1");
outtextxy(546,100,"Instruction");
outtextxy(546,115,"Queue");
rectangle(470,220,550,240); //control sys
outtextxy(480,222,"Program Counter");
}
void computer::registers()
{
rectangle(320,310,420,450); //registers
for(int k=1;k<8;k++)
{ int a=320;
int b=310+20*k;
int c= 420;
int d=310+20*k;
line(a,b,c,d);
3
8. Programming Laboratory (210251)
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:tcbgi");
computer c;
c.exp1();
delay(500);
c.biu();
delay(500);
c.segments();
delay(500);
c.registers();
delay(500);
c.display();
delay(500);
c.alu();
delay(500);
c.flags();
delay(500);
c.buses();
getch();
}
Graphics function used:
1. outtextxy
2. line
3. rectangle
4. drawpoly
5. fillpoly
6. setfillstyle
7. floodfill
Output:
Title: Writing a C++ class for displaying pixel or point on the screen.
8
9. Programming Laboratory (210251)
Aim: To understand, how to display pixel on screen.
C++ Code:
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
class pixel
{
public:
int x,y;
void disp(int,int);
};
void pixel::disp(int p,int q)
{
putpixel(p,q,WHITE);
}
void main()
{
class pixel p;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:tcplusbgi");
cout<<"Enter position of pixel";
cin>>p.x>>p.y;
p.disp(p.x,p.y);
getch();
}
Output:
9
10. Programming Laboratory (210251)
Title: Write a C++ class for a Line drawing method using overloading DDA and Bresenham’s
Algorithms, inheriting the pixel or point.
DDA Line Drawing Algorithm:
Bresenham’s Line Drawing Algorithm:
10
11. Programming Laboratory (210251)
C++ Code for DDA Line Drawing Algorithm:
#include<iostream.h>
#include<math.h>
#include<conio.h>
#include<graphics.h>
class line
{
public:
int x1,y1,x2,y2;
void drawl(int,int,int,int);
};
void line::drawl(int x1,int y1,int x2,int y2)
{
int i=1,dx,dy,step,x,y;
float xinc,yinc;
dx=abs(x2-x1);
dy=abs(y2-y1);
if(dx<=dy)
{
step=dy;
}
else
{step=dx;}
xinc=dx/step;
yinc=dy/step;
x=x1;y=y1;
putpixel(x,y,WHITE);
while(i<=step)
{
x=x+xinc+0.5;
y=y+yinc+0.5;i++;
putpixel(x,y,WHITE);
}
}
void main()
{
class line l;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:tcbgi");
cout<<"Enter coordinates of end points";
cin>>l.x1>>l.y1>>l.x2>>l.y2;
l.drawl(l.x1,l.y1,l.x2,l.y2);
getch();
}
11
12. Programming Laboratory (210251)
Output:
C++ Code for Bresenham’s Line Drawing Algorithm:
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
class line
{
public:
int x1,y1,x2,y2;
void drawl(int,int,int,int);
};
void line::drawl(int x1,int y1,int x2,int y2)
{
int dx=x2-x1,dy=y2-y1,di=2*dx-dy,ds=2*dy,dt=2*(dy-dx);
putpixel(x1,y1,WHITE);
while(x1<=x2)
{
x1++;
if(di<0)
{di+=ds;}
else
{
y1++;
di+=dt;
}
putpixel(x1,y1,WHITE);
}
}
void main()
{
class line l;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:tcbgi");
cout<<"Enter coordinates of end points x1,y1,x2,y2";
cin>>l.x1>>l.y1>>l.x2>>l.y2;
l.drawl(l.x1,l.y1,l.x2,l.y2);
getch();
}
Output:
12
13. Programming Laboratory (210251)
Title: Write a C++ class for a circle drawing inheriting line class.
C++ Code:
#include<conio.h>
#include<iostream.h>
#include<graphics.h>
class linep //line class
{
public:
int x1,y1,x2,y2;
};
class circle:public linep //circle class inherit from linep class
{
public:
void disp(int,int,int);
};
void circle::disp(int x,int y,int r)
{
int p,x1,y1;
x1=0;
y1=r;
p=3-r;
while(x1<=y1)
{
if(p<0)
{
x1++;
p+=4*x1+6;
}
else
{
x1++;y1--;
p+=4*(x1-y1)+10;
}
putpixel(x1+x,y1+y,1);
putpixel(x1+x,y-y1,1);
putpixel(x-x1,y1+y,1);
putpixel(x-x1,y-y1,1);
putpixel(x+y1,y+x1,1);
putpixel(x+y1,y-x1,1);
putpixel(x-y1,y+x1,1);
putpixel(x-y1,y-x1,1);
}
13
14. Programming Laboratory (210251)
}
void main()
{
class circle c;
class linep p;
int gd=DETECT,gm,r;
initgraph(&gd,&gm,"C:tcbgi");
cout<<"Enter radius of circle";
cin>>r;
cout<<"Enter co-ordinates of circle";
cin>>p.x2>>p.y2;
c.disp(p.x2,p.y2,r);
getch();
}
Output:
14
15. Programming Laboratory (210251)
Title: Write a program in C++ to draw a line with line style (Thick, Thin, Dotted).
C++ code:
#include<conio.h>
#include<iostream.h>
#include<graphics.h>
class linep
{
public:
int x1,y1,x2,y2;
void drawl(int,int,int,int);
void thick(int,int,int,int,int);
void dotted(int,int,int,int);
};
void linep::thick(int x1,int y1,int x2,int y2,int w)
{
int i,dx,dy,step,xinc,yinc;
dx=x2-x1;
dy=y2-y1;
if(dy>=dx)
{
step=dy;
}
else
{
step=dx;
}
xinc=dx/step;
yinc=dy/step;
while(x1<=x2)
{
x1=x1+xinc+0.5;
y1=y1+yinc+0.5;
for(i=0;i<w;i++)
{
putpixel(x1+i,y1,WHITE);
}
}
}
void linep::drawl(int x1,int y1,int x2,int y2)
{
int dx,dy,step,xinc,yinc;
dx=x2-x1;
dy=y2-y1;
if(dy>=dx)
15
17. Programming Laboratory (210251)
{
class linep p;
int gd=DETECT,gm,n,i,w;
initgraph(&gd,&gm,"C:TCbgi");
cout<<"Enter co-ordinates of line x1,y1,x2,y2";
cin>>p.x1>>p.y1>>p.x2>>p.y2;
cout<<"Enter your choice 1. Thin Line 2. Thick line 3. Dotted line";
cin>>i;
switch(i)
{
case 1: p.drawl(p.x1,p.y1,p.x2,p.y2); break;
case 2:
cout<<"Enter width of line in pixel";
cin>>w;
p.thick(p.x1,p.y1,p.x2,p.y2,w); break;
case 3: p.dotted(p.x1,p.y1,p.x2,p.y2); break;
default:
cout<<"Enter proper choice";
}
getch();
}
Output:
17
18. Programming Laboratory (210251)
Title: Write a program in C++ to draw a circle of desired radius.
C++ Code:
#include<conio.h>
#include<iostream.h>
#include<graphics.h>
void display(int,int,int,int);
void main()
{
int p,gd=DETECT,gm,x1,y1,x,y,r;
initgraph(&gd,&gm,"c :tcbgi");
cout<<"Enter radius of circle";
cin>>r;
cout<<"Enter co-ordinates of circle";
cin>>x>>y;
x1=0;
y1=r;
p=3-r;
while(x1<=y1)
{
if(p<0)
{
x1++;
p+=4*x1+6;
}
else
{
x1++;y1--;
p+=4*(x1-y1)+10;
}
display(x1,y1,x,y);
}
getch();
}
void display(int x1,int y1,int x,int y)
{
putpixel(x1+x,y1+y,1);
putpixel(x1+x,y-y1,1);
putpixel(x-x1,y1+y,1);
putpixel(x-x1,y-y1,1);
putpixel(x+y1,y+x1,1);
putpixel(x+y1,y-x1,1);
putpixel(x-y1,y+x1,1);
putpixel(x-y1,y-x1,1);
18
22. Programming Laboratory (210251)
break;
case 3:
int x3,y3;
cout<<"Enter base and height of triangle ";
cin>>base>>height;
x2=x1+base;
y2=y1;
l.drawl(x1,y1,x2,y2);
x3=x1;
y3=y1+height;
l.drawl(x1,y1,x3,y3);
l.drawl(x2,y2,x3,y3);
break;
default: cout<<"Enter correct choice";
}
getch();
}
Output:
22
23. Programming Laboratory (210251)
Title: Write a program in C++ to test that given point is inside the polygon (Rectangle).
C++ Code:
#include<iostream.h>
#include<math.h>
#include<conio.h>
#include<graphics.h>
class line
{
public:
int x1,y1,x2,y2;
void drawl(int,int,int,int);
};
void line::drawl(int x1,int y1,int x2,int y2)
{
int i=1,dx,dy,step,x,y;
float xinc,yinc;
dx=abs(x2-x1);
dy=abs(y2-y1);
if(dx<=dy)
{
step=dy;
}
else
{step=dx;}
xinc=dx/step;
yinc=dy/step;
x=x1;y=y1;
putpixel(x,y,WHITE);
while(i<=step)
{
x=x+xinc+0.5;
y=y+yinc+0.5;
i++;
putpixel(x,y,WHITE);
}
}
void main()
{
class line l;
int i,x1=100,y1=100,x2,y2,gd=DETECT,gm,len=50,wid=34,x,y;
initgraph(&gd,&gm,"c:tcbgi");
x2=x1+wid;
y2=y1;
23
25. Programming Laboratory (210251)
Title: Write a C++ program to fill polygon using scan line algorithm.
C++ Code:
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
struct edge
{
int x1,y1,x2,y2,flag;
};
void main()
{
int n,i,j,k,gd=DETECT,gm, x[10],y[10],ymax=0,ymin=480,yy,temp;
struct edge ed[10],temped;
float dx,dy,m[10],x_int[10],inter_x[10];
initgraph(&gd,&gm,"c:tcbgi");
cout<<"n Enter the number of vertices of the graph: ";
cin>>n;
cout<<"n Enter the co-ordinates of vertices: n";
for(i=0;i<n;i++)
{
cout<<"x"<<i;
cin>>x[i]>>endl;
cout<<"y"<<i;
cin>>y[i]>>endl;
if(y[i]>ymax)
ymax=y[i];
if(y[i]<ymin)
ymin=y[i];
ed[i].x1=x[i];
ed[i].y1=y[i];
}
for(i=0;i<n-1;i++) //store the edge information
{
ed[i].x2=ed[i+1].x1;
ed[i].y2=ed[i+1].y1;
ed[i].flag=0;
}
ed[i].x2=ed[0].x1;
ed[i].y2=ed[0].y1;
ed[i].flag=0;
for(i=0;i<n-1;i++) //check for y1>y2 if not then interchange it
{
25
28. Programming Laboratory (210251)
j++;
}
}
}
for(i=0;i<j;i++) //sorting the x intersections
{
for(k=0;k<j-1;k++)
{
if(x_int[k]>x_int[k+1])
{
temp=x_int[k];
x_int[k]=x_int[k+1];
x_int[k+1]=temp;
}
}
}
for(i=0;i<j;i+=2) //Extracting x values to draw a line
{
line(x_int[i],yy,x_int[i+1],yy);
}
yy--;
}
delay(3000);
getch();
}
Output:
28
29. Programming Laboratory (210251)
Title: Write a Java program to draw a line with line style (Thick, Thin, Dotted).
JAVA Code:
import java.awt.*;
import javax.swing.*;
public class drawline extends JFrame{
public drawline(){
super("Lines");
setSize(400,400);
setVisible(true);
}
Stroke[] linestyles=new Stroke[]{
new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL),
new BasicStroke(25.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER),
new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND),};
Stroke thindashed=new
BasicStroke(2.0f,BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL,1.0f, new float[]
{8.0f,3.0f,2.0f,3.0f},0.0f);
final static float dash1[]={10.0f};
final static BasicStroke dashed =new BasicStroke(1.0f,
BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
final static float thick1[]={10.0f};
final static BasicStroke thickdash =new BasicStroke(10.0f,
BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER, 10.0f, thick1, 0.0f);
public void paint(Graphics g){
int xpoints[]={220,350,350,220};
int ypoints[]={220,220,320,320};
int npoints=4;
int xpoints1[]={60,120,180};
int ypoints1[]={320,220,320};
int npoints1=3;
Graphics2D g2d = (Graphics2D) g;
super.paint(g);
((Graphics2D)g).setStroke(dashed);
g.setColor(Color.black);
g2d.drawLine(50,50,200,50);
g2d.setColor(Color.black);
g.drawString("Dotted Line", 210,55);
((Graphics2D)g).setStroke(linestyles[3]);
g.setColor(Color.red);
g2d.drawLine(50,170,200,170);
g2d.setColor(Color.black);
g.drawString("Thin Line", 210,175);
29
30. Programming Laboratory (210251)
}
public static void main(String[] args){
Lines application = new Lines();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Steps for running this program:
1. Compilation of Program
C:Program FilesJavajdk1.7bin>javac drawline.java
2. Run the Program
C:Program FilesJavajdk1.7bin>java drawline
Output:
30
31. Programming Laboratory (210251)
Title: Use Maya to draw a Bouncing ball animation.
Introduction:
Maya 3D animation, modeling, simulation, rendering and compositing software offers a
comprehensive creative feature set for 3D computer animation, modeling, simulation and
rendering on a highly extensible production platform. Maya provides high-end character
and effects toolsets along with increased productivity for modeling, texturing and shade
creation tasks.
31
32. Programming Laboratory (210251)
C graphics using graphics.h functions or WinBGIM (Windows 7) can be used to draw different
shapes, display text in different fonts, change colors and many more. Using functions of
graphics.h in turbo C compiler you can make graphics programs, animations, projects and
games.
In a C/C++ Program first of all, we have to initialize the graphics drivers on the computer. This
is done using the initgraph method provided in graphics.h library.
Graphics mode Initialization:
First of all we have to call the initgraph function that will intialize the graphics mode on the
computer.
Prototype of initigraph:
void initgraph(int far *graphdriver, int far *graphmode, char far *pathtodriver);
Initgraph initializes the graphics system by loading a graphics driver from disk (or validating a
registered driver) then putting the system into graphics mode. Initgraph also resets all graphics
settings (color, palette, current position, viewport, etc.) to their defaults, then resets graph result
to 0.
*graphdriver
Integer that specifies the graphics driver to be used. You can give graphdriver a value using a
constant of the graphics_drivers enumeration type.
*graphmode
Integer that specifies the initial graphics mode (unless *graphdriver = DETECT). If *graphdriver
= DETECT, initgraph sets *graphmode to the highest resolution available for the detected driver.
You can give *graphmode a value using a constant of the graphics_modes enumeration type.
*pathtodriver
Specifies the directory path where initgraph looks for graphics drivers (*.BGI) first.
1. If they’re not there, initgraph looks in the current directory.
2. If pathtodriver is null, the driver files must be in the current
directory.
*graphdriver and *graphmode must be set to valid graphics_drivers and graphics_mode values or
you’ll get unpredictable results. (The exception is graphdriver = DETECT.)
After a call to initgraph, *graphdriver is set to the current graphics driver, and *graphmode is set
to the current graphics mode. You can tell initgraph to use a particular graphics driver and mode,
32
33. Programming Laboratory (210251)
or to autodetect the attached video adapter at run time and pick the corresponding driver. If you
tell initgraph to autodetect, it calls detectgraph to select a graphics driver and mode.
Generally, initgraph loads a graphics driver by allocating memory for the driver (through
_graphgetmem), then loading the appropriate .BGI file from disk. As an alternative to this
dynamic loading scheme, you can link a graphics driver file directly into your executable
program file.
List of few functions from graphics.h file:
Name of Function
Circle Drawing circle
Arc Drawing arc
Screen getbkcolor, getcolor, setbkcolor, setcolor
Pixel getpixel, getx, gety, putpixel
Rectangle rectangle
Polygon drawpoly, fillpoly, floodfill
Line line, linerel, lineto
Text print outtextxy
getpixel(int x, int y);
putpixel(int x,int y, int color);
setbkcolor(BLUE);
getbkcolor(void);
setcolor(int color);
getcolor(void);
outtextxy function display text or string at a specified point(x,y) on the screen.
void outtextxy(int x, int y, char *string);
x, y are coordinates of the point and third argument contains the address of string to be
displayed.
line(int x1, int y1, int x2, int y2)
linerel(int dx,int dy): draw a line relative distance.
lineto(int x,int y): draw a line original point to x,y point.
rectangle(left,top,right,bottom)
circle(int x, int y, int radius)
33
34. Programming Laboratory (210251)
arc(int x,int y, int stangle, int endangle, int radius)
drawpoly(int numpoints, int far *polypoints);
setfillstyle(int pattern, int color);
EMPTY_FILL: 0, SOLID_FILL: 1
fillpoly(int numpoints, int far *polypoints);
fillpoly draws outline of polygon using current line style and color.
floodfill(int x,int y int border);
floodfill function is used to fill an enclosed area. Current fill pattern and fill color is used to fill
the area.(x, y) is any point on the screen if (x,y) lies inside the area then inside will be filled
otherwise outside will be filled, border specifies the color of boundary of area. To change fill
pattern and fill color use setfillstyle. Code given below draws a circle and then fills it.
Computer Graphics:
Computer graphics remains one of the most existing and rapidly growing computer fields.
Computer graphics may be defined as a pictorial representation or graphical representation of
objects in a computer.
Applications of computer graphics:
There are many interesting applications of computer graphics. Three common applications are
graphic user interface (GUI), computer-aided design (CAD), and computer games.
Major components (hardware and software) are needed for computer graphics:
Besides the basic computer, some special devices and software may be required especially for
computer graphics. For hardware, a special high-resolution, color monitor is often demanded and
some input tools, e.g. mouse and joy-sticker, and hard-copy devices, e.g. high-resolution color
printer, may be required. For software, some special purpose utilities (device-dependent and
device-independent) are needed for handling processing in computer graphics.
Random/Raster Scan:
Random scan is a method in which the display is made by the electronic beam, which is
directed, only to the points or part of the screen where the picture is to be drawn.
The Raster scan system is a scanning technique in which the electrons sweep from top to
bottom and from left to right. The intensity is turned on or off to light and unlight the pixel.
Refreshing of the screen:
Refreshing of screen is done by keeping the phosphorus glowing to redraw the picture
repeatedly. i.e. by quickly directing the electronic beam back to the same points.
34
35. Programming Laboratory (210251)
Aspect Ratio:
The ratio of vertical points to the horizontal points necessary to produce length of lines in both
directions of the screen is called Aspect Ratio. Usually the aspect ratio is ¾.
Addressability:
Addressability is the number of individual dots per inch (d.p.i.) that can be created. If the address
of the current dot is (x, y) then the next dot will be (x + y), (x + y + 1) etc.
Dot size:
The diameter of a single dot on the devices output.
Interdot distance:
Interdot distance is the reciprocal of addressability. If the addressability is large, the interdot
distance will be less. The interdot distance should be less to get smooth shapes.
C++:
Purpose of C++ programming was to add object orientation to the C programming language,
which is in itself one of the most powerful programming languages.
The core of the pure object-oriented programming is to create an object, in code, that has certain
properties and methods. While designing C++ modules, we try to see whole world in the form of
objects.
There are a few principle concepts that form the foundation of object-oriented
programming:
1. Object:
This is the basic unit of object oriented programming. That is both data and function that
operate on data are bundled as a unit called as object.
2. Class:
We define a blueprint for an object. This doesn't actually define any data, but it does
define what the class name means, that is, what an object of the class will consist of and
what operations can be performed on such an object.
There are three types of data members:
• Public
• Private
• Protected
Syntax:
class classname{
private: //by default data members are private
public:
protected:
}; // end of the Class
35
36. Programming Laboratory (210251)
3. Inheritance:
One of the most useful aspects of object-oriented programming is code reusability. As the
name suggests Inheritance is the process of forming a new class from an existing class
that is from the existing class called as base class, new class is formed called as derived
class. This is a very important concept of object-oriented programming since this feature
helps to reduce the code size.
When creating a class, instead of writing completely new data members and member
functions, the programmer can designate that the new class should inherit the members of
an existing class. This existing class is called the base class, and the new class is referred
to as the derived class.
A class can be derived from more than one classes, which means it can inherit data and
functions from multiple base classes. To define a derived class, we use a class derivation
list to specify the base class(es). A class derivation list names one or more base classes
and has the form:
class derived-class: access-specifier base-class
Where access-specifier is one of public, protected, or private, and base-class is the
name of a previously defined class. If the access-specifier is not used, then it is private by
default.
class shape // shape is base class
{
public:
int length, width;
};
class rectangle:public shape // rectangle is derived class
{
public:
int get area()
{ int a;
a=length*width;
return a;
}
};
4. Abstraction:
Data abstraction refers to, providing only essential information to the outside world and
hiding their background details, i.e., to represent the needed information in program
without presenting the details. For example, a database system hides certain details of
how data is stored and created and maintained. Similar way, C++ classes provides
36
37. Programming Laboratory (210251)
different methods to the outside world without giving internal detail about those methods
and data.
5. Encapsulation:
Encapsulation is placing the data and the functions that work on that data in the same
place. While working with procedural languages, it is not always clear which functions
work on which variables but object-oriented programming provides you framework to
place the data and the relevant functions together in the same object.
6. Overloading:
The concept of overloading is also a branch of polymorphism. When the exiting operator
or function is made to operate on new data type, it is said to be overloaded.
When we call overloaded function or operator, the compiler determines the most
appropriate definition to use by comparing the argument types you used to call the
function or operator with the parameter types specified in the definitions. The process of
selecting the most appropriate overloaded function or operator is called overload
resolution
class dispdata{
public:
void disp(int i) {cout<<i;}
void disp(float f) {cout<<f;}
void disp(double b){cout<<b;}
};
void main()
{
int a=5;
float b=2.6;
double c=1.98654;
cout<<a<<endl<<b<<endl<<c;
getch();
}
7. Polymorphism:
The ability to use an operator or function in different ways in other words giving different
meaning or functions to the operators or functions is called polymorphism. Poly refers
too many. That is a single function or an operator functioning in many ways different
upon the usage is called polymorphism.
TIFF:
TIFF is a computer file format for storing raster graphics images, popular among graphic artists,
the publishing industry. The TIFF format is widely supported by image-manipulation
applications, by publishing and page layout applications, and by scanning, faxing, word
37
38. Programming Laboratory (210251)
processing, optical character recognition and other applications. Adobe Systems, which acquired
Aldus, now holds the copyright to the TIFF specification.
GTK+:
GTK+ (previously GIMP Toolkit, sometimes incorrectly referred to as the GNOME Toolkit) is
a cross-platform widget toolkit for creating graphical user interfaces. It is licensed under the
terms of the GNU LGPL, allowing both free and proprietary software to use it. It is one of the
most popular toolkits for the Wayland and X11 windowing systems, along with Qt.
The name GTK+ originates from GTK; the plus was added to distinguish an enhanced version. It
was originally created for the GNU Image Manipulation Program (GIMP), a free software raster
graphics editor.
38