function blend(a, b, c) return b*c+a*(1-c) end return function() w, h = w or 200, h or 200 -- keep default width/height if supplied sw = math.random(10, w-15) sh = math.random(5, h-15) x1 = math.random(5, w-sw-5) y1 = math.random(5, h-sh-5) pixels = {} for i=1, w*h do pixels[i] = -1 end mx = math.floor(x1+sw/2+0.5) for y=y1, y1+sh-1 do ww = math.floor(blend(1, sw/2, (y-y1)/sh)+0.5) for x=mx-ww, mx+ww-1 do pixels[y*w+x+1] = 0 end end end