07-12-2023, 12:09 PM
@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
- 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