English
Source / code snippets

Ellipsen in Horizontallage through modifiziertem Bresenham-Kreisalgorithmus

 

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 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
04/25/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

632 Views

Untitledvor 0 min.
N.Art07/21/22
Ernst07/21/21
Uwe ''Pascal'' Niemeier06/13/21
R.Schneider05/28/21
More...

Themeninformationen

this Topic has 1 subscriber:

p.specht (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie