English
Source / code snippets

Bresenham-Linienalgorithmus

 

p.specht


'Base XProfan11.2a free of https://XProfan.de/start.htm
Windowtitle "BRESENHAM-Algorithmus"
'Schnarch-slow, only for Lernzwecke geproggd of P. woodpecker
Windowstyle 31
Window %maxx*.81,%maxy*.81
Cls @Rgb(221,221,221)
var w%=@width(%hWnd)/2
var h%=@height(%hWnd)/2
brline(0,0, 2*w%,2*h%, @rgb(255,0,0))
brline(0,1, w%-1,2*h%, @rgb(0,255,0))
brline(3,0, 2*w%,h%-3, @rgb(0,0,255))
var i%=0
var j!=0

while i%<360

    j!=i%*@pi()/180
    brline(w%,h%,w%+240*cos(j!),h%+240*sin(j!),46603*i%)
    inc i%,1

endwhile

Print "OK, with LINE instead of Einzelpixel settle wär´s faster gone..."
WaitInput
End

proc brline

    ' Bresenham-Algorithmus for Line in beliebigem Oktanten
    parameters xstart%,ystart%,xend%,yend%,c%
    declare i%,el%,pdx%,pdy%,ddx%,ddy%,it%,Error%
    var x% = xstart%
    var y% = ystart%
    var dx% = xend%-xstart%
    var dy% = yend%-ystart%
    var adx% = ABS(dx%)
    var ady% = ABS(dy%)' Absolutbetraege
    var sdx% = int((dx%>0)-(dx%<0))' Signum-function
    var sdy% = int((dy%>0)-(dy%<0))

    IF adx% > ady%

        pdx% = sdx%
        pdy% = 0
        ddx% = sdx%
        ddy% = sdy%
        it%  = ady%
        el%  = adx%

    ELSE

        pdx% = 0
        pdy% = sdy%
        ddx% = sdx%
        ddy% = sdy%
        it%  = adx%
        el%  = ady%

    ENDIF

    Error% = el%/2' el% gives too Number of To zeichnenden Pixel on
    i%=1

    while i% <= el%

        Error% = Error% - it%

        IF Error% < 0

            Error% = Error% + el%
            x% = x% + ddx%
            y% = y% + ddy%

        ELSE

            x% = x% + pdx%
            y% = y% + pdy%

        ENDIF

        SETPIXEL x%,y%, x%*y%*3' or c%, would Punktfarbe
        inc i%

    endwhile

endproc

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

607 Views

Untitledvor 0 min.
Hans Neff01/24/23
N.Art07/23/21
Glubbfan06/19/21
Uwe ''Pascal'' Niemeier06/13/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