| |
|
|
p.specht
| XProfan-11 Demo-Umsetzung des Xiaolin Wu - Antialiasing-Algorithmus
... desafortunadamente todavía con un leichten Bug, aber el Principio se zumindest deutlich! Um en vernünftiger Geschwindigkeit a laufen, debería en el Praxis el Canal Alfa-Blending-Eigenschaft moderner Grafikkarten genutzt voluntad!
Título de la ventana "Antialiased Line (Xiaolin Wu-Algorithmus)"
'Q: https://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm
'S: https://rosettacode.org/wiki/Xiaolin_Wu%27s_line_algorithm#BBC_BASIC
Ventana de Estilo 24
Ventana 0,0-%maxx,%maxy
screen width(%hwnd)\5,height(%hwnd)\5
set("Truecolor",0)
cls rgb(255,255,180)
drawAntiAliasedLine(20,20, 50,100, 255,0,0)
screen width(%hwnd),height(%hwnd)
Waitinput
FIN
Proc drawAntiAliasedLine
parámetros x1!,y1& , x2&,y2&, r%,g%,b%
declarar tmp&, dx&,dy&, xend&,yend!, grad!,yf!,xgap!, ix1%,iy1%, ix2%,iy2%, x%
dx& = x2& - x1!
dy& = y2& - y1&
IF ABS(dx&) < ABS(dy&)
tmp&=x1!:x1!=y1&:y1&=tmp&
tmp&=x2&:x2&=y2&:y2&=tmp&
tmp&=dx&:dx&=dy&:dy&=tmp&
ENDIF
IF x2& < x1!
tmp&=x1!:x1!=x2&:x2&=tmp&
tmp&=y1&:y1&=y2&:y2&=tmp&
ENDIF
grad! = dy& / dx&
xend& = INT(x1! + 0.5)
yend! = y1& + grad! * (xend& - x1!)
xgap! = xend& + 0.5 - x1!
ix1% = xend&
iy1% = INT(yend!)
plot(ix1%, iy1%, r%,g%,b%, (INT(yend!) + 1 - yend!) * xgap!)
plot(ix1%, iy1% + 1, r%,g%,b%, (yend! - INT(yend!)) * xgap!)
yf! = yend! + grad!
xend& = INT(x2& + 0.5)
yend! = y2& + grad! * (xend& - x2&)
xgap! = x2& + 0.5 - xend&
ix2% = xend&
iy2% = INT(yend!)
plot(ix2%,iy2%, r%,g%,b%,(INT(yend!) + 1 - yend!) * xgap!)
plot(ix2%,iy2%+1, r%,g%,b%,(yend! - INT(yend!)) * xgap!)
Whileloop ix1%+1,ix2%-1 : x%=&Loop
plot(x%, INT(yf!), r%,g%,b%, INT(yf!) + 1 - yf!)'RGBA-Formato
plot(x%, INT(yf!)+1, r%,g%,b%, yf!-INT(yf!))
yf!=yf!+grad!
Endwhile
ENDPROC
Proc plot : parámetros X%,Y%, R%,G%,B%, A!
var C% = GetPixel(X%*2,Y%*2)
'imprimir int(1000*A!);
USEPEN 0,2, R%*(1-a!) + ( C% AND 255)*a!, \
G%*(1-a!) + ((C%>>8) AND 255)*a!, \
B%*(1-a!) + ((C%>>16) AND 255)*a!
'MODE "OR" wäre nachzubauen
LINE X%*2,Y%*2 - X%*2,Y%*2
ENDPROC
|
|
|
| XProfan 11Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 28.05.2021 ▲ |
|
|
|