Total members 11890 |It is currently Thu Apr 18, 2024 4:38 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Drawing Circle using Mid-Point Techniqe .The Most important thing in this techniqe is his performance.The Circle Drawen using this techniqe is not so smooth and this considered as a drawback on this techniqe.

You need a NetBeans + NetBeans Mobility package to run the project.


The Following part is the class of Circle Midpoint , this algorthem can be implmented using Java 2 SE on any JFrame Just copy and past the funtion "paint" .
java code
/**
*
*/
class myCanvas extends Canvas
{
public myCanvas(int x1,int y1,int R)
{
this.x1=x1;
this.y1=y1;
this.R=R;

}
protected void paint(Graphics g)
{
g.fillRect(0,0,300,300);
g.setColor(200,23,43);
float p=1-R;
float theta=0.0f;
int x=0;
int y=R;
while(x<=y)
{
if(p<0)
{
x=x+1;
p=p+2*x+1;
}
else if(p>=0)
{
x=x+1;
y=y-1;
p=p+2*x+1-2*y;

}
g.drawLine(x+(100)+x1,(150)-y-y1,x+(100)+x1,(150)-y-y1);
g.drawLine(-x+(100)+x1,(150)-y-y1,-x+(100)+x1,(150)-y-y1);
g.drawLine(x+(100)+x1,(150)+y-y1,x+(100)+x1,(150)+y-y1);
g.drawLine(-x+(100)+x1,(150)+y-y1,-x+(100)+x1,(150)+y-y1);
g.drawLine(y+(100)+x1,(150)-x-y1,y+(100)+x1,(150)-x-y1);
g.drawLine(-y+(100)+x1,(150)-x-y1,-y+(100)+x1,(150)-x-y1);
g.drawLine(y+(100)+x1,(150)+x-y1,y+(100)+x1,(150)+x-y1);
g.drawLine(-y+(100)+x1,(150)+x-y1,-y+(100)+x1,(150)+x-y1);

}

}

int x1=0;
int y1=0;
int R=0;


}




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Drawing Circle using Mid-point implmented using J2me
 Drawing circle using circle equation directly , on mouse     -  
 Mid-point Algorithm using j2me     -  
 php drawing a circle     -  
 Circle drawing using Bresenham     -  
 php drawing a circle with imagearc()     -  
 Circle direct drawing algorithm     -  
 Circle drawing using Polar based algorithm with C++     -  
 Point class in C++     -  
 Curve Control Point in java     -  
 All 4 CCNA semesters in power point pass?     -  



Topic Tags

Java Graphics
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com