Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ugh. Is my math (and logic) right?
#11
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/BASICAnywhereMa...the_works/
Reply
#12
"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
```
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  random maze map. math help pmackay 4 553 08-10-2025, 11:22 AM
Last Post: pmackay
  Is my Logic wrong or QB64's ? bplus 10 2,149 10-15-2023, 09:04 PM
Last Post: James D Jarvis
  Compiler setting for accurate math? James D Jarvis 12 2,443 12-01-2022, 10:16 PM
Last Post: Pete
  Any math experts know what I'm missing here? [Solved] Pete 24 4,090 09-26-2022, 07:00 PM
Last Post: Kernelpanic

Forum Jump:


Users browsing this thread: 1 Guest(s)