Author Topic: Write with line light  (Read 179 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Forum Resident
  • Posts: 6664
  • b = b + ...
Write with line light
« on: May 04, 2021, 12:06:12 PM »
Code: QB64: [Select]
  1. _Title "Write with light line" 'b+ 2021-05-04
  2. ' from "Random light line" 'b+ 2020-01-28
  3.  
  4. Const xmax = 1200, ymax = 700
  5. Screen _NewImage(xmax, ymax, 32)
  6.  
  7. wandsi 0, 0, 0, 0, 1, 0
  8. While _KeyDown(27) = 0
  9.     If InKey$ = " " Then Cls
  10.     mx = _MouseX: my = _MouseY: mb = _MouseButton(1)
  11.     If mb Then
  12.         a = a + _Pi(1 / 45)
  13.         wandsi mx, my, a, 20, 0, i
  14.     End If
  15.     lastmx = mx: lastmy = my
  16.     i = i + 1
  17.     _Display
  18.     _Limit 3000
  19.  
  20. 'draw a colorful line from point x, y, at radianAngle for a distance and use new <> 0 to reset colors
  21. Sub wandsi (x1 As Single, y1 As Single, radianAngle As Single, distance As Single, new As Integer, startIdx As Integer)
  22.     Static r As Single, g As Single, b As Single 'hold present color settings until
  23.     If new <> 0 Then r = Rnd * Rnd * .5: g = Rnd * Rnd * .5: b = Rnd * Rnd * .5 'new is true
  24.     Dim dx As Single, dy As Single, i As Integer, x As Single, y As Single
  25.     dx = Cos(radianAngle): dy = Sin(radianAngle)
  26.     For i = 0 To distance
  27.         x = x1 + i * dx: y = y1 + i * dy
  28.         Line (x, y)-Step(0, 0), _RGB32(127 + 127 * Sin(r * (i + startIdx)), 127 + 127 * Sin(g * (i + startIdx)), 127 + 127 * Sin(b * (i + startIdx)), 50), BF
  29.     Next
  30.  
  31.  
  32.  


Offline SierraKen

  • Forum Resident
  • Posts: 1334
Re: Write with line light
« Reply #1 on: May 04, 2021, 05:37:24 PM »
Pretty cool B+. :)

Offline Ashish

  • Forum Resident
  • Posts: 665
  • Never Give Up!
Re: Write with line light
« Reply #2 on: May 05, 2021, 02:45:48 AM »
 
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline _vince

  • Seasoned Forum Regular
  • Posts: 345
Re: Write with line light
« Reply #3 on: May 05, 2021, 02:52:01 AM »

Offline bplus

  • Forum Resident
  • Posts: 6664
  • b = b + ...
Re: Write with line light
« Reply #4 on: May 05, 2021, 02:27:47 PM »
Nice, but Ashishh wins:  https://www.qb64.org/forum/index.php?topic=3266.0

Ha! I'll try harder next time, actually I was just going for a new way to note the day!

Thanks Ken and Ashish.

Offline Dav

  • Forum Resident
  • Posts: 607
Re: Write with line light
« Reply #5 on: May 06, 2021, 11:53:28 AM »
Neat one, @bplus!  I sure like playing around with unique drawing tools.  Thanks for sharing.

- Dav

 

Offline bplus

  • Forum Resident
  • Posts: 6664
  • b = b + ...
Re: Write with line light
« Reply #6 on: May 06, 2021, 12:01:10 PM »
Hey Dav's back! :)