Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Drawing shapes on forms
Message
De
05/09/2001 09:49:30
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
05/09/2001 07:23:39
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Divers
Thread ID:
00552409
Message ID:
00552477
Vues:
23
>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

Joe,
Using line() in other form line(FromX, FromY, ToX, ToY) should slightly speed it up.
Next if you lockscreen=.t. before drawing and .f. after drawing it should boost more.
However if I understood it right this would draw sort of doughnut with gaps in it (like sun radians). I think you could do the same with 2 shapes with curvature 99 + half count of gaps as line objects (line objects graphically under top shape and over the larger). Design it as a class and just broadcast a setall for its size IMHO. I expect it to have much smoother appearence + it would be durable to form painting + faster (though line() method is fast sounds too much calls to it).
Another option might be increasing your linewidth to reduce loop count.
And yet another one might be doing that with much fewer lines (lines passing from center of a circle with full diameter). To create the center hole place a shape with curvature 99.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform