Re: Need trig & LCB help
Greg, I've been away from LCB for a while. When reading the last post again I remembered an improvement that you could try to use: The current version computes the pathes with every redraw (onPaint). This is far too often. We could compute the pathes once (in onCreate) and then update ONLY when needed (= when one of its params changes). This will give your widget a lot of time for other things and makes the OnPaint code shorter. variable mBCircles as List variable mBigRad as Number variable mLilRad as Number variable mInnerRad as Number variable mBigX as Number variable mBigY as Number variable mBNum as Number [1] in OnCreate write: put the number of elements in mData into mBNum put my width/2 into mBigX put my height/2 into mBigY put mBigRad-mLilRad into mInnerRad updateCirclePaths([mBNum,mInnerRad,mLilRad,mBigX,mBigY]) [2] in OnPaint write: repeat with tButtonNumber from 1 up to mBNum fill mBCircles[tButtonNumber] on this canvas end repeat [3] This does the job minimal often: Whenever you change one of its params write also updateCirclePaths([mBNum,mInnerRad,mLilRad,mBigX,mBigY]) [4] This handler computes already the small circle paths: -- sets the list mBCircles of regularly placed circle paths, -- turns clockwise from high noon, is centered at point [cX,cY] -- pL = [numOfCircles,bigRadius,smallRadius,cX,cY] handler updateCirclePaths (in pL as List) returns nothing variable tI as Number variable tPi as Number variable tPaths as List put 2*pi/pL[1] into tPi put [] into tPts repeat with tI from 0 up to pL[1]-1 push circle path centered at point \ [pL[4]+pL[2]*sin(tI*tPi), pL[5]-pL[2]*cos(tI*tPi)] \ with radius pL[3] onto tPaths end repeat put tPaths into mBCircles end handler Hope you'll show us your shining new widget ... ___ 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: Need trig & LCB help
This works much better than what I was trying. THANKS! - Replace the last part of your handler with the following. variable tBNum as Number variable tBCenters as List put tBigRad - tLilRad into tInnerRad put the number of elements in mData into tBNum put regularPoints([tBNum,tInnerRad,tBigX,tBigY]) into tBCenters repeat with tButtonNumber from 1 up to tBNum fill circle path centered at tBCenters[tButtonNumber] \ with radius tLilRad on this canvas end repeat -- returns list of N regular (=evenly spaced) circle points -- starting at high noon, turning clockwise -- pL = [numOfPoints,radius,centerX,centerY] handler regularPoints (in pL as List) returns List variable tI as Number variable tPi as Number variable tPts as List put 2*pi/pL[1] into tPi put [] into tPts repeat with tI from 0 up to pL[1]-1 push point \ [pL[3]+pL[2]*sin(tI*tPi), pL[4]-pL[2]*cos(tI*tPi)] onto tPts end repeat return tPts end polyPoints [Untested, right out of my head, should work.] ___ 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: Need trig & LCB help
Replace the last part of your handler with the following. variable tBNum as Number variable tBCenters as List put tBigRad - tLilRad into tInnerRad put the number of elements in mData into tBNum put regularPoints([tBNum,tInnerRad,tBigX,tBigY]) into tBCenters repeat with tButtonNumber from 1 up to tBNum fill circle path centered at tBCenters[tButtonNumber] \ with radius tLilRad on this canvas end repeat -- returns list of N regular (=evenly spaced) circle points -- starting at high noon, turning clockwise -- pL = [numOfPoints,radius,centerX,centerY] handler regularPoints (in pL as List) returns List variable tI as Number variable tPi as Number variable tPts as List put 2*pi/pL[1] into tPi put [] into tPts repeat with tI from 0 up to pL[1]-1 push point \ [pL[3]+pL[2]*sin(tI*tPi), pL[4]-pL[2]*cos(tI*tPi)] onto tPts end repeat return tPts end polyPoints [Untested, right out of my head, should work.] ___ 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