-- Mosaic 02
-- Revision 2

--@TBCONFIG SLIDER: Size X, 14
--@TBCONFIG SLIDER: Gap, 2
--@TBCONFIG FLAG: More Rounded, False
--@TBCONFIG INFO: Mosaic 02
--@TBCONFIG INFO: Revision 1
--@TBCONFIG INFO:  
--@TBCONFIG INFO: Creates a rounded tile pattern from an existing image.

stepx = (sliderVal1 * 100) + 1 
stepy = (sliderVal1 * 100) + 1
gapsize = (sliderVal2 * 50) + 2

stepx = stepx - (stepx % 1)
stepy = stepy - (stepy % 1)
gapsize = gapsize - (gapsize % 1)

-- Fill to black
for ix = 0, width - 1 do
  for iy = 0, height - 1 do
    set_rgba(ix, iy, 0, 0, 0, 1.0)
  end
end

for ix = 0, width - 1, stepx + gapsize do
  -- If the Escape key is pressed exit the loop
  if (is_escape() > 0) then
    return
  end

  for iy = 0, height - 1, stepy + gapsize do
    local r, g, b, a  = get_rgba(ix, iy)

    for ix2 = ix, ix + stepx do
      for iy2 = iy, iy + stepy do
        set_rgba(ix2, iy2, r, g, b, a)
      end
	  end
  end
end

flush()

paint_open(0)
paint_filter("Bump",0,500,0,540,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
paint_filter("Anti Alias",0,500,500,1000,1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
if flagVal1 == true then
  paint_filter("Anti Alias",0,500,500,1000,1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
end
paint_close()





