Skip to content

Instantly share code, notes, and snippets.

@MinSomai
Created February 22, 2020 17:30
Show Gist options
  • Save MinSomai/6a5204117e3c99280defd68cafbc1b90 to your computer and use it in GitHub Desktop.
Save MinSomai/6a5204117e3c99280defd68cafbc1b90 to your computer and use it in GitHub Desktop.
package hw;
import java.awt.*;
import java.applet.*;
public class BresenhamCircleAlgorithm13 extends Applet {
@Override
public void paint(Graphics g) {
int xc,yc,r;
xc=225;
yc=225;
r=80;
int x=0;
int y=r;
int p=3-2*r;
do {
if(p<0)
p=p+4*x+6;
else
{
p=p+4*(x-y)+10;
y=y-1;
}
x=x+1;
g.drawLine(xc+x,yc+y,xc+x,yc+y);
g.drawLine(x+xc,yc-y,xc+x,yc-y);
g.drawLine(xc-x,yc+y,xc-x,yc+y);
g.drawLine(xc-x,yc-y,xc-x,yc-y);
g.drawLine(xc+y,yc+x,xc+y,yc+x);
g.drawLine(xc+y,yc-x,xc+y,yc-x);
g.drawLine(xc-y,yc+x,xc-y,yc+x);
g.drawLine(xc-y,yc-x,xc-y,yc-x);
}while(x<y);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment