Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Improved my small Gradient Ball drawing SUB
#13
@bplus you inspired me.  Had to give a Shaded Voronoi a try too.  Studied a few sources online, ended up with this simple version.

- Dav

Code: (Select All)

SCREEN _NEWIMAGE(1000, 600, 32)

DIM SHARED Points: Points = 50
DIM SHARED PointX(Points), PointY(Points), PointR(Points), PointG(Points), PointB(Points)

RANDOMIZE TIMER
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
    FOR y = 0 TO _HEIGHT
        min = SQR((x - PointX(1)) ^ 2 + (y - PointY(1)) ^ 2)
        closest = 1
        FOR p = 2 TO Points
            dis = SQR((x - PointX(p)) ^ 2 + (y - PointY(p)) ^ 2)
            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

SLEEP


Find my programs here in Dav's QB64 Corner
Reply


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



Users browsing this thread: 4 Guest(s)