Results 1 to 4 of 4
- 07-28-2010, 12:10 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 27
- Rep Power
- 0
- 07-28-2010, 01:53 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,380
- Blog Entries
- 7
- Rep Power
- 17
- 07-28-2010, 09:41 PM #3
Cross posted
Java 2D - Use GeneralPath class to draw a regular octagon
db
- 07-29-2010, 12:12 PM #4
Member
- Join Date
- Dec 2008
- Posts
- 27
- Rep Power
- 0
I was using this code but it is not working. Can you tell me what is wrong with it?
Java Code:public void paintComponent(Graphics g){ float x,y; super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; GeneralPath path = new GeneralPath(); path.moveTo(200,200); for (int i = 1; i < 8; i++){ double a = i*0.25*Math.PI; path.lineTo((float)Math.cos(a), (float)Math.sin(a)); x = (float)Math.cos(a); y = (float)Math.sin(a); g2.draw(path); //printf("x %d,y %d: %f, %f\n", i,i,x,y); } path.closePath(); g2.draw(path);
Similar Threads
-
how to draw an arc
By Baker in forum New To JavaReplies: 1Last Post: 04-16-2009, 09:05 PM -
How to create a GeneralPath
By Java Tip in forum java.awtReplies: 0Last Post: 06-25-2008, 10:38 AM -
GeneralPath demo
By Java Tip in forum java.awtReplies: 0Last Post: 06-25-2008, 10:37 AM -
How to obtain a filled and stroked GeneralPath
By Java Tip in forum java.awtReplies: 0Last Post: 06-25-2008, 10:37 AM -
How to use GeneralPath class
By Java Tip in forum java.awtReplies: 0Last Post: 06-25-2008, 10:37 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks