local assets = {
  textbox_click = {
    id = 12,
    content = "coroutine.resume(self.textcor,\"typeit\")",
    name = "textbox_click",
  },
  [ "slider.lua" ] = {
    id = 3,
    content = "self.val = 0\
local w,h = term.getSize()\
function render()\
    term.setBackgroundColor(colors.white)\
    term.clear()\
    term.setCursorPos(1,1)\
    term.setBackgroundColor(colors.lightGray)\
    term.setTextColor(colors.white)\
    term.write(\"\\17\")\
    term.setBackgroundColor(colors.white)\
    term.setTextColor(colors.black)\
    term.write(tostring(self.val))\
    term.setCursorPos(w,1)\
    term.setBackgroundColor(colors.lightGray)\
    term.setTextColor(colors.white)\
    term.write(\"\\16\")\
end\
render()\
while true do\
    e = {os.pullEvent()}\
    if e[1] == \"mouse_click\" then\
        if e[4] == 1 and e[3] == 1 and self.val > 0 then\
            self.val = self.val-1\
            render()\
        elseif e[4] == 1 and e[3] == w and self.val < tonumber(string.rep(\"9\",w-2)) then\
            self.val = self.val+1\
            render()\
        end\
    end\
end",
    name = "slider.lua",
  },
  [ "load.lua" ] = {
    id = 15,
    content = "local s = shapescape.getSlide()\
function s.var.load()\
    if s.var.filepath and s.var.filepath[1] and fs.exists(s.var.filepath[1]) then\
        local cvs = textutils.unserialize((lUtils.fread(s.var.filepath[1])))\
        if cvs then\
            s.var.cvs = cvs\
        else\
            self.color = colors.red\
            self.border.color = colors.orange\
            self.render()\
            os.sleep(1)\
            self.color = colors.green\
            self.border.color = colors.lime\
        end\
    else\
        self.color = colors.red\
        self.border.color = colors.orange\
        self.render()\
        os.sleep(1)\
        self.color = colors.green\
        self.border.color = colors.lime\
    end\
end\
s.var.load()",
    name = "load.lua",
  },
  [ "debug.lua" ] = {
    id = 6,
    content = "local s = shapescape.getSlide()\
_G.cDebug = s\
while true do\
    term.setBackgroundColor(colors.black)\
    term.setTextColor(colors.white)\
    term.clear()\
    term.setCursorPos(1,1)\
    if s.var then\
        --[[for key,value in pairs(s.var) do\
            if type(value) == \"table\" then\
                value = textutils.serialize(value)\
            end\
            print(key..\" = \"..value)\
        end]]\
        if s.var.sprites then\
            print(\"sprites = \"..textutils.serialize(s.var.sprites))\
        else\
            print(\"No sprites.\")\
        end\
    end\
    coroutine.yield()\
end",
    name = "debug.lua",
  },
  tW = {
    id = 7,
    content = "local s = shapescape.getSlide()\
if not s.var then s.var = {} end\
s.var.tW = self.val",
    name = "tW",
  },
  format = {
    id = 17,
    content = "a = {lUtils.clickmenu(self.x2-1,self.y1+1,15,{{\"nfp/nfg\",\"lImg (Mini)\",\"Square\"}})}\
if a[1] then\
    local s = shapescape.getSlide()\
    s.var.format = a[3]\
end",
    name = "format",
  },
  margin = {
    id = 9,
    content = "local s = shapescape.getSlide()\
if not s.var then s.var = {} end\
s.var.margin = self.val",
    name = "margin",
  },
  [ "select.lua" ] = {
    id = 13,
    content = "local s = shapescape.getSlide()\
local fp = lUtils.explorer(\"User\",\"SelFile false\")\
if fp then\
    s.var.filepath[1] = fp\
end",
    name = "select.lua",
  },
  [ "textbox.lua" ] = {
    id = 1,
    content = "function doUpdate()\
    if not self then\
        self = {x1=1,x2=10,y1=1,y2=3}\
    end\
    if self.textcor == nil then\
        self.textbox = lUtils.makeEditBox(\"\",((self.x2-1)-(self.x1+1))+1,((self.y2-1)-(self.y1+1))+1)\
        local s = shapescape.getSlide()\
        if not s.var then s.var = {} end\
        s.var.filepath = self.textbox.lines\
        self.textcor = coroutine.create(function() while true do e = {os.pullEvent()} if e[1] == \"typeit\" then lUtils.drawEditBox(self.textbox,self.x1+1,self.y1+1,nil,nil,nil,nil,true,false) else lUtils.drawEditBox(self.textbox,self.x1+1,self.y1+1,nil,nil,nil,nil,false) end end end)\
    end\
    self.textbox.width,self.textbox.height = ((self.x2-1)-(self.x1+1)+1),((self.y2-1)-(self.y1+1)+1)\
    self.textbox.x = self.x1+1\
    self.textbox.y = self.y1+1\
    if not shapescape then\
        shapescape = {getEvent = os.pullEvent}\
    end\
    coroutine.resume(self.textcor,shapescape.getEvent())\
end\
ok,err = pcall(doUpdate)\
if not ok then\
    term.setCursorPos(1,1)\
    print(err)\
    os.sleep(1)\
end",
    name = "textbox.lua",
  },
  [ "export.lua" ] = {
    id = 18,
    content = "-- ok\
--popup for filepath pls\
local fp,success,_,button = lUtils.inputbox(\"Save\",\"Filepath to export to:\",29,9,{\"Confirm\",\"Cancel\"})\
if success and button == \"Confirm\" and fp ~= \"\" then\
    local spr = {}\
    local s = shapescape.getSlide()\
    for t=1,#s.var.sprites do\
        spr[t] = s.var.render(s.var.sprites[t])\
    end\
    --spr.type = s.var.format\
    if lUtils.getFileType(fp) == \"\" then\
        if s.var.format == \"nfp/nfg\" then\
            if #s.var.sprites > 1 then\
                fp = fp..\".nfg\"\
                spr.type = \"nfg\"\
            else\
                fp = fp..\".nfp\"\
                spr = spr[1]\
            end\
        elseif s.var.format == \"lImg (Mini)\" then\
            fp = fp..\".limg\"\
            spr.type = \"lImg\"\
        else\
            return false\
        end\
    end\
    if type(spr) == \"table\" then\
        lUtils.asset.save(spr,fp)\
    else\
        lUtils.fwrite(fp,spr)\
    end\
    lUtils.popup(\"Save\",\"Successfully exported to \"..fp..\".\",29,9,{\"OK\"})\
end",
    name = "export.lua",
  },
  y = {
    id = 11,
    content = "local s = shapescape.getSlide()\
if not s.var then s.var = {} end\
s.var.y = self.val",
    name = "y",
  },
  x = {
    id = 10,
    content = "local s = shapescape.getSlide()\
if not s.var then s.var = {} end\
s.var.x = self.val",
    name = "x",
  },
  tH = {
    id = 8,
    content = "local s = shapescape.getSlide()\
if not s.var then s.var = {} end\
s.var.tH = self.val",
    name = "tH",
  },
  [ "input.lua" ] = {
    id = 14,
    content = "local s = shapescape.getSlide()\
if not s.var then s.var = {} end\
s.var.sprites = {}\
_G.cDebug = s\
local sprites = s.var.sprites\
local function clear(tbl)\
    for key,val in pairs(tbl) do\
        tbl[key] = nil\
    end\
end\
local cvs\
local mode = 1 -- for debug, usually starts at 0\
local function render()\
    clear(sprites)\
    if s.var.cvs then\
        cvs = s.var.cvs\
        term.setBackgroundColor(colors.black)\
        term.clear()\
        term.setCursorPos(1,1)\
        local w,h = term.getSize()\
        local mW,mH = w,h\
        if #cvs > mH then\
            mH = #cvs\
        end\
        for y1=1,mH do\
            local y = y1+s.var.y\
            term.setCursorPos(1,y1)\
            if cvs[y] and not (s.var.tH > 0 and y1 > s.var.tH) then\
                if #cvs[y] > mW then\
                    mW = #cvs[y]\
                end\
                for x1=1,mW do\
                    local x = x1+s.var.x\
                    if cvs[y][x] and not (s.var.tW > 0 and x1 > s.var.tW) then\
                        if cvs[y][x] == 0 then\
                            --term.setBackgroundColor(colors.black)\
                            --term.setTextColor(colors.gray)\
                            if y/2 == math.floor(y/2) then\
                                term.setBackgroundColor(colors.black)\
                                term.setTextColor(colors.gray)\
                            else\
                                term.setBackgroundColor(colors.gray)\
                                term.setTextColor(colors.black)\
                            end\
                            --term.write(\"\\153\")\
                        else\
                            term.setBackgroundColor(cvs[y][x])\
                        end\
                        local grX,grY\
                        if s.var.sW > 0 then\
                            grX = math.ceil(x1/(s.var.sW+s.var.margin))\
                        else\
                            grX = 1\
                        end\
                        if s.var.sH > 0 then\
                            grY = math.ceil(y1/(s.var.sH+s.var.margin))\
                        else\
                            grY = 1\
                        end\
                        local margin = false\
                        for m=1,s.var.margin do\
                            if x1 == (s.var.sW+s.var.margin)*grX-(m-1) then\
                                margin = true\
                            elseif y1 == (s.var.sH+s.var.margin)*grY-(m-1) then\
                                margin = true\
                            end\
                        end\
                        if margin then\
                            term.setTextColor(colors.red)\
                            term.write(\"\\127\")\
                        else\
                            local spr\
                            if s.var.tW > 0 and s.var.tH > 0 then\
                                spr = (grY-1)*math.ceil(s.var.tW/(s.var.sH+s.var.margin))+grX\
                            else\
                                spr = 1\
                            end\
                            if not sprites[spr] then\
                                sprites[spr] = {}\
                            end\
                            local c\
                            if cvs[y][x] == 0 then\
                                c = \"T\"\
                            else\
                                c = lUtils.toBlit(cvs[y][x])\
                            end\
                            if s.var.tW > 0 and s.var.tH > 0 then\
                                local num = math.mod(y1,s.var.sH+s.var.margin)\
                                if num == 0 then\
                                    num = s.var.sH+s.var.margin\
                                end\
                                if not sprites[spr][num] then\
                                    sprites[spr][num] = c\
                                else\
                                    sprites[spr][num] = sprites[spr][num]..c\
                                end\
                            else\
                                if not sprites[spr][y1] then\
                                    sprites[spr][y1] = c\
                                else\
                                    sprites[spr][y1] = sprites[spr][y1]..c\
                                end\
                            end\
    	                       if mode == 1 and ((grX/2 == math.floor(grX/2) and grY/2 == math.floor(grY/2)) or (grX/2 ~= math.floor(grX/2) and grY/2 ~= math.floor(grY/2))) then\
    	                           term.setTextColor(colors.blue)\
    	                           term.write(\"\\7\")\
    	                       elseif cvs[y][x] == 0 then\
    	                           term.write(\"\\153\")\
    	                       else\
    	                           term.write(\" \")\
    	                       end\
	                       end\
                    else\
                        if y/2 == math.floor(y/2) then\
                            term.setBackgroundColor(colors.gray)\
                            term.setTextColor(colors.red)\
                        else\
                            term.setBackgroundColor(colors.red)\
                            term.setTextColor(colors.gray)\
                        end\
                        term.write(\"\\153\")\
                    end\
                end\
            else\
                if y/2 == math.floor(y/2) then\
                    term.setBackgroundColor(colors.gray)\
                    term.setTextColor(colors.red)\
                else\
                    term.setBackgroundColor(colors.red)\
                    term.setTextColor(colors.gray)\
                end\
                term.write(string.rep(\"\\153\",w))\
            end\
        end\
        --term.setCursorPos(2,2)\
        --term.setTextColor(colors.white)\
        --bigfont.hugeWrite(\"1\")\
    end\
end\
while true do\
    ok,err = pcall(render)\
    if not ok then\
        term.setTextColor(colors.red)\
        term.setBackgroundColor(colors.black)\
        term.setCursorPos(1,1)\
        print(err)\
        os.sleep(5)\
    end\
    --mode = 0\
    local e = {os.pullEvent()}\
end",
    name = "input.lua",
  },
  [ "textbox_mouse.lua" ] = {
    id = 2,
    content = "coroutine.resume(self.textbox,\"typeit\")",
    name = "textbox_mouse.lua",
  },
  sW = {
    id = 4,
    content = "local s = shapescape.getSlide()\
if not s.var then s.var = {} end\
s.var.sW = self.val",
    name = "sW",
  },
  [ "output.lua" ] = {
    id = 16,
    content = "print(\"Loading...\")\
local s\
if shapescape then\
    s = shapescape.getSlide()\
else\
    s = {}\
end\
function s.sleep(t)\
    local sTime = os.epoch(\"local\")/1000\
    os.startTimer(t)\
    while true do\
        e = {os.pullEvent()}\
        if os.epoch(\"local\")/1000 >= sTime+t then\
            break\
        end\
    end\
end\
local sleep = s.sleep\
if not s.var then s.var = {} end\
s.var.format = \"nfp/nfg\"\
function s.var.render(spr)\
    term.setBackgroundColor(colors.black)\
    term.clear()\
    term.setCursorPos(1,1)\
    if s.var.format == \"nfp/nfg\" then\
        local tSprite = \"\"\
        for t=1,#spr do\
            local len = #spr[t]\
            term.setCursorPos(1,t)\
            term.blit(string.rep(\" \",len),string.rep(\"0\",len),spr[t])\
            if t > 1 then\
                tSprite = tSprite..\"\\n\"\
            end\
            tSprite = tSprite..string.gsub(spr[t],\"T\",\" \")\
        end\
        return tSprite\
    elseif s.var.format == \"lImg (Mini)\" then\
        --local tSprite = {}\
        --tSprite[1] = {}\
        --local pixels = tSprite[1]\
        --local pix = 1\
        if stupid then\
            for l=1,#spr do\
                if not pixels[pix] then pixels[pix] = {} end\
                if #pixels[pix] >= 3 then\
                    pix = pix+1\
                end\
                pixels[pix][#pixels[pix]+1] = {}\
                local pixel = pixels[pix][#pixels[pix]]\
                for c=1,#spr[l] do\
                    local t = math.ceil(c/2)\
                    if not pixel[t] then\
                        pixel[t] = {}\
                    end\
                    local ch\
                    local str = string.sub(spr[l],c,c)\
                    if str == \"T\" or str == \" \" then\
                        ch = false\
                    else\
                        ch = str\
                    end\
                    pixel[t][#pixel[t]+1] = ch\
                end\
            end\
        end\
        local tSprite = {}\
        local function tc(char,num)\
            if not char then\
                return false\
            end\
            local ch = string.sub(char,num,num)\
            if ch == \"T\" or ch == \" \" then\
                return false\
            else\
                return ch\
            end\
        end\
        local function max(tbl)\
            local m = {}\
            for key,value in pairs(tbl) do\
                if not m[1] and not m[2] then\
                    m[1] = key\
                elseif not m[2] then\
                    if value > tbl[m[1]] then\
                        table.insert(m,1,key)\
                    else\
                        m[2] = key\
                    end\
                elseif value > tbl[m[1]] then\
                    table.insert(m,1,key)\
                    m[3] = nil\
                elseif value > tbl[m[2]] then\
                    m[2] = key\
                end\
            end\
            return m\
        end\
        for l=1,#spr,3 do\
            tSprite[math.ceil(l/3)] = {\"\",\"\",\"\"}\
            local line = tSprite[math.ceil(l/3)]\
            for c=1,#spr[l],2 do\
                local s1 = spr[l]\
                local s2 = spr[l+1]\
                local s3 = spr[l+2]\
                local pix = {tc(s1,c),tc(s1,c+1),tc(s2,c),tc(s2,c+1),tc(s3,c),tc(s3,c+1)}\
                local cols = {[\"T\"]=0}\
                for t=1,#pix do\
                    if pix[t] == false or pix[t] == \"\" then\
                        cols[\"T\"] = cols[\"T\"]+1\
                    else\
                        if not cols[pix[t]] then\
                            cols[pix[t]] = 0\
                        end\
                        cols[pix[t]] = cols[pix[t]]+1\
                    end\
                end\
                local color = max(cols)\
                if not color[1] then\
                    color[1] = \"T\"\
                end\
                if #color == 1 then\
                    color[2] = color[1]\
                end\
                for t=1,#pix do\
                    if pix[t] == false then\
                        pix[t] = \"T\"\
                    end\
                    if pix[t] == color[2] then\
                        pix[t] = false\
                    else\
                        pix[t] = true\
                    end\
                end\
                local p = lUtils.getDrawingCharacter(unpack(pix))\
                line[1] = line[1]..p.char\
                if p.inverted then\
                    color[1],color[2] = color[2],color[1]\
                end\
                if not color[1] or not color[2] then\
                    error(textutils.serialize(color))\
                end\
                line[2] = line[2]..color[1]\
                line[3] = line[3]..color[2]\
            end\
        end\
        cDebug.tSprite = tSprite\
        term.setCursorPos(1,1)\
        for t=1,#tSprite do\
            term.setCursorPos(1,t)\
            local bl = {}\
            bl[1] = tSprite[t][1]\
            bl[2] = string.gsub(tSprite[t][2],\"T\",lUtils.toBlit(term.getBackgroundColor()))\
            bl[3] = string.gsub(tSprite[t][3],\"T\",lUtils.toBlit(term.getBackgroundColor()))\
            --print(textutils.serialize(bl))\
            term.blit(unpack(bl))\
        end\
        return tSprite\
    else\
        term.setTextColor(colors.red)\
        print(\"This format is not supported yet.\")\
    end\
end\
local render = s.var.render\
local sl = 0\
if not s.var.sprites then\
    term.clear(1,1)\
    term.setCursorPos(1,1)\
    term.setTextColor(colors.red)\
    print(\"No sprite loaded.\")\
end\
while not s.var.sprites do\
    sleep(1)\
    term.setCursorPos(1,2)\
    term.clearLine()\
    term.setCursorPos(1,2)\
    if s.var.sprites ~= nil then\
        break\
    end\
    print(s.var.sprites)\
end\
while true do\
    sl = sl+1\
    if s.var.sprites[sl] == nil then\
        sl = 1\
    end\
    if s.var.sprites[sl] ~= nil then\
        ok,err = pcall(render,s.var.sprites[sl])\
        if not ok then\
            term.setTextColor(colors.red)\
            term.setBackgroundColor(colors.black)\
            term.clear()\
            term.setCursorPos(1,1)\
            term.write(err)\
            sleep(3)\
        end\
        sleep(0.1)\
    else\
        term.clear()\
        term.setCursorPos(1,1)\
        term.setTextColor(colors.red)\
        print(\"No sprite loaded.\")\
        sleep(1)\
    end\
end",
    name = "output.lua",
  },
  sH = {
    id = 5,
    content = "local s = shapescape.getSlide()\
if not s.var then s.var = {} end\
s.var.sH = self.val",
    name = "sH",
  },
}

local nAssets = {}
for key,value in pairs(assets) do nAssets[key] = value nAssets[assets[key].id] = assets[key] end
assets = nAssets
nAssets = nil

local slides = {
  {
    y = 21,
    x = 61,
    h = 19,
    w = 51,
    objs = {
      {
        type = "rect",
        color = 128,
        y2 = 19,
        border = {
          color = 0,
          type = 1,
        },
        x1 = 1,
        y1 = 1,
        ox2 = 0,
        x2 = 51,
        oy2 = 0,
        snap = {
          Top = "Snap top",
          Right = "Snap right",
          Left = "Snap left",
          Bottom = "Snap bottom",
        },
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
      },
      {
        x2 = 12,
        y2 = 2,
        y1 = 2,
        x1 = 3,
        txt = "Input",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        txtcolor = 1,
        input = false,
        border = {
          color = 0,
          type = 1,
        },
        snap = {
          Top = "Snap top",
          Right = "Snap left",
          Left = "Snap left",
          Bottom = "Snap top",
        },
        color = 128,
      },
      {
        x2 = 30,
        y2 = 2,
        x1 = 22,
        ox1 = 4,
        txt = "Filepath",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        txtcolor = 1,
        ox2 = -4,
        border = {
          color = 0,
          type = 1,
        },
        input = false,
        color = 0,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        y1 = 2,
      },
      {
        type = "rect",
        x2 = 41,
        y2 = 6,
        y1 = 4,
        x1 = 22,
        border = {
          color = 32768,
          type = 1,
        },
        ox2 = 10,
        color = 1,
        ox1 = 4,
        snap = {
          Top = "Snap top",
          Right = "Snap right",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        event = {
          mouse_up = {
            [ 2 ] = 12,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = 1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
      },
      {
        color = 8192,
        y2 = 6,
        x1 = 44,
        ox1 = 7,
        txt = "Load",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = 15,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        txtcolor = 1,
        ox2 = 2,
        border = {
          color = 32,
          type = 1,
        },
        input = false,
        x2 = 49,
        snap = {
          Top = "Snap top",
          Right = "Snap right",
          Left = "Snap right",
          Bottom = "Snap top",
        },
        y1 = 4,
      },
      {
        color = 32768,
        y2 = 17,
        border = {
          color = 0,
          type = 1,
        },
        x1 = 3,
        oy1 = -5,
        type = "window",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = 16,
          },
        },
        ox2 = 7,
        y1 = 15,
        x2 = 19,
        snap = {
          Top = "Snap center",
          Right = "Snap center",
          Left = "Snap left",
          Bottom = "Snap bottom",
        },
        oy2 = 2,
      },
      {
        color = 0,
        y2 = 13,
        x1 = 3,
        oy1 = -3,
        txt = "Output",
        type = "text",
        oy2 = -3,
        txtcolor = 1,
        y1 = 13,
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        input = false,
        x2 = 12,
        snap = {
          Top = "Snap center",
          Right = "Snap left",
          Left = "Snap left",
          Bottom = "Snap center",
        },
        border = {
          color = 0,
          type = 1,
        },
      },
      {
        type = "window",
        y1 = 10,
        color = 32768,
        y2 = 10,
        border = {
          color = 0,
          type = 1,
        },
        x1 = 25,
        ox2 = -2,
        x2 = 28,
        ox1 = 1,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = 4,
          },
          Coroutine = {
            [ 2 ] = 3,
          },
        },
      },
      {
        color = 0,
        y2 = 8,
        x1 = 22,
        ox1 = 4,
        txt = "Sprite size",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        ox2 = -6,
        border = {
          color = 0,
          type = 1,
        },
        txtcolor = 1,
        input = false,
        x2 = 32,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        y1 = 8,
      },
      {
        color = 0,
        y2 = 10,
        x1 = 22,
        ox1 = 4,
        txt = "w:",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        ox2 = 3,
        border = {
          color = 0,
          type = 1,
        },
        txtcolor = 1,
        input = false,
        x2 = 23,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        y1 = 10,
      },
      {
        type = "window",
        y1 = 12,
        color = 32768,
        y2 = 12,
        border = {
          color = 0,
          type = 1,
        },
        x1 = 25,
        ox2 = -2,
        x2 = 28,
        ox1 = 1,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = 5,
          },
          Coroutine = {
            [ 2 ] = 3,
          },
        },
      },
      {
        x2 = 23,
        y2 = 12,
        x1 = 22,
        ox1 = 4,
        txt = "h:",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        ox2 = 3,
        y1 = 12,
        txtcolor = 1,
        input = false,
        color = 0,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        border = {
          color = 0,
          type = 1,
        },
      },
      {
        type = "window",
        y1 = 10,
        color = 32768,
        y2 = 10,
        border = {
          color = 0,
          type = 1,
        },
        x1 = 39,
        ox2 = -17,
        x2 = 43,
        ox1 = -13,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = 7,
          },
          Coroutine = {
            [ 2 ] = 3,
          },
        },
      },
      {
        x2 = 46,
        y2 = 8,
        x1 = 36,
        ox1 = -10,
        txt = "Total size",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        ox2 = -20,
        y1 = 8,
        txtcolor = 1,
        input = false,
        color = 0,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        border = {
          color = 0,
          type = 1,
        },
      },
      {
        x2 = 37,
        y2 = 10,
        x1 = 36,
        ox1 = -10,
        txt = "w:",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        ox2 = -11,
        y1 = 10,
        txtcolor = 1,
        input = false,
        color = 0,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        border = {
          color = 0,
          type = 1,
        },
      },
      {
        color = 0,
        y2 = 12,
        x1 = 36,
        ox1 = -10,
        txt = "h:",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        ox2 = -11,
        border = {
          color = 0,
          type = 1,
        },
        txtcolor = 1,
        input = false,
        x2 = 37,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        y1 = 12,
      },
      {
        type = "window",
        y1 = 12,
        color = 32768,
        y2 = 12,
        border = {
          color = 0,
          type = 1,
        },
        x1 = 39,
        ox2 = -17,
        x2 = 43,
        ox1 = -13,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = 8,
          },
          Coroutine = {
            [ 2 ] = 3,
          },
        },
      },
      {
        x2 = 27,
        y2 = 15,
        x1 = 22,
        ox1 = 4,
        txt = "Margin",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        ox2 = -1,
        y1 = 15,
        txtcolor = 1,
        input = false,
        color = 0,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        border = {
          color = 0,
          type = 1,
        },
      },
      {
        type = "window",
        y1 = 17,
        color = 32768,
        y2 = 17,
        border = {
          color = 0,
          type = 1,
        },
        x1 = 23,
        ox2 = 1,
        x2 = 25,
        ox1 = 3,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = 9,
          },
          Coroutine = {
            [ 2 ] = 3,
          },
        },
      },
      {
        color = 0,
        y2 = 15,
        x1 = 32,
        ox1 = -6,
        txt = "Starting position",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        ox2 = -22,
        border = {
          color = 0,
          type = 1,
        },
        txtcolor = 1,
        input = false,
        x2 = 48,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        y1 = 15,
      },
      {
        type = "window",
        border = {
          color = 0,
          type = 1,
        },
        color = 32768,
        y2 = 17,
        y1 = 17,
        x1 = 35,
        ox2 = -12,
        x2 = 38,
        ox1 = -9,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = 10,
          },
          Coroutine = {
            [ 2 ] = 3,
          },
        },
      },
      {
        color = 0,
        y2 = 17,
        x1 = 32,
        ox1 = -6,
        txt = "x:",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        txtcolor = 1,
        ox2 = -7,
        border = {
          color = 0,
          type = 1,
        },
        input = false,
        x2 = 33,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        y1 = 17,
      },
      {
        x2 = 42,
        y2 = 17,
        x1 = 41,
        ox1 = -15,
        txt = "y:",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        ox2 = -16,
        txtcolor = 1,
        y1 = 17,
        input = false,
        color = 0,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        border = {
          color = 0,
          type = 1,
        },
      },
      {
        type = "window",
        y1 = 17,
        color = 32768,
        y2 = 17,
        border = {
          color = 0,
          type = 1,
        },
        x1 = 44,
        ox2 = -21,
        x2 = 47,
        ox1 = -18,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = 11,
          },
          Coroutine = {
            [ 2 ] = 3,
          },
        },
      },
      {
        type = "window",
        border = {
          color = 0,
          type = 1,
        },
        color = 32768,
        y2 = 11,
        y1 = 4,
        x1 = 3,
        ox2 = 7,
        oy2 = -1,
        x2 = 19,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap left",
          Bottom = "Snap center",
        },
        event = {
          mouse_up = {
            [ 2 ] = -1,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = 14,
          },
        },
      },
      {
        x2 = 38,
        y2 = 2,
        x1 = 31,
        ox1 = -5,
        txt = " Select",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = 13,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        txtcolor = 1,
        ox2 = -12,
        y1 = 2,
        input = false,
        color = 256,
        snap = {
          Top = "Snap top",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap top",
        },
        border = {
          color = 0,
          type = 1,
        },
      },
      {
        color = 0,
        y2 = 13,
        x1 = 12,
        ox1 = 14,
        oy1 = -3,
        txt = "Format ",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = 17,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        ox2 = 7,
        txtcolor = 1,
        border = {
          color = 0,
          type = 1,
        },
        x2 = 19,
        input = false,
        y1 = 13,
        snap = {
          Top = "Snap center",
          Right = "Snap center",
          Left = "Snap center",
          Bottom = "Snap center",
        },
        oy2 = -3,
      },
      {
        x2 = 17,
        y2 = 13,
        x1 = 10,
        oy1 = -3,
        txt = " Export",
        type = "text",
        event = {
          mouse_up = {
            [ 2 ] = 18,
          },
          mouse_click = {
            [ 2 ] = -1,
          },
          Initialize = {
            [ 2 ] = -1,
          },
          selected = {
            [ 2 ] = -1,
          },
          update = {
            [ 2 ] = -1,
          },
          Coroutine = {
            [ 2 ] = -1,
          },
        },
        txtcolor = 1,
        border = {
          color = 0,
          type = 1,
        },
        oy2 = -3,
        input = false,
        color = 2,
        snap = {
          Top = "Snap center",
          Right = "Snap left",
          Left = "Snap left",
          Bottom = "Snap center",
        },
        y1 = 13,
      },
    },
    c = 1,
  },
  {
    y = 21,
    x = 61,
    h = 19,
    w = 51,
    objs = {},
    c = 2,
  },
}

for s=1,#slides do
		local slide = slides[s]
		for o=1,#slide.objs do
			local obj = slide.objs[o]
			for key,value in pairs(obj.event) do
				if assets[ value[2] ] then
					lUtils.shapescape.addScript(obj,value[2],key,assets,LevelOS,slides)
				else
					obj.event[key] = {function() end,-1}
				end
			end
		end
	end

		local tArgs = {...}
	if tArgs[1] and tArgs[1] == "load" then
		return {assets=assets,slides=slides}
	end

	
	lUtils.shapescape.run(slides)