> > Message: 2 > Date: Fri, 17 Jan 2014 16:00:43 +0200 > From: j...@souslelogo.com > To: use-revolut...@lists.runrev.com > Subject: the points of graphic > Message-ID: <b058292c0d6ba33b59b2906da17e9271.squirrel@185.8.104.234> > Content-Type: text/plain;charset=iso-8859-1 > > Hi list, > > Is there a way to get the points of a Regular Polygon > graphic, or do I have to compute it myself using the > loc, width, height and number of sides of the graphic ? > > Thanks, > jbv > >
This script will provide the individual points. on mouseUp put the width of this card/2 into x0 put the height of this card/2 into y0 put 6 into n put 50 into L put 360/n into tAngle put x0,y0 & cr after tPoints set the points of grc "polygon" to tPoints repeat with i = 1 to n+1 -- plus 1 to close --Calculate each line segment individually --dx and dy and the x and y projections of the line segment repeat with j = 1 to i add L * cosine(j*tAngle) to dx subtract L * sine(j*tAngle) from dy end repeat put x0 + dx , y0 + dy into theCoord[i] --if you want the coordinates of each vertex put (x0 + dx), ( y0 + dy) & cr after tPoints set the points of grc "polygon" to tPoints--if you want to see the polygon evolve put 0 into dx put 0 into dy end repeat end mouseUp Given the individual points (theCoord[i]), it would be possible to do things line draw all diagonals, connect each vertex with all the others. When n is large, it is a pretty picture. But, of course, there is always the much simpler Turtle Graphics. To poly n, L repeat n forward L left 360/n put xycor() into theVertex[i] end repeat end poly _______________________________________________ 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