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
b = b + ...
Reply


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



Users browsing this thread: 5 Guest(s)