pixels = W:1024 H:1024

x = from 0 to 16 W
y = from 0 to 16 H

dx = 0.01
dy = 0.01

ax = x + 0.5*dx
ay = y + 0.5*dy

bx = x - 0.5*dx
by = y - 0.5*dy

n = 3

ix = (floor(ax) + min(fract(ax)*n, 1) - floor(bx) - min(fract(bx)*n, 1)) / dx / n
iy = (floor(ay) + min(fract(ay)*n, 1) - floor(by) - min(fract(by)*n, 1)) / dy / n

r = 1 - ix - iy + 2*ix*iy
g = r
b = r

