| |
|
|
p.specht
| caution, schnarchlangsam there only principle-demonstration:
Window Title "BRESENHAM-ELLIPSEN IN HORIZONTALLAGE"
' Q: https://de.wikipedia.org/wiki/Bresenham-Algorithmus
' On XProfan gequält of P. woodpecker 2012-06. demonstration, no Gewähr!
Window Style 16 | 64
Font 2:randomize
Window 0,0 - %maxx,%maxy
var xm&=%maxx\2 : var ym&=%maxy\2:var cnt&= 0
var a&=300:var b&=160:var co&=rgb(255,0,0)
var bco&= rgb(210,210,210)+rgb(rnd(46),rnd(46),rnd(46))
Begin:
inc cnt&:ifnot cnt& mod 200:cls bco&:print " discontinue with ESC ";:endif
BrEllipse 2*xm&*rnd(),2*ym&*rnd(), a&*rnd(),b&*rnd(), rnd(8^8)
WaitInput 100
case %key=27:End
goto "Begin"
proc BrEllipse : parameters xm&, ym&, a&, b&,co&
var dx& = 0: var dy& = b&' in the I. quadrants of left supra to right under
var a2! = a&*a&: var b2! = b&*b&
var err! = b2!-(2*b&-1)*a2! : var e2!=0' Error in the 1. step
Repeat
setPixel xm&+dx&, ym&-dy&, co&' I. quadrant
setPixel xm&-dx&, ym&-dy&, co&' II. quadrant
setPixel xm&-dx&, ym&+dy&,co&'III. quadrant
setPixel xm&+dx&, ym&+dy&, co&'IV. quadrant
e2! = 2*err!
if e2! < ((2*dx&+1)*b2!) : inc dx& : err! = err! + (2*dx&+1)*b2! : endif
if e2! > (-(2*dy&-1)*a2!) : dec dy&: err! = err! - (2*dy& -1)*a2! : endif
Until dy& < 0
While dx& <= a&
inc dx&' against whom fehlerhaften discontinue with flachen Ellipsen with b=1:
setPixel xm&+dx&, ym&,co&' -> pointed the ellipsis complete
setPixel xm&-dx&, ym&,co&
EndWhile
ENDPROC
|
|
|
| XProfan 11Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 04/25/21 ▲ |
|
|
|