|
Author |
Topic: circle segments (Read 7200 times) |
|
toxi
|
circle segments
« on: Aug 12th, 2003, 2:54pm » |
|
been playing around with some idea using circle/pie chart segments. some of them started roaming free... http://www.toxi.co.uk/p5/segments/ a click will cause them to change appearance. all in all, the drawSegment function in this code is quite a handy tool for other aspects/applications... have fun! UPDATE :::::::::::::::::::::::::::::::: alternate version with modulated radii and Z transformation: http://www.toxi.co.uk/p5/segmentsZ/
|
« Last Edit: Aug 12th, 2003, 6:38pm by toxi » |
|
http://toxi.co.uk/
|
|
|
flight404
|
Re: circle segments
« Reply #1 on: Aug 12th, 2003, 9:30pm » |
|
yum.
|
|
|
|
scrap-pile
|
Re: circle segments
« Reply #2 on: Aug 12th, 2003, 10:25pm » |
|
the first one is really elegant, nice work
|
|
|
|
REAS
|
Re: circle segments
« Reply #3 on: Aug 13th, 2003, 8:48am » |
|
hey toxi, did you compile this with v58? it's not showing up on my machine. i'm running the microsoft vm and getting the following error: Code: Error loading class: circleSegmentsAlt java.lang.NoClassDefFoundError java.lang.ClassNotFoundException: circleSegmentsAlt at com/ms/vm/loader/URLClassLoader.loadClass at com/ms/vm/loader/URLClassLoader.loadClass at com/ms/applet/AppletPanel.securedClassLoad at com/ms/applet/AppletPanel.processSentEvent at com/ms/applet/AppletPanel.processSentEvent at com/ms/applet/AppletPanel.run at java/lang/Thread.run |
|
|
|
|
|
toxi
|
Re: circle segments
« Reply #4 on: Aug 13th, 2003, 11:22am » |
|
you're right casey! i did export with 58 and also just got the same errors as you did under IE6 (w/ M$ JVM). so i guess i'll have to post a new bug... btw. also just recompiled both applets under 56 and they both work fine. have another look!
|
http://toxi.co.uk/
|
|
|
REAS
|
Re: circle segments
« Reply #5 on: Aug 13th, 2003, 6:44pm » |
|
i really wanted to see them yesterday so i copied the code from your pages and looked at them locally. thanks.
|
|
|
|
Koenie
|
Re: circle segments
« Reply #6 on: Aug 13th, 2003, 9:23pm » |
|
There's only one thing I can say about that: Those pie chart are alive and kickin'. Koenie
|
http://koeniedesign.com
|
|
|
kevinP
|
Re: circle segments
« Reply #7 on: Jan 23rd, 2004, 4:30pm » |
|
on Aug 12th, 2003, 2:54pm, toxi wrote:been playing around with some idea using circle/pie chart segments. some of them started roaming free... [...] UPDATE :::::::::::::::::::::::::::::::: alternate version with modulated radii and Z transformation: http://www.toxi.co.uk/p5/segmentsZ/ |
| Really nice! I keep seeing lots of fantastic work here. This piece I can picture on a large wall (in the wall); that responds as you move past or mover closer to the image. Would be great in a large modern space; especially with a couple environmentally linked variables (room temperature or time or brightnesss) to introduce a little longer term variation. -K
|
Kevin Pfeiffer
|
|
|
kate
|
Re: circle segments
« Reply #8 on: Jul 27th, 2004, 6:07pm » |
|
I'm working on a program that I want to put an interactive pie chart in -- but I am struggling to come up with a good method to detect when the mouse is over a certain circle segment. any suggestions? Thanks, Kate
|
|
|
|
TomC
|
Re: circle segments
« Reply #9 on: Jul 27th, 2004, 6:16pm » |
|
I'd use the angles of the start and end of the segment, and the radius of the circle. So if the angle to the mouse-pointer is between the start and end of the segment, and the distance to the pointer is less than the circle radius, then the mouse is over the segment. (You can calculate the angles with atan2() - see http://processing.org/reference/atan2_.html or http://processing.org/learning/examples/arctangent.html for more info.)
|
« Last Edit: Jul 27th, 2004, 6:17pm by TomC » |
|
|
|
|
kate
|
Re: circle segments
« Reply #10 on: Jul 29th, 2004, 4:51pm » |
|
Thanks... got it to work: Code: boolean over(){ push(); //move origin for tangent calculation: // (x, y) is the center of circle the segment is drawn from. translate(x, y); float angle = degrees(atan2(mouseY-y, mouseX-x)); pop(); //account for negative angles returned from atan2 angle += ((angle<0) ? 360 : 0); //in case end is out of 0 to 360 range angle += (((end>360) && (angle<180)) ? 360 : 0); return ((start < angle) && (end > angle)) &&(sqrt(sq(x - mouseX) + sq(y - mouseY)) < r2 ) && (sqrt(sq(x - mouseX) + sq(y - mouseY)) > r1 ); } |
|
|
|
|
|
TomC
|
Re: circle segments
« Reply #11 on: Jul 29th, 2004, 5:16pm » |
|
Well, done The push / translate / pop calls aren't actually doing anything there, by the way. They only affect drawing, not atan2 or any other maths functions.
|
|
|
|
|