Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

Drawing Circle using Mid-point implmented using J2me

Mon May 07, 2007 11:19 pm

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;


}




Post a reply
  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