Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Need inspiration

Rating
-
Sold
-
Pages
47
Uploaded on
21-05-2025
Written in
2024/2025

easy coding to understand easily.

Institution
Course

Content preview

<br>




Ex. No.:1

LINE DRAWING USING DDA ALGORITHM
import java.awt.*:
import java.awt.cvent.*:
import java.applet.*;
P <Applet code=dda height=5000 width-5000> </Applct> */
public class dda extends Applet implemcnts ActionListencr

Label l1,12,13.14;
TextFicld t1.(2.t3,t4;
int x.y.xl.yl.x2.y2,dx,dy, xincr,yincr,steps;
Button b:
public void init()
{

||=new Labcl("Enter the value of x1:");
tl=new TextField(4):
12=new Label("Enter the value of yl:"):
t2-new TextField(4):
13=new Label("Enter the value of x2:");
t3=new TextField(4);
14=new Label("Enter the value of y2:");
t4=new TextField(4);
b=new Button("line");
add(|l);add(t1);
add(12);add(12);
add(13 );add(t3);
add(14);add(t4);
add(b):
b.addActionListener(this);

actionPerformed(ActionEvent ae)
public void

x1=Integer.parselnt(t1.getText());
yl=Integer.parselnt((2.getTexI();
x2=Integer.parselnt(t3.getText());
y2=Integer.parselnt(t4.getText(0):
repaint();

public void paint(Graphics g)

dx=x2-x1;
dy=y2-yl;
if(dx>dy)
steps-dx;
else
steps=dy:
xincr=dx/steps;
yincr=dy/steps;

,<br>




N=X1;
y-yl;
g.fillOval(x,y, 1,1);
g.drawString(x+ "," +y,x,y);
for(int k=1;k<steps;k++)

X=X+Xncr;
y=ytyincr;
g.fillOval(x,y,1,1);

g.drawString(x+ +y,x,y);

,<br>




5


OUTPUT
Apeet
i
dda

Aeptel
Enter hevae of 00 Enter he vaue et 2
o




+03,200




299, 09




roletstattd




Arpit
vi
dda

300 Enter the value of y2 800
Artiel
Enter he value ct P00 Enter the value of yt 600 Enter the vsiue of
2




200600 9600




Acplet staned

, <br>




Enter hvaue of 2 300 Erter the vslue of y2 600 tne
Enter h vake of t 50




9599




300 Enter the value ot y1 400 Enter the value of x2 300 Enter the value of y2 600 kne




bog.599

Written for

Institution
Course

Document information

Uploaded on
May 21, 2025
Number of pages
47
Written in
2024/2025
Type
Class notes
Professor(s)
Bhuvana
Contains
All classes

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
abinaya7

Get to know the seller

Seller avatar
abinaya7 sri sarada matric high sec.school
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
11 months
Number of followers
0
Documents
4
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions