QB64 Phoenix Edition
Ugh. Is my math (and logic) right? - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: Ugh. Is my math (and logic) right? (/showthread.php?tid=1944)

Pages: 1 2


RE: Ugh. Is my math (and logic) right? - CharlieJV - 08-29-2023

Hey, thanks for the help!

I wound up going back to the approach in the OP.  For the moment.  I'm on the fence.

All of this to put together an "RgbaLine" statement.

https://www.reddit.com/r/BASICAnywhereMachine/comments/1648qp9/rgbaline_statement_in_the_works/


RE: Ugh. Is my math (and logic) right? - bplus - 08-29-2023

"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
```