QB64.org Forum

Active Forums => Programs => Topic started by: bplus on May 04, 2021, 12:06:12 pm

Title: Write with line light
Post by: bplus 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.  

Title: Re: Write with line light
Post by: SierraKen on May 04, 2021, 05:37:24 pm
Pretty cool B+. :)
Title: Re: Write with line light
Post by: Ashish on May 05, 2021, 02:45:48 am
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Write with line light
Post by: _vince on May 05, 2021, 02:52:01 am
Nice, but Ashishh wins:  https://www.qb64.org/forum/index.php?topic=3266.0 (https://www.qb64.org/forum/index.php?topic=3266.0)
Title: Re: Write with line light
Post by: bplus on May 05, 2021, 02:27:47 pm
Nice, but Ashishh wins:  https://www.qb64.org/forum/index.php?topic=3266.0 (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.
Title: Re: Write with line light
Post by: Dav on May 06, 2021, 11:53:28 am
Neat one, @bplus!  I sure like playing around with unique drawing tools.  Thanks for sharing.

- Dav

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Write with line light
Post by: bplus on May 06, 2021, 12:01:10 pm
Hey Dav's back! :)