|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Sujet n° 1400 |
Released: Example demonstrating Bresenham's MidPoint Circle Algorithm |
le 02/05/2006 @ 21:08 par bh77a
|
Tuesday, May 2, 2006
Good day,
Here is a link to a new project that I am releasing that demonstrates Bresenham's MidPoint Circle Algorithm:
http://geocities.com/bh77a/palm_stuff/ib_code_midpointcircle.html
Please note that this is better than the PP applet as the circles are truly hollow using this method. Full source is provided, including documentation on origins of algorithm.
Features are: - custom x,y - custom radius - filled or hollow
Of course anyone is free to use this as they see fit. Should you have any questions, please don't hesitate to ask.
Regards, bh77a |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 1 -------- le 06/05/2006 @ 12:24 par aldweb
visiteur |
It maybe is better but isn't it a bit slower?
Cheers
@+ aldweb |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 2 -------- le 06/05/2006 @ 17:13 par bh77a
visiteur |
You are right... it is a bit slower. In an attempt to gain truly hollow circles with PP I should try the WinDrawRectangleFrame API procedure with a frame type set to 0x0401.
Regards, bh77a |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 3 -------- le 07/05/2006 @ 05:21 par bh77a
visiteur |
Hi,
Just reporting back that WinDrawRectangleFrame only seems to draw a rectangle with rounded corners, so it will be insufficient for hollow circles.
While the PP applet works fast for filled circles, the algorithm isn't too slow for hollow ones, which are needed if one wants to implement into a drawing app of sorts.
Any thoughts on speeding it up or making truly hollow circles with the PP applet are most welcome.
Regards, bh77a |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 4 -------- le 08/05/2006 @ 20:44 par Pierre
visiteur |
Hi, both Aldweb and bh77a !
I just had a look on your PPApplet (ibcircle): 6 calls to the 'substring' routine and 6 more to the 'StrAToI... to call a single API routine to draw a circle !?... These are 12 reasons to be slow.
In order to define a circle, you just need its center and its radius. As a Palm screen is max 320x480 you just need 9 bits to define those elements (9 bits give you a 512 points range) : so 3x9=27 and one bit for filled/hollow circle are 28 bits ... you just need an integer (32 bits) to send your data from your iziBasic program to your PPApplet (and then use 'shr' and 'and').
I never 'compiled' anything with IziBasic (excuse moi Aldweb , or with the GUI mode of PP. Anyway, if I could help you, it would be a pleasure.
Pierre, qui va aller dormir. |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 5 -------- le 08/05/2006 @ 21:46 par bh77a
visiteur |
Hi Pierre,
Thank you for the feedback.
I am very interested in your method. Could you please provide some more details?
My method is probably very poor, but my goal was to make a circle that could be defined via user input in iziBasic, which would then be sent the parameters to PP and use native API to draw it.
Since PP receives strings from iB (iziBasic), I had to pass the parameters as a string and then let PP cut and convert the string...
Some of the code should probably be changed to the following...
x:=StrAToI(SubString "rect",1,3);
which would be a small bit more efficient (or at least easier to follow when viewing).
The "native" iziBasic method (listed on my site as well) of using the MidPoint Circle Algorithm is a little slower than the PP applet method, but it does allow for hollow circles, in which my method using PP applet certainly did not (looked hollow but weren't :( ). It is terribly slow (too slow for a drawing app) if one has a chance to look at it to and has ideas to speed it up that would be great... maybe I need to dump the routine into a PP applet for speed issues?
If you have any thoughts on speeding up the process of drawing ellipses, as posted a few threads down, that would be great. Unfortunately, I was unable to follow the MidPoint Ellipse Algorithm (just a programmer for a hobby, never took a real class of it) so I had to revert to a meshing of the draw routine and sin/cosine manipulations.
Thanks for taking the time to look at the project. I look forward to any information/assistance that you may provide.
Regards, bh77a |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 6 -------- le 09/05/2006 @ 13:21 par bh77a
visiteur |
Based on Pierre's suggestions, a leaner version of PP circle applet is posted:
http://www.geocities.com/bh77a/palm_stuff/ib_applet_circle.html
Quite a few lines of code removed, etc.
Thanks, bh77a |
|
|
sujet actif
sujet clos
Important!
Nouveau message -
Rectifier message
Clôturer sujet
Remonter
|
|