Re: mouse within oval filled area
a simplifyed version of the hack to get at the boundaries of a oval with startangle and arcangle set. Again to get the area of a oval graphic with a startangle and an arcangle set and opaque = true you could use the new 5.0 intersect(object,object,pixels) syntax. You would have to cheat though in that you create a hidden polygon graphic hidden and call your start/arcangle graphic halfCircle plus a field for feedback (for testing) the script of the graphic halfCircle: - on mouseWithin set the points of grc hidden to the mouseLoc if intersect(graphic halfCircle, grc hidden, pixels) then put the mouseColor the milliseconds into field 1 else put into field 1 end if end mouseWithin on mouseLeave put into field 1 end mouseLeave - Depending on your needs you could change this to mouseMove. Maybe it would be nice if the 'within' syntax would also have the option of pixels. No more clunky workarounds. within(object,point,pixels) Kind regards Bernd -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/mouse-within-oval-filled-area-tp4034252p4036414.html Sent from the Revolution - User mailing list archive at Nabble.com. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: mouse within oval filled area
This is probably a silly idea, but.. if you have AE 5 with its collision detection, maybe you can drag a hidden pixel around at the mouseloc and set your ovals up to detect collisions. At which point a message is sent with all the ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: mouse within oval filled area
oops. accidental send on that last one. Clumsy day for me! As I was saying, if you use AE5 and drag around a pixel at the mouseloc the collision detection stuff in AE5 should make this a piece of cake. On Sun, Nov 13, 2011 at 6:51 AM, Mike Bonner bonnm...@gmail.com wrote: This is probably a silly idea, but.. if you have AE 5 with its collision detection, maybe you can drag a hidden pixel around at the mouseloc and set your ovals up to detect collisions. At which point a message is sent with all the ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: mouse within oval filled area
Jacque, BOL! (Burst out laughing) This may be more recognizable, the equation for the ellipse in rectangular coordinates: x^2 + y^2 - - = 1 a^2 b^2 Just replace x by r*cos(theta) and y by r*sin(theta) and solve for r. Voila. Well maybe not. Foreign languages are not difficult, just alien. Speaking of which, I have no idea what the emoticon :P means. I hope its not something naughty. After two years of classical Greek I recall (?) that Ho strategos eine micros, means the general is small. (It doesn't look anything like this in modern Greek.) The rest is all Greek to me. Jim On 11/13/11 12:01 AM, James Hurley wrote: function r tA --Radial distance to the ellipse as afunction of the angle put (cos(tA*pi/180))^2 / (a*a) + (sin(tA*pi/180))^2 / (b*b) into temp return 1/sqrt(temp) end r This means something, right? Well, for your information I happen to know how to say beer in Turkish. So there. :P -- Jacqueline Landman Gay | jacque at hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: mouse within oval filled area
By the way, to see how different the startAngle is from the polar angle, make a very wide oval with a very small height. Set the startangle to 45 degrees and the arcangle to say 250. The start angle appears to be about 10 degrees. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: mouse within oval filled area
Just tried doing the detection using AE5 and it works like a champ. With the collisionListernerDemo, a couple really simple changes gets the job done. in the card script I added the following: command startMove if tMoving is empty then put false into tMoving --put false into tMoving put not tMoving into tMoving mover end startMove command mover if tMoving then lock screen set the loc of grc grmypnt to the mouseloc unlock screen send mover to me in 10 milliseconds end if end mover In the button script that starts the demo listening I added a startmove call so the final handler ends up as so: -- all handlers on mouseUp pMouseBtnNo if animationEngine is not among the lines of the stacksInUse then answer This stack needs animationEngine 5 or higher to run. exit mouseUp end if aeStopListeningForCollisions local tList set the flag of me to not the flag of me if the flag of me then -- set up graphics to be draggable repeat with i=1 to the number of graphics set the constrainRectangular of graphic i to the rect of this cd -- graphics need to be opaque to be draggable set the opaque of graphic i to true end repeat repeat with i = 2 to the number of graphics --put the long id of graphic i ,bounds cr after tList put the long id of graphic i cr after tList end repeat -- remove trailing carriage return delete char -1 of tList set the aeListenForCollisionsWith of graphic 1 to tList -- right now we assume all but graphic 1 are predators -- you could set up lists for each graphic though aeStartListeningForCollisions set the label of me to Stop listening for collisions else aeStopListeningForCollisions set the label of me to Start listening for collisions end if startMove -- my change end mouseUp I then created a grc named grmypnt and moved its layer to the back so that it becomes the focus of the listener. It also needs to be moved to the back so you can still click other items. (otherwise you're clicking the graphic no matter WHERE the mouse is. On moving the mouse around and over the other graphics, the output field populates with the other graphics that are being mouseovered. Seems to work pretty well. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: mouse within oval filled area
Oh, forgot to mention. The really cool thing about the collision listener is if you have overlapping graphics, it will list all of them as collisions. AE5 is just too cool. On Sun, Nov 13, 2011 at 8:43 AM, Mike Bonner bonnm...@gmail.com wrote: Just tried doing the detection using AE5 and it works like a champ. With the collisionListernerDemo, a couple really simple changes gets the job done. in the card script I added the following: command startMove if tMoving is empty then put false into tMoving --put false into tMoving put not tMoving into tMoving mover end startMove command mover if tMoving then lock screen set the loc of grc grmypnt to the mouseloc unlock screen send mover to me in 10 milliseconds end if end mover In the button script that starts the demo listening I added a startmove call so the final handler ends up as so: -- all handlers on mouseUp pMouseBtnNo if animationEngine is not among the lines of the stacksInUse then answer This stack needs animationEngine 5 or higher to run. exit mouseUp end if aeStopListeningForCollisions local tList set the flag of me to not the flag of me if the flag of me then -- set up graphics to be draggable repeat with i=1 to the number of graphics set the constrainRectangular of graphic i to the rect of this cd -- graphics need to be opaque to be draggable set the opaque of graphic i to true end repeat repeat with i = 2 to the number of graphics --put the long id of graphic i ,bounds cr after tList put the long id of graphic i cr after tList end repeat -- remove trailing carriage return delete char -1 of tList set the aeListenForCollisionsWith of graphic 1 to tList -- right now we assume all but graphic 1 are predators -- you could set up lists for each graphic though aeStartListeningForCollisions set the label of me to Stop listening for collisions else aeStopListeningForCollisions set the label of me to Start listening for collisions end if startMove -- my change end mouseUp I then created a grc named grmypnt and moved its layer to the back so that it becomes the focus of the listener. It also needs to be moved to the back so you can still click other items. (otherwise you're clicking the graphic no matter WHERE the mouse is. On moving the mouse around and over the other graphics, the output field populates with the other graphics that are being mouseovered. Seems to work pretty well. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: mouse within oval filled area
On 11/13/11 8:47 AM, James Hurley wrote: Jacque, BOL! (Burst out laughing) This may be more recognizable, the equation for the ellipse in rectangular coordinates: x^2 + y^2 - - = 1 a^2 b^2 Just replace x by r*cos(theta) and y by r*sin(theta) and solve for r. Voila. Oh, of course. I should have thought of that... Speaking of which, I have no idea what the emoticon :P means. It means I'm sticking out my tongue at you. Nyah. But seriously, I'm totally in awe. -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: mouse within oval filled area: A solution using geometry
For those who do not have LC5 or AE (ideas already suggested), here is a solution to detect whether a point is within the filled area of an oval graphic using polar geometry. It is offered as a starting point for a more compact solution. on mouseUp --| Syntax: isWithinSegment(long ID,point) put isWithinSegment(the long id of grc myOval,the mouseLoc) end mouseUp function isWithinSegment pGrc.obj,pLoc --| pGrc.obj is the long id of the graphic --| pLoc is a point expressed as x,y --| Returned value is TRUE or FALSE if word 1 of pGrc.obj graphic then return if the style of pGrc.obj oval then return put the startAngle of pGrc.obj into tSA put the arcAngle of pGrc.obj into tAA put the width of pGrc.obj into W put the height of pGrc.obj into H put item 1 of the loc of pGrc.obj into objX put item 2 of the loc of pGrc.obj into objY put item 1 of pLoc into pointX put item 2 of pLoc into pointY --| Get the point's relative coordinates... put pointX - objX into x put pointY - objY into y if y=0 then --| Handle the exceptions... if x0 then put 0 into tAngle else put 180 into tAngle else put atan ((x*H)/(y*W)) into tAngle --| Convert from radians to degrees... put (tAngle * 180 / pi) into tAngle --| Adjust the angle according to the quadrant... put (tAngle MOD 180)+90 into tAngle if y0 then add 180 to tAngle end if return (tAngle= tSA) AND (tAngle=tSA+tAA) end isWithinSegment Hugh Senior FLCo ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
mouse within oval filled area
Has anyone worked out how to test if the mouseLoc is within the filled area of an oval graphic (defined by startAngle and arcAngle)? I was thinking polar coordinates, but this assumes a circle and a fixed radius which is not necessarily the case. A btter math brain than mine is needed! Hugh Senior FLCo ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
RE: mouse within oval filled area
Use the mouseColor ? From: ad...@flexiblelearning.com To: use-livecode@lists.runrev.com Subject: mouse within oval filled area Date: Sat, 12 Nov 2011 11:59:33 + Has anyone worked out how to test if the mouseLoc is within the filled area of an oval graphic (defined by startAngle and arcAngle)? I was thinking polar coordinates, but this assumes a circle and a fixed radius which is not necessarily the case. A btter math brain than mine is needed! Hugh Senior FLCo ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: mouse within oval filled area
Hi Hugh, I haven't done exactly as you describe, but have made things where I only wanted a response when the user clicked the filled area of a graphic. I used the function version of within…. This script in the graphic…. on mouseUp if within(graphic myGraphic,the mouseLoc) then beep end if end mouseUp The beep only happens on the filled area of the graphic. be well, randy hengst - On Nov 12, 2011, at 5:59 AM, FlexibleLearning wrote: Has anyone worked out how to test if the mouseLoc is within the filled area of an oval graphic (defined by startAngle and arcAngle)? I was thinking polar coordinates, but this assumes a circle and a fixed radius which is not necessarily the case. A btter math brain than mine is needed! Hugh Senior FLCo ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: mouse within oval filled area
Sorry to flood the list.. but nevermind… I double-checked and that idea doesn't help you…. On Nov 12, 2011, at 9:56 AM, Randy Hengst wrote: Hi Hugh, I haven't done exactly as you describe, but have made things where I only wanted a response when the user clicked the filled area of a graphic. I used the function version of within…. This script in the graphic…. on mouseUp if within(graphic myGraphic,the mouseLoc) then beep end if end mouseUp The beep only happens on the filled area of the graphic. be well, randy hengst - On Nov 12, 2011, at 5:59 AM, FlexibleLearning wrote: Has anyone worked out how to test if the mouseLoc is within the filled area of an oval graphic (defined by startAngle and arcAngle)? I was thinking polar coordinates, but this assumes a circle and a fixed radius which is not necessarily the case. A btter math brain than mine is needed! Hugh Senior FLCo ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
RE: mouse within oval filled area
Indeed, John, but not a unique object identifier if more than one grc uses the same color. I think I am back to polar coordinates (unfortunately). The current engine behaviour is painfully inconsistent with other controls whose transparency is immune from mouse events. Hugh Senior FLCo John Dixon wrote: Use the mouseColor ? Original message: Has anyone worked out how to test if the mouseLoc is within the filled area of an oval graphic (defined by startAngle and arcAngle)? I was thinking polar coordinates, but this assumes a circle and a fixed radius which is not necessarily the case. A btter math brain than mine is needed! Hugh Senior FLCo ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
RE: mouse within oval filled area
OK then... on mouseWithin put the backgroundcolor of me into colorCheck if the mouseColor = colorCheck then put I am inside the coloured bit of control ID no the short id of me end if end mouseWithin From: ad...@flexiblelearning.com To: use-livecode@lists.runrev.com Subject: RE: mouse within oval filled area Date: Sat, 12 Nov 2011 19:25:16 + Indeed, John, but not a unique object identifier if more than one grc uses the same color. I think I am back to polar coordinates (unfortunately). The current engine behaviour is painfully inconsistent with other controls whose transparency is immune from mouse events. Hugh Senior FLCo John Dixon wrote: Use the mouseColor ? Original message: Has anyone worked out how to test if the mouseLoc is within the filled area of an oval graphic (defined by startAngle and arcAngle)? I was thinking polar coordinates, but this assumes a circle and a fixed radius which is not necessarily the case. A btter math brain than mine is needed! Hugh Senior FLCo ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: mouse within oval filled area
This would be very difficult to implement if the graphic had a gradient. On Sat, Nov 12, 2011 at 1:09 PM, John Dixon dixo...@hotmail.co.uk wrote: OK then... on mouseWithin put the backgroundcolor of me into colorCheck if the mouseColor = colorCheck then put I am inside the coloured bit of control ID no the short id of me end if end mouseWithin From: ad...@flexiblelearning.com To: use-livecode@lists.runrev.com Subject: RE: mouse within oval filled area Date: Sat, 12 Nov 2011 19:25:16 + Indeed, John, but not a unique object identifier if more than one grc uses the same color. I think I am back to polar coordinates (unfortunately). The current engine behaviour is painfully inconsistent with other controls whose transparency is immune from mouse events. Hugh Senior FLCo John Dixon wrote: Use the mouseColor ? Original message: Has anyone worked out how to test if the mouseLoc is within the filled area of an oval graphic (defined by startAngle and arcAngle)? I was thinking polar coordinates, but this assumes a circle and a fixed radius which is not necessarily the case. A btter math brain than mine is needed! Hugh Senior FLCo ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
RE: mouse within oval filled area
Yes, it would... but a gradient wasn't mentioned... we could throw spanners into the works all night! From: gboj...@gmail.com Date: Sat, 12 Nov 2011 13:34:32 -0700 Subject: Re: mouse within oval filled area To: use-livecode@lists.runrev.com This would be very difficult to implement if the graphic had a gradient. On Sat, Nov 12, 2011 at 1:09 PM, John Dixon dixo...@hotmail.co.uk wrote: OK then... on mouseWithin put the backgroundcolor of me into colorCheck if the mouseColor = colorCheck then put I am inside the coloured bit of control ID no the short id of me end if end mouseWithin From: ad...@flexiblelearning.com To: use-livecode@lists.runrev.com Subject: RE: mouse within oval filled area Date: Sat, 12 Nov 2011 19:25:16 + Indeed, John, but not a unique object identifier if more than one grc uses the same color. I think I am back to polar coordinates (unfortunately). The current engine behaviour is painfully inconsistent with other controls whose transparency is immune from mouse events. Hugh Senior FLCo John Dixon wrote: Use the mouseColor ? Original message: Has anyone worked out how to test if the mouseLoc is within the filled area of an oval graphic (defined by startAngle and arcAngle)? I was thinking polar coordinates, but this assumes a circle and a fixed radius which is not necessarily the case. A btter math brain than mine is needed! Hugh Senior FLCo ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: mouse within oval filled area
Hi Hugh, to get the area of a oval graphic with a startangle and an acrangle set and opaque to true you could use the new 5.0 intersect(object,object,pixel) syntax. You would have to cheat though in that you create a hidden polygon graphic hidden and call your start/arcangle graphic halfCircle plus any field for feedback The script of graphic halfCircle could be: on mouseWithin put the mouseLoc into tLoc put item 1 of tLoc - 1 comma item 2 of tLoc - 1 comma \ item 1 of tLoc +1 comma item 2 of tLoc + 1 into tRect set the rect of grc hidden to tRect if intersect(graphic halfCircle, grc hidden, pixels) then put the milliseconds into field 1 else put into field 1 end if end mouseWithin --- it works but it is a more of a hack. maybe someone has a better solution... Kind regards Bernd -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/mouse-within-oval-filled-area-tp4034252p4035498.html Sent from the Revolution - User mailing list archive at Nabble.com. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: mouse within oval filled area
Hugh, Would this help? The script below will draw a polygon that looks like an ellipse with a start and stop angle. The trouble with the start angle and the arcangle in RR is that they are not polar angles but are related in a complex way: arcAngle = arctangent( b/a * tangent(polarangle) (Don't ask.) And then use a mousewithin handler for the oval grc--actually a polygon local a,b on mouseUp put 10 into tStartAngle -- Or whatever put 250 into tEndAngle -- Or whatever put 200 into a --Semi major axis put 100 into b -- Semi minor axis put 300 into x0 -- The origin put 250 into y0 -- The origin put x0,y0 cr into tPoints --Construct the points for the ellipse repeat with i = tStartANgle to tEndANgle put r(i) into tR put round ( x0 + r(i) * cos(i*pi/180)), round(y0+r(i) * sin(i*pi/180)) into temp put temp cr after tPoints end repeat put x0,y0 after tPoints --Construct the graphic if there is no grc oval then create grc oval set the style of grc oval to polygon set the opaque of grc oval to true set the points of grc oval to tPoints end mouseUp function r tA --Radial distance to the ellipse as afunction of the angle put (cos(tA*pi/180))^2 / (a*a) + (sin(tA*pi/180))^2 / (b*b) into temp return 1/sqrt(temp) end r Has anyone worked out how to test if the mouseLoc is within the filled area of an oval graphic (defined by startAngle and arcAngle)? I was thinking polar coordinates, but this assumes a circle and a fixed radius which is not necessarily the case. A btter math brain than mine is needed! Hugh Senior FLCo ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode