Created
February 22, 2020 17:30
-
-
Save MinSomai/6a5204117e3c99280defd68cafbc1b90 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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