English
Source / code snippets

Bresenham-Kreisalgorithmus

 

p.specht


'In XProfan 11.2a free written for learning
Windowstyle 31
Windowtitle "Bresenham-Circles"
Window %maxx*.81,%maxy*.81
Cls @Rgb(231,231,221)
'  Kreise in stood off ex%
var r%= sqrt((@width(%hWnd)/2)^2 + (@height(%hWnd)/2)^2 )
var ex%=14

while r%>0

    brCircle( @width(%hWnd)/2, @height(%hWnd)/2 , r% , \
    @rgb(rnd(100)+155,rnd(155)+100,r% and 255) )
    r% = r% - ex%
    case %MousePressed : break

endwhile

WaitInput
End

proc brCircle

    ' Bresenham-Algorithmus for a (Achtel-)circle
    parameters xmittel%,ymittel%,r%,c%
    var x% = r%
    var y% = 0
    var Error% = r%
    declare dy%,dx%
    Gosub "DrawPixels"' JAWOLL, ONE GOSUB! DA STAUNSTE, WAS?

    WHILE y% < x%

        dy% = y%*2+1 : REM with Assembler-Implementierung *2 by Invoice values
        inc y%
        Error% = Error% - dy%

        IF Error%<0

            dx% = 1 - x%*2
            x% = x% - 1
            Error% = Error% - dx%

        ENDIF

        ' there it around the screen and not ums Plotten goes,
        ' can The others Oktanten here with unroof:
        Gosub "DrawPixels"

    ENDWHILE

    RETURN
    DrawPixels:
    SETPIXEL xmittel%+x%, ymittel%+y%,c%
    SETPIXEL xmittel%-x%, ymittel%+y%,c%
    SETPIXEL xmittel%-x%, ymittel%-y%,c%
    SETPIXEL xmittel%+x%, ymittel%-y%,c%
    SETPIXEL xmittel%+y%, ymittel%+x%,c%
    SETPIXEL xmittel%-y%, ymittel%+x%,c%
    SETPIXEL xmittel%-y%, ymittel%-x%,c%
    SETPIXEL xmittel%+y%, ymittel%-x%,c%
    Return

ENDPROC

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

571 Views

Untitledvor 0 min.
Hans Neff01/24/23
Stringray01/05/22
N.Art07/23/21
Glubbfan06/19/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