Program for DDA Line Drawing Algorithm in C++
- Get link
- X
- Other Apps
//This code is tested in Code Blocks
#include <iostream>
#include <graphics.h>
using namespace std;
void dda(float,float,float,float);
int main()
{
float x1,y1,x2,y2;
cout<<"Enter the value of x1 and y1 : ";
cin>>x1>>y1;
cout<<"Enter the value of x2 and y2: ";
cin>>x2>>y2;
dda(x1,y1,x2,y2);
}
void dda(float x1,float y1,float x2,float y2)
{
float x,y,dx,dy,step;
int i,gd=DETECT,gm;
char path[] = "";
initgraph(&gd,&gm,path);
dx=x2-x1;
dy=y2-y1;
if(dx>=dy)
{
step=abs(dx);
}
else
{
step=abs(dy);
}
dx=dx/step;
dy=dy/step;
x=x1;
y=y1;
i=1;
while(i<=step)
{
putpixel(x,y,WHITE);
x=x+dx;
y=y+dy;
i=i+1;
}
getch();
closegraph();
}
OUTPUT:
#include <iostream>
#include <graphics.h>
using namespace std;
void dda(float,float,float,float);
int main()
{
float x1,y1,x2,y2;
cout<<"Enter the value of x1 and y1 : ";
cin>>x1>>y1;
cout<<"Enter the value of x2 and y2: ";
cin>>x2>>y2;
dda(x1,y1,x2,y2);
}
void dda(float x1,float y1,float x2,float y2)
{
float x,y,dx,dy,step;
int i,gd=DETECT,gm;
char path[] = "";
initgraph(&gd,&gm,path);
dx=x2-x1;
dy=y2-y1;
if(dx>=dy)
{
step=abs(dx);
}
else
{
step=abs(dy);
}
dx=dx/step;
dy=dy/step;
x=x1;
y=y1;
i=1;
while(i<=step)
{
putpixel(x,y,WHITE);
x=x+dx;
y=y+dy;
i=i+1;
}
getch();
closegraph();
}
OUTPUT:
- Get link
- X
- Other Apps
Comments
Popular posts from this blog
Download and install MATLAB R2017a in Ubuntu 18.04 | Linux Free | Cracked
Smile emoji using graphics in Java using Applet
import java.awt.*; import java.awt.event.*; import java.applet.*; public class Smile extends Applet { public void paint(Graphics g) { setBackground(Color.BLACK); g.setColor(Color.YELLOW); g.fillOval(30,50,100, 100); g.setColor(Color.BLACK); g.fillOval(55,75,10, 10); g.fillOval(95,75,10, 10); g.drawArc(60, 85, 40,40,-30,-120); } } /* <applet code="Smile.class" width="200" height="200"> </applet> */ OUTPUT:
Program to find the LCM & HCF of n numbers
class HcfLcm { public static void main(String[] args) { int n,x; System.out.println("Number of integers: "); n = Integer.parseInt(System.console().readLine()); if(n<1) { System.out.print("Invalid input!"); System.exit(0); } int[] arr = new int[n]; for(int i =0; i<n; i++) { System.out.print("Number "+(i+1)+":"); ...
Program For Dda Line Drawing Algorithm In C++ >>>>> Download Now
ReplyDelete>>>>> Download Full
Program For Dda Line Drawing Algorithm In C++ >>>>> Download LINK
>>>>> Download Now
Program For Dda Line Drawing Algorithm In C++ >>>>> Download Full
>>>>> Download LINK uy