Posts

Showing posts with the label Algorithm

dda line drawing algorithm in java

Read about DDA (Digital differential analyzer) algorithm . You can find line drawing using bresenham's line algorithm here . Java Code for DDA line drawing algorithm. :- package applet; import java.applet.Applet; import java.awt.Button; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; public class dda extends Applet implements MouseListener, MouseMotionListener, ActionListener {     int x1 = -1, y1 = -1, x2 = -1, y2 = -1,     //coordinates of start and end points             pixelsize = 12,                     //size of pixel in raster             xa = 0, xfin = 0, yfin = 0,         //increment and end po...

Bresenham line drawing algorithm in java

   My friend Sandip is doing M.Tech from one of the reputed college. His lecturer asked him to do Java code for line drawing using Bresenham s , DDA algorithm. So I am posting this blog for  Bresenham line drawing algorithm in java and you can find line drawing using DDA algorithm  here . Read more about Bresenham's line algorithm  . Java code :-  package applet; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; public class bresenhamLine extends java.applet.Applet implements MouseListener, MouseMotionListener { private static final long serialVersionUID = 1L; int width, height; int x1 = 0, y1 = 0, x2 = 0, y2 = 0, pixelsize = 2; public void init() {      width = getSize().width;      height = getSize().height;      this.addMous...