-- Adjustable Horizontal Mirror
--@TBCONFIG SLIDER: Horizon Point, 50.0

if sliderVal1 == 0 or sliderVal1 == 1.0 then
  return
end 

mirrorHorizon = (height - 1) * sliderVal1
mirroredYInc = ((height - 1) - mirrorHorizon) / mirrorHorizon
mirroredY = height - 1

for y = 0, mirrorHorizon do
  for x = 0, width - 1 do
    local y2 = 0
    local r, g, b, a = get_rgba(x, y)
    set_rgba(x, y, r, g, b, a)
    for y2 = mirroredY, mirroredY - mirroredYInc, -1 do
      set_rgba(x, y2, r, g, b, a)
    end 
  end
  mirroredY = mirroredY - mirroredYInc
end
