Hi!
Following is somewhat improved algorithm. I removed the most internal loop by replacing it using sinle 'line' method call. Seems display is the same...
The slow down is in the approach you used. VFP have no much things to use for drawing. You might want to use the API functions that are much more quick and have wide number of functions, include drawing of angle of circle (set the width of line to 20 using DrawWidth, then draw circle - see how it quick? API functions allow to draw a piece of circle - that is probably what you need). This require a lot of learning, however, if you did not worked with drawing API functions before. (I do not used much them too).
OpenDeg = 2.9
counter = -0.050
with thisform
.DRAWWIDTH=2
shbsY = .shapebase1.top+(.shapebase1.height/2)
shbsX = .shapebase1.left+(.shapebase1.width/2)
for xx = 90.5 to 448 step 3.6
IF COUNTER = 0
COUNTER = COUNTER + 0.001
ENDIF
if counter > .max or counter < .min
.forecolor = rgb(255,0,0)
else
.forecolor = rgb(66,192,0)
endif
cosXX = COS(DTOR(XX))
cosYY = SIN(DTOR(XX))
for yy = 172 to 154 step -2
.line(shbsX+(YY*cosXX), shbsY+(YY*cosYY), ;
shbsX+(YY*COS(DTOR(XX+OpenDeg-1))), shbsY+(YY*SIN(DTOR(XX+OpenDeg-1))) )
endfor
counter = counter + 0.001
endfor
endwith
>Hello, here is some code that draws a clock-shaped dial on a form. The hash-marks are different each time based upon parameters. It works well, but takes a bit too long to draw. Anyone see any clear ways to speed/refine this code up?
>Thx, Seth
>
>OpenDeg = 2.9
>
>this.parent.cmdquit.setfocus()
> counter = -0.050
> PAPER=_SCREEN.ACTIVEFORM
> PAPER.DRAWWIDTH=2
>
>for xx = 90.5 to 448 step 3.6 &&100 Marks
> IF COUNTER = 0
> COUNTER = COUNTER + 0.001
> ENDIF
>
> if counter > thisform.max or counter < thisform.min
> thisform.forecolor = rgb(255,0,0)
> else
> thisform.forecolor = rgb(66,192,0)
> endif
>
> for yy = 172 to 154 step -2 &&Draw colored blocks, line by line
> PAPER.CURRENTX=thisform.shapebase1.left+(thisform.shapebase1.width/2)+(YY*COS(DTOR(XX)))
> PAPER.CURRENTY=thisform.shapebase1.top+(thisform.shapebase1.height/2)+(YY*SIN(DTOR(XX)))
> FOR angle = XX+1 TO XX+OpenDeg
> PAPER.LINE(thisform.shapebase1.left+(thisform.shapebase1.width/2)+(YY*COS(DTOR(angle))),thisform.shapebase1.top+(thisform.shapebase1.height/2)+(YY*SIN(DTOR(angle))))
> ENDFOR
> endfor
> counter = counter + 0.001
>endfor
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.comICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs
It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.