Posts: 3,965
Threads: 176
Joined: Apr 2022
Reputation:
219
08-29-2023, 12:26 PM
(This post was last modified: 08-29-2023, 12:35 PM by bplus.)
"Problem solved with a little security (last two lines added to bLine):"
I think if you subst in the first and last i to the pset values you will see the first and last point on line are already covered. Also if you want lines with transparencies doubling on first and last will show the color more like doing a circle fill with circles using alpha colors.
Try the 2 versions using alpha and see.
```Screen _NewImage(800, 600, 32)
Color &H30FFFFFF
For x = 1 To 20
cLine x + 100, 10, x + 100, 500
bLine x + 200, 10, x + 200, 500
Next
Sub cLine (x1, y1, x2, y2)
dx = x2 - x1
dy = y2 - y1
dist = Sqr(dx * dx + dy * dy)
dx = dx / dist
dy = dy / dist
For i = 0 To dist
PSet (x1 + dx * i, y1 + dy * i)
Next
PSet (x1, y1)
PSet (x2, y2)
End Sub
Sub bLine (x1, y1, x2, y2)
dx = x2 - x1
dy = y2 - y1
dist = Sqr(dx * dx + dy * dy)
dx = dx / dist
dy = dy / dist
For i = 0 To dist
PSet (x1 + dx * i, y1 + dy * i)
Next
End Sub
```
b = b + ...