21 lines
654 B
Plaintext
21 lines
654 B
Plaintext
' using Twips
|
|
' twipsX is 15 twips. So for 96 dpi, we have 1440/96=15 twips/pixel
|
|
Module Bresenham_s_line_algorithm {
|
|
Module Br_line(x0 As Long, y0 As Long, x1 As Long, y1 As Long, Col=15) {
|
|
Long dx = Abs(x1 - x0), dy = Abs(y1 - y0)
|
|
Long sx = If(x0 < x1-> TWIPSX, -TWIPSX)
|
|
Long sy = If(y0 < y1-> TWIPSY, -TWIPSY)
|
|
Long er = If(dx > dy-> dx, -dy) div 2, e2
|
|
Do
|
|
PSet col, x0, y0
|
|
If abs(x0-x1)<=TWIPSX And abs(y0-y1)<=TWIPSY Then Exit
|
|
e2 = er
|
|
If e2 > -dx Then Er -= dy : x0 += sx
|
|
If e2 < dy Then Er += dx : y0 += sy
|
|
Always
|
|
}
|
|
cls ,0
|
|
Br_line scale.x*.2, scale.y*.2, scale.x*.8, scale.y*.8 , #FFbb77
|
|
}
|
|
Bresenham_s_line_algorithm
|