Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why do I get a whole red pie???  RSS feed

 
Caven Wang
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to use some colors to make my circle with the following code.

public void paint(Graphics g){
Graphics2D g2 = (Graphics2D) g;
g2.fill(new Arc2D.Double(10, 10, 200, 200, 0,100, Arc2D.PIE));
g2.setPaint(Color.blue );
g2.fill(new Arc2D.Double(10, 10, 200, 200, 100,120, Arc2D.PIE));
g2.setPaint(Color.darkGray );
g2.fill(new Arc2D.Double(10, 10, 200, 200, 120,135, Arc2D.PIE));
g2.setPaint(Color.green );
g2.fill(new Arc2D.Double(10, 10, 200, 200,135,270, Arc2D.PIE));
g2.setPaint(Color.cyan );
g2.fill(new Arc2D.Double(10, 10, 200, 200,270,290, Arc2D.PIE));
g2.setPaint(Color.lightGray );
g2.fill(new Arc2D.Double(10, 10, 200, 200, 290,300, Arc2D.PIE));
g2.setPaint(Color.red );
g2.fill(new Arc2D.Double(10, 10, 200, 200, 300,360, Arc2D.PIE));
}
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Caven,
You are putting the wrong value into the sixth parameter of the Arc2D double method call. THe sizth parameter is the amount of angle to cover and not the ending angle. You case:

All sixth values add up to full circle or 360 degrees.
Regards,
Manfred.
 
Caven Wang
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I saw your answer , I come to realize my stupidity. Thank you sooooooooooooooooooooo much!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!