#https://www.shadertoy.com/view/MslGD8

pixels = W:1024 H:1024

x = from -5.0 to 5.0 W
y = from -5.0 to 5.0 H

nx = floor(x)
ny = floor(y)
fx = fract(x)
fy = fract(y)

gx = -1
gy = -1
ox = iq_hash2(nx+gx, ny + gy)
oy = iq_hash2(nx+gx+13, ny+gy+51)
tx = gx - fx + ox
ty = gy - fy + oy
f = length2(tx, ty)

gx = -1
gy = 0
ox = iq_hash2(nx+gx, ny + gy)
oy = iq_hash2(nx+gx+13, ny+gy+51)
tx = gx - fx + ox
ty = gy - fy + oy
f = min(f, length2(tx, ty))

gx = -1
gy = 1
ox = iq_hash2(nx+gx, ny + gy)
oy = iq_hash2(nx+gx+13, ny+gy+51)
tx = gx - fx + ox
ty = gy - fy + oy
f = min(f, length2(tx, ty))


gx = 0
gy = -1
ox = iq_hash2(nx+gx, ny + gy)
oy = iq_hash2(nx+gx+13, ny+gy+51)
tx = gx - fx + ox
ty = gy - fy + oy
f = min(f, length2(tx, ty))

gx = 0
gy = 0
ox = iq_hash2(nx+gx, ny + gy)
oy = iq_hash2(nx+gx+13, ny+gy+51)
tx = gx - fx + ox
ty = gy - fy + oy
f = min(f, length2(tx, ty))

gx = 0
gy = 1
ox = iq_hash2(nx+gx, ny + gy)
oy = iq_hash2(nx+gx+13, ny+gy+51)
tx = gx - fx + ox
ty = gy - fy + oy
f = min(f, length2(tx, ty))


gx = 1
gy = -1
ox = iq_hash2(nx+gx, ny + gy)
oy = iq_hash2(nx+gx+13, ny+gy+51)
tx = gx - fx + ox
ty = gy - fy + oy
f = min(f, length2(tx, ty))

gx = 1
gy = 0
ox = iq_hash2(nx+gx, ny + gy)
oy = iq_hash2(nx+gx+13, ny+gy+51)
tx = gx - fx + ox
ty = gy - fy + oy
f = min(f, length2(tx, ty))

gx = 1
gy = 1
ox = iq_hash2(nx+gx, ny + gy)
oy = iq_hash2(nx+gx+13, ny+gy+51)
tx = gx - fx + ox
ty = gy - fy + oy
f = min(f, length2(tx, ty))

r = f
g = f
b = f
