home .. forth .. colorforth mail list archive ..

[ColorForth] Circle Primitive, happy for response



Nice indeed, and that AT & COLOR would make it blend in perfectly into the environement (would work as global variables/functions anyway, right?). Btw I´ll post my algorithm in pseudocode (its 100% tested and works like a charm) as Its the fastest & shortest circle algo ive had thru my years, if nothing else would be great fun see it in CF

Cheers.

CIRCLE(r)
a=r
c=-r
b=0
Repeat
symmetric(b,a)
symmetricplot(a,b)
b=b+1:c=c+b
If c=>0 Then a=a-1:c=c-a
Until a<b

symmetricplot(x,y)
Plot ATX+x,ATY+y
Plot ATX+x,ATY-y
Plot ATX-x,ATY+y
Plot ATX-x,ATY-y

From: Mark Slicker <maslicke@xxxxxxxxxxx>
Reply-To: ColorForth@xxxxxxxxxxxxxxxxxx
To: "ColorForth List Member"  <ColorForth@xxxxxxxxxxxxxxxxxx>
Subject: [ColorForth] Circle Primitive,  happy for response
Date: Sat, 15 Jun 2002 23:50:54 -0400 (EDT)

Hello,

Here is my take. It was easier to just write this since yours was
untested, and there were some misunderstandings of the colorForth
vocabulary. However it uses the ideas of your implementation, and the
bresenham algorithm from a book of mine.

circle takes (radius x y color), though it might be better though to use
the colorForth words 'at' and 'color', to define the position and color,
to fit in with the other drawing functions. Just thought of this now.

Mark

( Circle ) empt macro
: 2! [a!] 28966 3, [drop] ; forth variable b variable c variable d
variable de variable se
: point2 1024 * over negate + 2* b @ + c @ over 2! swap 4 * + c @ swap
2! ;
: 2over over over ;
: points 2over point2 2over negate point2 2over swap 2over negate point2
point2 ;
: d? d @ 0 less drop if de @ + d ! 2 de +! 2 se +! ; then se @ + d ! 2 de
+! 4 se +! -1 + ;
: circle c ! 1024 * + 2* 1e80000 + b ! 0 swap points dup - 2 + d ! dup -2
* 5 + se ! 3 de !
: n less if d? points 1 u+ n ; then drop drop ;
: ok show black screen 100 400 400 ffff circle keyboard ;
------------------------

To Unsubscribe from this list, send mail to Mdaemon@xxxxxxxxxxxxxxxxxx with:
unsubscribe ColorForth
as the first and only line within the message body
Problems   -   List-Admin@xxxxxxxxxxxxxxxxxx
Main ColorForth site   -   http://www.colorforth.com




_________________________________________________________________
Kom med i världens största e-posttjänst med MSN Hotmail. http://www.hotmail.com
------------------------

To Unsubscribe from this list, send mail to Mdaemon@xxxxxxxxxxxxxxxxxx with:
unsubscribe ColorForth
as the first and only line within the message body
Problems   -   List-Admin@xxxxxxxxxxxxxxxxxx
Main ColorForth site   -   http://www.colorforth.com