Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Improved my small Gradient Ball drawing SUB
#14
Hi @Dav that's is interesting alternate calculation. 

We could shave some time:
Code: (Select All)
Screen _NewImage(1000, 600, 32)
DefLng A-Z

Randomize Timer
Do
    Points = Rnd * 70 + 10
    ReDim PointX(Points), PointY(Points), PointR(Points), PointG(Points), PointB(Points)

    For p = 1 To Points
        PointX(p) = Rnd * _Width
        PointY(p) = Rnd * _Height
        PointR(p) = Rnd * 255
        PointG(p) = Rnd * 255
        PointB(p) = Rnd * 255
    Next
    For x = 0 To _Width - 1
        For y = 0 To _Height - 1
            min = _Hypot(x - PointX(1), y - PointY(1))
            closest = 1
            For p = 1 To Points
                dis = _Hypot(x - PointX(p), y - PointY(p))
                If dis < min Then
                    min = dis: closest = p
                End If
            Next
            PSet (x, y), _RGB(PointR(closest) - min, PointG(closest) - min, PointB(closest) - min)
        Next
    Next
    _Display
    _Limit 5
Loop Until _KeyDown(27)
Sleep
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
RE: Improved my small Gradient Ball drawing SUB - by bplus - 07-12-2023, 02:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  A drawing program Frederick 8 534 02-28-2026, 04:45 PM
Last Post: Frederick
  Drawing 20 planets with graphical commands Delsus 9 528 02-08-2026, 01:41 AM
Last Post: ahenry3068
  BallDraw - simple drawing programing using colored balls Dav 2 389 11-11-2025, 08:57 PM
Last Post: Dav
  The Curve statement, an improved Circle 2112 6 685 11-02-2025, 09:45 PM
Last Post: bplus
  Sound Ball SierraKen 0 450 12-17-2024, 11:34 PM
Last Post: SierraKen

Forum Jump:


Users browsing this thread: