Oeed

Sketch 2

Dec 15th, 2014
474
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 131.21 KB | None | 0 0
  1. --  Hideously Smashed Together by Compilr, a Hideous Smash-Stuff-Togetherer, (c) 2014 oeed  --
  2.  
  3. --  This file REALLLLLLLY isn't suitable to be used for anything other than being executed --
  4.  
  5. --  To extract all the files, run: "<filename> --extract" in the Shell --
  6. local files = {["Icons"]={["nft"]="4f 3bnft\
  7. 3f  d  \
  8. df    ",["nfp"]="4f 3bnfp\
  9. 3f  d  \
  10. df    ",["skch"]="3bskch\
  11. 3f  d  \
  12. df    ",},["icon"]="bf    \
  13. b0Skch\
  14. bf    ",["startup"]="local bedrockPath='/' if OneOS then OneOS.LoadAPI('/System/API/Bedrock.lua', false)elseif fs.exists(bedrockPath..'/Bedrock')then os.loadAPI(bedrockPath..'/Bedrock')else if http then print('Downloading Bedrock...')local h=http.get('http://pastebin.com/raw.php?i=0MgKNqpN')if h then local f=fs.open(bedrockPath..'/Bedrock','w')f.write(h.readAll())f.close()h.close()os.loadAPI(bedrockPath..'/Bedrock')else error('Failed to download Bedrock. Is your internet working?') end else error('This program needs to download Bedrock to work. Please enable HTTP.') end end if Bedrock then Bedrock.BasePath = bedrockPath Bedrock.ProgramPath = shell.getRunningProgram() end\
  15. \
  16. local program = Bedrock:Initialise()\
  17. \
  18. function ViewClick(self, event, side, x, y)\
  19.     if program.DragWindow and event == 'mouse_drag' then\
  20.         program.DragWindow.X = x - program.DragWindow.DragX\
  21.         program.DragWindow.Y = y\
  22.         program.DragWindow:OnWindowDrag(x, y)\
  23.         program.WindowDragTimer = program:StartTimer(function(_,timer)\
  24.             if timer and timer == program.WindowDragTimer then\
  25.                 program.WindowDragTimer = nil\
  26.                 program.DragWindow = nil\
  27.             end\
  28.         end, 0.8)\
  29.     elseif self.Visible and not self.IgnoreClick then\
  30.         for i = #self.Children, 1, -1 do --children are ordered from smallest Z to highest, so this is done in reverse\
  31.             local child = self.Children[i]\
  32.             if self:DoClick(child, event, side, x, y) then\
  33.                 if self.OnChildClick then\
  34.                     self:OnChildClick(child, event, side, x, y)\
  35.                 end\
  36.                 return true\
  37.             end\
  38.         end\
  39.         if event == 'mouse_click' and self.OnClick and self:OnClick(event, side, x, y) ~= false then\
  40.             return true\
  41.         elseif event == 'mouse_drag' and self.OnDrag and self:OnDrag(event, side, x, y) ~= false then\
  42.             return true\
  43.         elseif event == 'mouse_scroll' and self.OnScroll and self:OnScroll(event, side, x, y) ~= false then\
  44.             return true\
  45.         else\
  46.             return false\
  47.         end\
  48.     else\
  49.         return false\
  50.     end\
  51. end\
  52. \
  53. function OpenDocument(path)\
  54.     CloseDocument(function(success)\
  55.         if success then\
  56.             program:RemoveObject('Artboard')\
  57.             local image = ImageIO.LoadDocument(path, program)\
  58.             if image then\
  59.                 program:AddObject({\
  60.                     Type = 'Artboard',\
  61.                     X = program.Helpers.Round((Drawing.Screen.Width - image.Width - 3) / 2),\
  62.                     Y = program.Helpers.Round((Drawing.Screen.Height - image.Height) / 2),\
  63.                     Width = image.Width,\
  64.                     Height = image.Height,\
  65.                     ImageName = image.ImageName,\
  66.                     ImagePath = image.ImagePath,\
  67.                     ImageFormat = image.ImageFormat,\
  68.                     Layers = image.Layers,\
  69.                 })\
  70.             end\
  71.         end\
  72.     end)\
  73. end\
  74. \
  75. function SaveWithFormat(path, format)\
  76.     local err\
  77.     local content\
  78. \
  79.     local artboard = program:GetObject('Artboard')\
  80.     if artboard then\
  81.         format = format:gsub('%.', '')\
  82.         if format == 'skch' then\
  83.             content = textutils.serialize(ImageIO.SaveSKCH(artboard.Layers))\
  84.         elseif format == 'nft' then\
  85.             content = ''\
  86.             local lines = ImageIO.SaveNFT(artboard:GetFlattenedPixels())\
  87.             for i, v in ipairs(lines) do\
  88.                 content = content .. v .. '\\n'\
  89.             end\
  90.         elseif format == 'nfp' then\
  91.             content = ''\
  92.             local lines = ImageIO.SaveNFP(artboard:GetFlattenedPixels())\
  93.             for i, v in ipairs(lines) do\
  94.                 content = content .. v .. '\\n'\
  95.             end\
  96.         else\
  97.             err = 'Unknown format \"'..format..'\"'\
  98.         end\
  99.         if not err and content then\
  100.             local _fs = fs\
  101.             if OneOS then\
  102.                 _fs = OneOS.FS\
  103.             end\
  104.             local h = _fs.open(path, 'w')\
  105.             if h then\
  106.                 h.write(content)\
  107.                 h.close()\
  108.             else\
  109.                 err = 'Could not open file.'\
  110.             end\
  111.         else\
  112.             err = 'Content conversion failed.'\
  113.         end\
  114.     else\
  115.         err = 'No artboard.'\
  116.     end\
  117. \
  118.     if err then\
  119.         program:DisplayAlertWindow('Save Failed', \"Document write failed: \"..err, {'Ok'}, function(button)\
  120.         end)\
  121.     end\
  122. end\
  123. \
  124. function SaveDocument(callback)\
  125.     callback = callback or function()end\
  126.     local artboard = program:GetObject('Artboard')\
  127.     if artboard then\
  128.         if artboard.ImagePath then\
  129.             SaveWithFormat(artboard.ImagePath, artboard.ImageFormat:lower())\
  130.             artboard:SetSavedState()\
  131.             callback(true)\
  132.         else\
  133.             program:DisplaySaveFileWindow('Save Image', function(success, path, filename)\
  134.                 if success then\
  135.                     SaveWithFormat(path, artboard.ImageFormat:lower())\
  136.                     artboard:SetSavedState()\
  137.                     artboard.ImagePath = path\
  138.                     callback(true)\
  139.                 else\
  140.                     callback(false)\
  141.                 end\
  142.             end, artboard.ImageFormat:lower())\
  143.         end\
  144.     else\
  145.         callback(false)\
  146.     end\
  147. end\
  148. \
  149. local artboardOnlyMenuItems = {\
  150.     'Tool',\
  151.     'Save',\
  152.     'SaveAs',\
  153.     'Undo',\
  154.     'Redo',\
  155.     'Cut',\
  156.     'Copy',\
  157.     'Paste',\
  158.     'Resize',\
  159.     'CanvasSize',\
  160.     'Crop',\
  161.     'Erase',\
  162.     'Flatten',\
  163.     'ZoomIn',\
  164.     'ZoomOut',\
  165.     '100%Zoom',\
  166.     'FitZoom',\
  167.     'FilterMask',\
  168.     'NewLayerImage'\
  169. }\
  170. \
  171. function program.OnArtboardOpen(artboard)\
  172.     for i, v in ipairs(artboardOnlyMenuItems) do\
  173.         for i2, v2 in ipairs(program:GetObjects(v..'MenuItem')) do\
  174.             v2.Enabled = true\
  175.         end\
  176.     end\
  177.     program:GetObject('Sidebar'):UpdateButtons(true)\
  178. end\
  179. \
  180. function program.OnArtboardClose(artboard)\
  181.     for i, v in ipairs(artboardOnlyMenuItems) do\
  182.         for i2, v2 in ipairs(program:GetObjects(v..'MenuItem')) do\
  183.             v2.Enabled = false\
  184.         end\
  185.     end\
  186.     program:GetObject('Sidebar'):UpdateButtons(false)\
  187.     program:GetObject('CurrentToolLabel').Text = ''\
  188.     program:GetObject('PrimaryColourView').BackgroundColour = colours.transparent\
  189.     program:GetObject('SecondaryColourView').BackgroundColour = colours.transparent\
  190. end\
  191. \
  192. function NewDocument()\
  193.     CloseDocument(function(success)\
  194.         if success then\
  195.             program:DisplayWindow('newdocumentwindow', 'New Document')\
  196. \
  197.             local colourView = program.Window:GetObject('CurrentColourButton')\
  198.             program.Window:GetObject('NoneColourButton').OnClick = function()\
  199.                 colourView.BackgroundColour = colours.transparent\
  200.             end\
  201. \
  202.             for i, v in ipairs(program.Window:GetObjects('BackgroundColourButton')) do\
  203.                 v.OnClick = function(self)\
  204.                     colourView.BackgroundColour = self.BackgroundColour\
  205.                 end\
  206.             end\
  207. \
  208.             local presetChanging = false\
  209.             program:GetObject('WidthNumberBox').OnChange = function()\
  210.                 if not presetChanging then\
  211.                     program:GetObject('PresetButton').Text = 'Custom      V'\
  212.                 end\
  213.             end\
  214.             program:GetObject('HeightNumberBox').OnChange = function()\
  215.                 if not presetChanging then\
  216.                     program:GetObject('PresetButton').Text = 'Custom      V'\
  217.                 end\
  218.             end\
  219. \
  220.             program:GetObject('PresetButton').OnClick = function(self)\
  221.                 if self:ToggleMenu('sizepresetmenu', 1, 1) then\
  222.                     program:GetObject('CustomMenuItem').OnClick = function()\
  223.                         self.Text = 'Custom      V'\
  224.                     end\
  225. \
  226.                     for i, v in ipairs(program:GetObjects('PresetMenuItem')) do\
  227.                         v.OnClick = function(_self)\
  228.                             local text = program.Helpers.TruncateString(_self.Text, 12)\
  229.                             for i = 1, 12 - #text do\
  230.                                 text = text .. ' '\
  231.                             end\
  232.                             text = text .. 'V'\
  233.                             self.Text = text\
  234.                             presetChanging = true\
  235.                             program:GetObject('WidthNumberBox').Value = _self.SizeWidth\
  236.                             program:GetObject('HeightNumberBox').Value = _self.SizeHeight\
  237.                             presetChanging = false\
  238.                         end\
  239.                     end\
  240.                 end\
  241.             end\
  242. \
  243.             program:GetObject('CancelButton').OnClick = function()\
  244.                 program.Window:Close()\
  245.             end\
  246. \
  247.             program:GetObject('OkButton').OnClick = function()\
  248.                 local width = program:GetObject('WidthNumberBox').Value\
  249.                 local height = program:GetObject('HeightNumberBox').Value\
  250.                 local background = colourView.BackgroundColour\
  251.                 program.Window:Close()\
  252. \
  253.                 local pixels = {}\
  254. \
  255.                 for x = 1, width do\
  256.                     pixels[x] = {}\
  257.                     for y = 1, height do\
  258.                         pixels[x][y] = {\
  259.                             BackgroundColour = background,\
  260.                             TextColour = colours.black,\
  261.                             Character = ' '\
  262.                         }\
  263.                     end\
  264.                 end\
  265. \
  266.                 program:AddObject({\
  267.                     Type = 'Artboard',\
  268.                     X = program.Helpers.Round((Drawing.Screen.Width - width - 3) / 2),\
  269.                     Y = program.Helpers.Round((Drawing.Screen.Height - height) / 2),\
  270.                     Width = width,\
  271.                     Height = height,\
  272.                     ImageFormat = 'skch',\
  273.                     Layers = {\
  274.                         {\
  275.                             Name = 'Background',\
  276.                             Pixels = pixels,\
  277.                             BackgroundColour = background,\
  278.                             Visible = true,\
  279.                             Index = 1,\
  280.                             LayerType = 'Normal'\
  281.                         }\
  282.                     },\
  283.                 })\
  284.             end\
  285.         end\
  286.     end)\
  287. end\
  288. \
  289. function SaveDocumentAs()\
  290.     local artboard = program:GetObject('Artboard')\
  291.     if artboard then\
  292.         program:DisplayWindow('saveasformatwindow', 'Save As')\
  293. \
  294.         local formatButtons = program:GetObjects('FormatButton')\
  295.         local format = 'skch'\
  296. \
  297.         for i, v in ipairs(formatButtons) do\
  298.             v.OnClick = function(self)\
  299.                 self.Toggle = true\
  300.                 format = self.Format\
  301.                 for i2, v2 in ipairs(formatButtons) do\
  302.                     if v2 ~= self then\
  303.                         v2.Toggle = false\
  304.                     end\
  305.                 end\
  306.             end\
  307.         end\
  308. \
  309.         program:GetObject('CancelButton').OnClick = function()\
  310.             program.Window:Close()\
  311.         end\
  312. \
  313.         program:GetObject('NextButton').OnClick = function()\
  314.             program.Window:Close()\
  315.             program:DisplaySaveFileWindow('Save Image As', function(success, path, filename)\
  316.                 if success then\
  317.                     SaveWithFormat(path, format)\
  318.                 end\
  319.             end, format)\
  320.         end\
  321.     end\
  322. end\
  323. \
  324. function CloseDocument(callback)\
  325.     local artboard = program:GetObject('Artboard')\
  326.     if artboard and artboard:Modified() then\
  327.         program:DisplayAlertWindow('Unsaved Changes!', \"Save changes to your document?\", {'Save', 'Cancel', \"Don't Save\"}, function(button)\
  328.             if button == 'Cancel' then\
  329.                 callback(false)\
  330.             elseif button == \"Don't Save\" then\
  331.                 callback(true)\
  332.                 program:RemoveObject(artboard)\
  333.             else\
  334.                 SaveDocument(function(success)\
  335.                     if success then\
  336.                         program:RemoveObject(artboard)\
  337.                     end\
  338.                     callback(success)\
  339.                 end)\
  340.             end\
  341.         end)\
  342.         return false\
  343.     else\
  344.         program:RemoveObject('Artboard')\
  345.         callback(true)\
  346.         return true\
  347.     end\
  348. end\
  349. \
  350. if OneOS then\
  351.     OneOS.CanClose = function()\
  352.         return CloseDocument(function(close)\
  353.                 if close then\
  354.                     program:Quit()\
  355.                 end\
  356.             end)\
  357.     end\
  358. end\
  359. \
  360. function ResizeDocument()\
  361.     local artboard = program:GetObject('Artboard')\
  362.     if artboard then\
  363.         program:DisplayWindow('resizewindow', 'Resize Image')\
  364. \
  365.         local constrainProportions = true\
  366.         local keepTextDetail = true\
  367.         local proportions = artboard.Width / artboard.Height\
  368. \
  369.         local widthNumberBox = program:GetObject('WidthNumberBox')\
  370.         local heightNumberBox = program:GetObject('HeightNumberBox')\
  371. \
  372.         widthNumberBox.Value = artboard.Width\
  373.         heightNumberBox.Value = artboard.Height\
  374. \
  375.         local proportionChange = false\
  376. \
  377.         widthNumberBox.OnChange = function()\
  378.             if constrainProportions and not proportionChange then\
  379.                 proportionChange = true\
  380.                 heightNumberBox:SetValue(program.Helpers.Round(widthNumberBox.Value / proportions))\
  381.             else\
  382.                 proportionChange = false\
  383.             end\
  384.         end\
  385. \
  386.         heightNumberBox.OnChange = function()\
  387.             if constrainProportions and not proportionChange then\
  388.                 proportionChange = true\
  389.                 widthNumberBox:SetValue(program.Helpers.Round(heightNumberBox.Value * proportions))\
  390.             else\
  391.                 proportionChange = false\
  392.             end\
  393.         end\
  394.         \
  395.         program:GetObject('ProportionsButton').OnClick = function(self)\
  396.             constrainProportions = self.Toggle\
  397.         end\
  398.         \
  399.         program:GetObject('TextDetailButton').OnClick = function(self)\
  400.             keepTextDetail = self.Toggle\
  401.         end\
  402. \
  403.         program:GetObject('ResizeButton').OnClick = function()\
  404.             artboard:Resize(widthNumberBox.Value, heightNumberBox.Value, keepTextDetail)\
  405.             program.Window:Close()\
  406.         end\
  407. \
  408.         program:GetObject('CancelButton').OnClick = function()\
  409.             program.Window:Close()\
  410.         end\
  411.     end\
  412. end\
  413. \
  414. function ChangeCanvasSize()\
  415.     local artboard = program:GetObject('Artboard')\
  416.     if artboard then\
  417.         print('splie')\
  418.         program:DisplayWindow('canvassizewindow', 'Change Canvas Size')\
  419. \
  420.         -- local constrainProportions = true\
  421.         -- local keepTextDetail = true\
  422.         -- local proportions = artboard.Width / artboard.Height\
  423. \
  424.         local widthNumberBox = program:GetObject('WidthNumberBox')\
  425.         local heightNumberBox = program:GetObject('HeightNumberBox')\
  426. \
  427.         widthNumberBox.Value = artboard.Width\
  428.         heightNumberBox.Value = artboard.Height\
  429. \
  430.         local anchorPosition = 5\
  431. \
  432.         local function updateAnchorButtons(self)\
  433.             local anchors = {' ',' ',' ',' ',' ',' ',' ',' ',' '}\
  434. \
  435.             -- i'm sure there's a better way to do this...\
  436.             if anchorPosition == 1 then\
  437.                 anchors[1] = '#'\
  438.                 anchors[2] = '>'\
  439.                 anchors[4] = 'v'\
  440.             elseif anchorPosition == 2 then\
  441.                 anchors[1] = '<'\
  442.                 anchors[2] = '#'\
  443.                 anchors[3] = '>'\
  444.                 anchors[5] = 'v'\
  445.             elseif anchorPosition == 3 then\
  446.                 anchors[2] = '<'\
  447.                 anchors[3] = '#'\
  448.                 anchors[6] = 'v'\
  449.             elseif anchorPosition == 4 then\
  450.                 anchors[1] = '^'\
  451.                 anchors[4] = '#'\
  452.                 anchors[5] = '>'\
  453.                 anchors[7] = 'v'\
  454.             elseif anchorPosition == 5 then\
  455.                 anchors[2] = '^'\
  456.                 anchors[4] = '<'\
  457.                 anchors[5] = '#'\
  458.                 anchors[6] = '>'\
  459.                 anchors[8] = 'v'\
  460.             elseif anchorPosition == 6 then\
  461.                 anchors[3] = '^'\
  462.                 anchors[6] = '#'\
  463.                 anchors[5] = '<'\
  464.                 anchors[9] = 'v'\
  465.             elseif anchorPosition == 7 then\
  466.                 anchors[4] = '^'\
  467.                 anchors[7] = '#'\
  468.                 anchors[8] = '>'\
  469.             elseif anchorPosition == 8 then\
  470.                 anchors[5] = '^'\
  471.                 anchors[8] = '#'\
  472.                 anchors[7] = '<'\
  473.                 anchors[9] = '>'\
  474.             elseif anchorPosition == 9 then\
  475.                 anchors[6] = '^'\
  476.                 anchors[9] = '#'\
  477.                 anchors[8] = '<'\
  478.             end\
  479. \
  480.             if artboard.Height > heightNumberBox.Value then\
  481.                 for i, v in ipairs(anchors) do\
  482.                     if string.find(v, \"%^\") then\
  483.                         v = v:gsub('%^','v')\
  484.                     elseif string.find(v, \"v\") then\
  485.                         v = v:gsub('v','%^')\
  486.                     end\
  487.                     anchors[i] = v\
  488.                 end\
  489.             end\
  490. \
  491.             if artboard.Width > widthNumberBox.Value then\
  492.                 for i, v in ipairs(anchors) do\
  493.                     if string.find(v, \">\") then\
  494.                         v = v:gsub('>','<')\
  495.                     elseif string.find(v, \"<\") then\
  496.                         v = v:gsub('<','>')\
  497.                     end\
  498.                     anchors[i] = v\
  499.                 end\
  500.             end\
  501. \
  502.             for i, v in ipairs(anchors) do\
  503.                 program:GetObject('Anchor'..i..'Button').Text = v\
  504.             end\
  505.         end\
  506. \
  507.         for i = 1, 9 do\
  508.             program:GetObject('Anchor'..i..'Button').OnClick = function()\
  509.                 anchorPosition = i\
  510.                 updateAnchorButtons()\
  511.             end\
  512.         end\
  513. \
  514.         updateAnchorButtons()\
  515. \
  516.         widthNumberBox.OnChange = function()\
  517.             updateAnchorButtons()\
  518.         end\
  519. \
  520.         heightNumberBox.OnChange = function()\
  521.             updateAnchorButtons()\
  522.         end\
  523. \
  524.         program:GetObject('OkButton').OnClick = function()\
  525.             artboard:ChangeCanvasSize(widthNumberBox.Value, heightNumberBox.Value, anchorPosition)\
  526.             program.Window:Close()\
  527.         end\
  528. \
  529.         program:GetObject('CancelButton').OnClick = function()\
  530.             program.Window:Close()\
  531.         end\
  532.     end\
  533. end\
  534. \
  535. local tArgs = {...}\
  536. \
  537. program:Run(function()\
  538. \
  539.     if OneOS then\
  540.         Clipboard = OneOS.Clipboard\
  541.     end\
  542. \
  543. \
  544.     -- NewDocument()\
  545.     --------------------------------File Menu---------------------------------------\
  546.     program:PrepareMenu('filemenu')\
  547. \
  548.     program:GetObject('NewMenuItem').OnClick = function(self, event, side, x, y)\
  549.         NewDocument()\
  550.     end\
  551.     program:GetObject('OpenMenuItem').OnClick = function(self, event, side, x, y)\
  552.         program:DisplayOpenFileWindow('Open Image', function(success, path)\
  553.             if success then\
  554.                 OpenDocument(path)\
  555.             end\
  556.         end)\
  557.     end\
  558.     program:GetObject('SaveMenuItem').OnClick = function(self, event, side, x, y)\
  559.         SaveDocument()\
  560.     end\
  561.     program:GetObject('SaveAsMenuItem').OnClick = function(self, event, side, x, y)\
  562.         SaveDocumentAs()\
  563.     end\
  564.     program:GetObject('QuitMenuItem').OnClick = function(self, event, side, x, y)\
  565.         CloseDocument(function(close)\
  566.             if close then\
  567.                 program:Quit()\
  568.                 term.setBackgroundColour(colours.black)\
  569.                 term.setTextColour(colours.white)\
  570.                 term.clear()\
  571.                 term.setCursorPos(1, 1)\
  572. \
  573.                 local function PrintCentered(text, y)\
  574.                     local w, h = term.getSize()\
  575.                     x = math.ceil(math.ceil((w / 2) - (#text / 2)), 0)+1\
  576.                     term.setCursorPos(x, y)\
  577.                     print(text)\
  578.                 end\
  579. \
  580.                 PrintCentered(\"Thanks for using Sketch 2!\", (Drawing.Screen.Height / 2) - 1)\
  581.                 term.setTextColour(colours.lightGrey)\
  582.                 PrintCentered(\"Photoshop Inspired Image Editor for ComputerCraft\", (Drawing.Screen.Height / 2))\
  583.                 term.setTextColour(colours.white)\
  584.                 PrintCentered(\"(c) oeed 2013 - 2014\", (Drawing.Screen.Height / 2) + 3)\
  585.                 term.setCursorPos(1, Drawing.Screen.Height)\
  586.             end\
  587.         end)\
  588.     end\
  589. \
  590.     program:GetObject('FileMenuButton').OnClick = function(self, event, side, x, y)\
  591.         self:ToggleMenu('filemenu')\
  592.     end\
  593.     --------------------------------------------------------------------------------\
  594. \
  595.     --------------------------------Edit Menu---------------------------------------\
  596.     program:PrepareMenu('editmenu')\
  597. \
  598.     program:GetObject('UndoMenuItem').OnClick = function(self, event, side, x, y)\
  599.         local artboard = program:GetObject('Artboard')\
  600.         if artboard then\
  601.             artboard:Undo()\
  602.         end\
  603.     end\
  604.     program:GetObject('RedoMenuItem').OnClick = function(self, event, side, x, y)\
  605.         local artboard = program:GetObject('Artboard')\
  606.         if artboard then\
  607.             artboard:Redo()\
  608.         end\
  609.     end\
  610.     program:GetObject('CutMenuItem').OnClick = function(self, event, side, x, y)\
  611.         local artboard = program:GetObject('Artboard')\
  612.         if artboard then\
  613.             artboard:Cut()\
  614.         end\
  615.     end\
  616.     program:GetObject('CopyMenuItem').OnClick = function(self, event, side, x, y)\
  617.         local artboard = program:GetObject('Artboard')\
  618.         if artboard then\
  619.             artboard:Copy()\
  620.         end\
  621.     end\
  622.     program:GetObject('PasteMenuItem').OnClick = function(self, event, side, x, y)\
  623.         local artboard = program:GetObject('Artboard')\
  624.         if artboard then\
  625.             artboard:Paste()\
  626.         end\
  627.     end\
  628. \
  629.     program:GetObject('EditMenuButton').OnClick = function(self, event, side, x, y)\
  630.         self:ToggleMenu('editmenu')\
  631.     end\
  632.     --------------------------------------------------------------------------------\
  633. \
  634.     --------------------------------Image Menu--------------------------------------\
  635.     program:PrepareMenu('imagemenu')\
  636. \
  637.     program:GetObject('ResizeMenuItem').OnClick = function(self, event, side, x, y)\
  638.         ResizeDocument()\
  639.     end\
  640.     program:GetObject('CanvasSizeMenuItem').OnClick = function(self, event, side, x, y)\
  641.         ChangeCanvasSize()\
  642.     end\
  643.     program:GetObject('CropMenuItem').OnClick = function(self, event, side, x, y)\
  644.         local artboard = program:GetObject('Artboard')\
  645.         if artboard then\
  646.             artboard:Crop()\
  647.         end\
  648.     end\
  649.     program:GetObject('EraseMenuItem').OnClick = function(self, event, side, x, y)\
  650.         local artboard = program:GetObject('Artboard')\
  651.         if artboard then\
  652.             return artboard:EraseSelection()\
  653.         end\
  654.         return false\
  655.     end\
  656.     program:GetObject('NewLayerImageMenuItem').OnClick = function(self, event, side, x, y)\
  657.         local artboard = program:GetObject('Artboard')\
  658.         if artboard then\
  659.             artboard:NewLayer()\
  660.         end\
  661.     end\
  662.     program:GetObject('FlattenMenuItem').OnClick = function(self, event, side, x, y)\
  663.         local artboard = program:GetObject('Artboard')\
  664.         if artboard then\
  665.             artboard:FlattenImage()\
  666.         end\
  667.     end\
  668. \
  669.     program:GetObject('ImageMenuButton').OnClick = function(self, event, side, x, y)\
  670.         self:ToggleMenu('imagemenu')\
  671.     end\
  672.     --------------------------------------------------------------------------------\
  673. \
  674.     --------------------------------View Menu---------------------------------------\
  675.     program:PrepareMenu('viewmenu')\
  676. \
  677.     program:GetObject('ZoomOutMenuItem').OnClick = function(self, event, side, x, y)\
  678.         local artboard = program:GetObject('Artboard')\
  679.         if artboard then\
  680.             artboard:SetZoom(artboard.Zoom / 2)\
  681.         end\
  682.     end\
  683.     program:GetObject('ZoomInMenuItem').OnClick = function(self, event, side, x, y)\
  684.         local artboard = program:GetObject('Artboard')\
  685.         if artboard then\
  686.             artboard:SetZoom(artboard.Zoom * 2)\
  687.         end\
  688.     end\
  689.     program:GetObject('100%ZoomMenuItem').OnClick = function(self, event, side, x, y)\
  690.         local artboard = program:GetObject('Artboard')\
  691.         if artboard then\
  692.             artboard:SetZoom(1)\
  693.         end\
  694.     end\
  695.     program:GetObject('FilterMaskMenuItem').OnClick = function(self, event, side, x, y)\
  696.         local artboard = program:GetObject('Artboard')\
  697.         if artboard then\
  698.             artboard.ShowFilterMask = not artboard.ShowFilterMask\
  699.         end\
  700.     end\
  701. \
  702.     program:GetObject('ViewMenuButton').OnClick = function(self, event, side, x, y)\
  703.         self:ToggleMenu('viewmenu')\
  704.     end\
  705.     --------------------------------------------------------------------------------\
  706. \
  707.     --------------------------------Tools Menu--------------------------------------\
  708.     program:PrepareMenu('toolsmenu')\
  709. \
  710.     for i, v in ipairs(program:GetObjects('ToolMenuItem')) do\
  711.         v.OnClick = function(self, event, side, x, y)\
  712.             local artboard = program:GetObject('Artboard')\
  713.             if artboard then\
  714.                 artboard:SetTool(getfenv()[self.ToolName])\
  715.             end\
  716.         end\
  717.     end\
  718.     program:GetObject('ToolsMenuButton').OnClick = function(self, event, side, x, y)\
  719.         self:ToggleMenu('toolsmenu')\
  720.     end\
  721.     --------------------------------------------------------------------------------\
  722. \
  723. \
  724.     program:GetObject('PrimaryColourView').OnClick = function(self, event, side, x, y)\
  725.         program:GetObject('ColoursSidebarButton'):Click(event, side, x, y)\
  726.     end\
  727. \
  728.     program:GetObject('SecondaryColourView').OnClick = function(self, event, side, x, y)\
  729.         program:GetObject('ColoursSidebarButton'):Click(event, side, x, y)\
  730.     end\
  731. \
  732.     program:GetObject('CurrentToolLabel').OnClick = function(self, event, side, x, y)\
  733.         program:GetObject('ToolsSidebarButton'):Click(event, side, x, y)\
  734.     end\
  735. \
  736.     program.View.Click = ViewClick\
  737. \
  738. \
  739.     program.OnArtboardClose()\
  740. \
  741.     if #tArgs == 1 then\
  742.         OpenDocument(tArgs[1])\
  743.     else\
  744.         NewDocument()\
  745.     end\
  746.     -- TODO: remove!\
  747.     -- program:RegisterKeyboardShortcut({'\\\\'}, function()os.reboot()end)\
  748. end)",["APIs"]={["EraserTool.lua"]="Name = 'Eraser'\
  749. \
  750. OnUse = function(artboard, event, side, x, y)\
  751.     local layer = artboard:GetCurrentLayer()\
  752.     local pixels = layer:GetEffectedPixels(x, y, artboard.BrushSize, artboard.BrushShape, artboard.CorrectPixelRatio)\
  753. \
  754.     local colour = colours.transparent\
  755.     if layer.Layer.LayerType ~= 'Normal' then\
  756.         colour = colours.black\
  757.     else\
  758.         colour = layer.BackgroundColour\
  759.     end\
  760. \
  761.     for i, pixel in ipairs(pixels) do\
  762.         if side == 1 then\
  763.             layer:SetPixel(pixel[1], pixel[2], colour)\
  764.         elseif side == 2 then\
  765.             layer:SetPixel(pixel[1], pixel[2], nil, colours.black, ' ')\
  766.         end\
  767.     end\
  768. end",["SprayTool.lua"]="Name = 'Spray'\
  769. \
  770. OnUse = function(artboard, event, side, x, y)\
  771.     local layer = artboard:GetCurrentLayer()\
  772.     -- artboard.BrushSize\
  773.     local pixels = layer:GetEffectedPixels(x, y, artboard.BrushSize, artboard.BrushShape, artboard.CorrectPixelRatio)\
  774. \
  775.     local colour = (side == 1 and artboard.BrushColour or artboard.SecondaryBrushColour)\
  776.     if layer.Layer.LayerType ~= 'Normal' then\
  777.         if colour == colours.transparent then\
  778.             colour = colours.black\
  779.         end\
  780.         colour = Drawing.FilterColour(colour, Drawing.Filters.BlackWhite)\
  781.     end\
  782. \
  783.     for i, pixel in ipairs(pixels) do\
  784.         if math.random(0, 3) == 0 then\
  785.             if side == 1 then\
  786.                 layer:SetPixel(pixel[1], pixel[2], colour)\
  787.             elseif side == 3 then\
  788.                 layer:SetPixel(pixel[1], pixel[2], nil, colour)\
  789.             end\
  790.         end\
  791.     end\
  792. end",["SelectTool.lua"]="Name = 'Select'\
  793. \
  794. OnUse = function(artboard, event, side, x, y)\
  795.     if event == 'mouse_click' then\
  796.         artboard.Selection = {\
  797.             {\
  798.                 X = x,\
  799.                 Y = y\
  800.             },\
  801.             nil\
  802.         }\
  803.     elseif event == 'mouse_drag' then\
  804.         if artboard.Selection and artboard.Selection[1] then\
  805.             artboard.Selection = {\
  806.                 artboard.Selection[1],\
  807.                 {\
  808.                     X = x,\
  809.                     Y = y\
  810.                 }\
  811.             }\
  812.         end\
  813.     end\
  814. end",["HandTool.lua"]="Name = 'Hand'\
  815. \
  816. OnUse = function(artboard, event, side, x, y)\
  817.     if event == 'mouse_click' then\
  818.         artboard.DragStart = {x, y}\
  819.     elseif event == 'mouse_drag' and artboard.DragStart then\
  820.         local deltaX = x - artboard.DragStart[1]\
  821.         local deltaY = y - artboard.DragStart[2]\
  822.         artboard.X = artboard.X + deltaX\
  823.         artboard.Y = artboard.Y + deltaY\
  824.     else return\
  825.     end\
  826. \
  827.     artboard.DragTimer = artboard.Bedrock:StartTimer(function(_, timer)\
  828.         if timer == artboard.DragTimer then\
  829.             artboard.DragStart = nil\
  830.             artboard.DragTimer = nil\
  831.         end\
  832.     end, 1)\
  833. end",["PencilTool.lua"]="Name = 'Pencil'\
  834. \
  835. OnUse = function(artboard, event, side, x, y)\
  836.     local layer = artboard:GetCurrentLayer()\
  837.     local pixels = layer:GetEffectedPixels(x, y, artboard.BrushSize, artboard.BrushShape, artboard.CorrectPixelRatio)\
  838. \
  839.     local colour = (side == 1 and artboard.BrushColour or artboard.SecondaryBrushColour)\
  840.     if layer.Layer.LayerType ~= 'Normal' then\
  841.         if colour == colours.transparent then\
  842.             colour = colours.black\
  843.         end\
  844.         colour = Drawing.FilterColour(colour, Drawing.Filters.BlackWhite)\
  845.     end\
  846. \
  847.     for i, pixel in ipairs(pixels) do\
  848.         layer:SetPixel(pixel[1], pixel[2], colour)\
  849.         -- elseif side == 3 then\
  850.         --  layer:SetPixel(pixel[1], pixel[2], nil, colour)\
  851.         -- end\
  852.     end\
  853. end",["FillTool.lua"]="Name = 'Fill'\
  854. \
  855. OnUse = function(artboard, event, side, x, y)\
  856.     local layer = artboard:GetCurrentLayer()\
  857.     local pixels = layer.Layer.Pixels\
  858.     local replaceColour = pixels[x][y].BackgroundColour\
  859.     -- if side == 2 then\
  860.     --  replaceColour = pixels[x][y].TextColour\
  861.     -- end\
  862. \
  863.     local colour = (side == 1 and artboard.BrushColour or artboard.SecondaryBrushColour)\
  864. \
  865.     local nodes = {{X = x, Y = y}}\
  866. \
  867.     while #nodes > 0 do\
  868.         local node = nodes[1]\
  869.         if pixels[node.X] and pixels[node.X][node.Y] then\
  870.             local replacing = pixels[node.X][node.Y].BackgroundColour\
  871.             -- if side == 2 then\
  872.             --  replacing = pixels[node.X][node.Y].TextColour\
  873.             -- end\
  874.             if replacing == replaceColour and replacing ~= colour then\
  875.                 -- if side == 1 then\
  876.                     layer:SetPixel(node.X, node.Y, colour)\
  877.                 -- elseif side == 2 then\
  878.                 --  layer:SetPixel(node.X, node.Y, nil, colour)\
  879.                 -- end\
  880.                 table.insert(nodes, {X = node.X, Y = node.Y + 1})\
  881.                 table.insert(nodes, {X = node.X + 1, Y = node.Y})\
  882.                 if x > 1 then\
  883.                     table.insert(nodes, {X = node.X - 1, Y = node.Y})\
  884.                 end\
  885.                 if y > 1 then\
  886.                     table.insert(nodes, {X = node.X, Y = node.Y - 1})\
  887.                 end\
  888.             end\
  889.         end\
  890.         table.remove(nodes, 1)\
  891.     end\
  892. end\
  893.             ",["ImageIO.lua"]="local hexnums = { [10] = \"a\", [11] = \"b\", [12] = \"c\", [13] = \"d\", [14] = \"e\" , [15] = \"f\" }\
  894. local function getHexOf(colour)\
  895.    if colour == colours.transparent or not colour or not tonumber(colour) then\
  896.            return \" \"\
  897.    end\
  898.    local value = math.log(colour)/math.log(2)\
  899.    if value > 9 then\
  900.            value = hexnums[value]\
  901.    end\
  902.    return value\
  903. end\
  904. \
  905. local function getColourOf(hex)\
  906.     if hex == ' ' then\
  907.         return colours.transparent\
  908.     end\
  909.    local value = tonumber(hex, 16)\
  910.    if not value then return nil end\
  911.    value = math.pow(2,value)\
  912.    return value\
  913. end\
  914. \
  915. function SaveSKCH(layersIn)\
  916.     local layers = {}\
  917.     for i, l in ipairs(layersIn) do\
  918.         local pixels = SaveNFT(l.Pixels)\
  919.         local layer = {\
  920.             Name = l.Name,\
  921.             Pixels = pixels,\
  922.             BackgroundColour = l.BackgroundColour,\
  923.             Visible = l.Visible,\
  924.             Index = l.Index,\
  925.             LayerType = l.LayerType\
  926.         }\
  927.         table.insert(layers, layer)\
  928.     end\
  929.     return layers\
  930. end\
  931. \
  932. function SaveNFT(pixels)\
  933.     local lines = {}\
  934.     local width = #pixels\
  935.     local height = #pixels[1]\
  936.     for y = 1, height do\
  937.         local line = ''\
  938.         local currentBackgroundColour = nil\
  939.         local currentTextColour = nil\
  940.         for x = 1, width do\
  941.             local pixel = pixels[x][y]\
  942.             if pixel.BackgroundColour ~= currentBackgroundColour then\
  943.                 line = line..string.char(30)..getHexOf(pixel.BackgroundColour)\
  944.                 currentBackgroundColour = pixel.BackgroundColour\
  945.             end\
  946.             if pixel.TextColour ~= currentTextColour then\
  947.                 line = line..string.char(31)..getHexOf(pixel.TextColour)\
  948.                 currentTextColour = pixel.TextColour\
  949.             end\
  950.             line = line .. pixel.Character\
  951.         end\
  952.         table.insert(lines, line)\
  953.     end\
  954.     return lines\
  955. end\
  956. \
  957. function SaveNFP(pixels)\
  958.     local lines = {}\
  959.     local width = #pixels\
  960.     local height = #pixels[1]\
  961.     for y = 1, height do\
  962.         local line = ''\
  963.         for x = 1, width do\
  964.             line = line .. getHexOf(pixels[x][y].BackgroundColour)\
  965.         end\
  966.         table.insert(lines, line)\
  967.     end\
  968.     return lines\
  969. end\
  970. \
  971. function ReadNFP(path)\
  972.     local pixels = {}\
  973.     local _fs = fs\
  974.     if OneOS then\
  975.         _fs = OneOS.FS\
  976.     end\
  977.     local file = _fs.open(path, 'r')\
  978.     local line = file.readLine()\
  979.     local y = 1\
  980.     while line do\
  981.         for x = 1, #line do\
  982.             if not pixels[x] then\
  983.                 pixels[x] = {}\
  984.             end\
  985.             pixels[x][y] = {BackgroundColour = getColourOf(line:sub(x,x)), TextColour = colours.black, Character = ' '}\
  986.         end\
  987.         y = y + 1\
  988.         line = file.readLine()\
  989.     end\
  990.     file.close()\
  991.     return {{Pixels = pixels}}\
  992. end\
  993. \
  994. function ReadNFT(path)\
  995.     local _fs = fs\
  996.     if OneOS then\
  997.         _fs = OneOS.FS\
  998.     end\
  999.     local file = _fs.open(path, 'r')\
  1000.     local line = file.readLine()\
  1001.     local lines = {}\
  1002.     while line do\
  1003.         table.insert(lines, line)\
  1004.         line = file.readLine()\
  1005.     end\
  1006.     file.close()\
  1007.     return {{Pixels = ParseNFT(lines)}}\
  1008. end\
  1009. \
  1010. function ParseNFT(lines)\
  1011.     local pixels = {}\
  1012.     for y, line in ipairs(lines) do\
  1013.         local bgNext, fgNext = false, false\
  1014.         local currBG, currFG = nil,nil\
  1015.         local writePosition = 1\
  1016.         for x = 1, #line do\
  1017.             if not pixels[writePosition] then\
  1018.                 pixels[writePosition] = {}\
  1019.             end\
  1020. \
  1021.             local nextChar = string.sub(line, x, x)\
  1022.            if nextChar:byte() == 30 then\
  1023.                    bgNext = true\
  1024.            elseif nextChar:byte() == 31 then\
  1025.                    fgNext = true\
  1026.            elseif bgNext then\
  1027.                    currBG = getColourOf(nextChar)\
  1028.                    if currBG == nil then\
  1029.                         currBG = colours.transparent\
  1030.                    end\
  1031.                    bgNext = false\
  1032.            elseif fgNext then\
  1033.                    currFG = getColourOf(nextChar)\
  1034.                    fgNext = false\
  1035.            else\
  1036.                    if nextChar ~= \" \" and currFG == nil then\
  1037.                            currFG = colours.white\
  1038.                    end\
  1039.                    pixels[writePosition][y] = {BackgroundColour = currBG, TextColour = currFG, Character = nextChar}\
  1040.                    writePosition = writePosition + 1\
  1041.            end\
  1042.         end\
  1043.     end\
  1044.     return pixels\
  1045. end\
  1046. \
  1047. function ReadSKCH(path)\
  1048.     local _fs = fs\
  1049.     if OneOS then\
  1050.         _fs = OneOS.FS\
  1051.     end\
  1052.     local file = _fs.open(path, 'r')\
  1053.     local _layers = textutils.unserialize(file.readAll())\
  1054.     file.close()\
  1055.     local layers = {}\
  1056. \
  1057.     for i, l in ipairs(_layers) do\
  1058.         local layer = {\
  1059.             Name = l.Name,\
  1060.             Pixels = ParseNFT(l.Pixels),\
  1061.             BackgroundColour = l.BackgroundColour,\
  1062.             Visible = l.Visible,\
  1063.             Index = l.Index,\
  1064.             LayerType = l.LayerType or 'Normal'\
  1065.         }\
  1066.         table.insert(layers, layer)\
  1067.     end\
  1068.     return layers\
  1069. end\
  1070. \
  1071. function GetFormat(path)\
  1072.     local _fs = fs\
  1073.     if OneOS then\
  1074.         _fs = OneOS.FS\
  1075.     end\
  1076.     local file = _fs.open(path, 'r')\
  1077.     local content = file.readAll()\
  1078.     file.close()\
  1079.     if type(textutils.unserialize(content)) == 'table' then\
  1080.         -- It's a serlized table, asume sketch\
  1081.         return '.skch'\
  1082.     elseif string.find(content, string.char(30)) or string.find(content, string.char(31)) then\
  1083.         -- Contains the characters that set colours, asume nft\
  1084.         return '.nft'\
  1085.     else\
  1086.         -- Otherwise asume nfp\
  1087.         return '.nfp'\
  1088.     end\
  1089. end\
  1090. \
  1091. function LoadDocument(path, program)\
  1092.     local _fs = fs\
  1093.     if OneOS then\
  1094.         _fs = OneOS.FS\
  1095.     end\
  1096.     if _fs.exists(path) and not _fs.isDir(path) then\
  1097.         local format = program.Helpers.Extension(path, true)\
  1098.         if (not format or format == '') and (format ~= '.nfp' and format ~= '.nft' and format ~= '.skch') then\
  1099.             format = GetFormat(path)\
  1100.         end\
  1101.         local layers = {}\
  1102.         if format == '.nfp' then\
  1103.             layers = ReadNFP(path)\
  1104.         elseif format == '.nft' then\
  1105.             layers = ReadNFT(path)      \
  1106.         elseif format == '.skch' then\
  1107.             layers = ReadSKCH(path)\
  1108.         end\
  1109. \
  1110.         for i, layer in ipairs(layers) do\
  1111.             if layer.Visible == nil then\
  1112.                 layer.Visible = true\
  1113.             end\
  1114.             if layer.Index == nil then\
  1115.                 layer.Index = 1\
  1116.             end\
  1117.             if layer.Name == nil then\
  1118.                 if layer.Index == 1 then\
  1119.                     layer.Name = 'Background'\
  1120.                 else\
  1121.                     layer.Name = 'Layer'\
  1122.                 end\
  1123.             end\
  1124. \
  1125.             if layer.LayerType == nil then\
  1126.                 layer.LayerType = 'Normal'\
  1127.             end\
  1128. \
  1129.             if layer.BackgroundColour == nil then\
  1130.                 layer.BackgroundColour = colours.white\
  1131.             end\
  1132.         end\
  1133. \
  1134.         if not layers or not layers[1] or not layers[1].Pixels then\
  1135.             program:DisplayAlertWindow('File Read Failed', 'The image file appears to be corrupt, maybe it is of a unsupported format?', {'Ok'})\
  1136.             return\
  1137.         end\
  1138. \
  1139.         local width = #layers[1].Pixels\
  1140.         local height = #layers[1].Pixels[1]\
  1141.         local _fs = fs\
  1142.         if OneOS then\
  1143.             _fs = OneOS.FS\
  1144.         end\
  1145. \
  1146.         return {\
  1147.             Width=width,\
  1148.             Height=height,\
  1149.             ImageName=_fs.getName(path),\
  1150.             ImagePath=path,\
  1151.             ImageFormat=format,\
  1152.             Layers=layers\
  1153.         }\
  1154.     end\
  1155. end",["Clipboard.lua"]="Content = nil\
  1156. Type = nil\
  1157. IsCut = false\
  1158. \
  1159. function Empty()\
  1160.     Clipboard.Content = nil\
  1161.     Clipboard.Type = nil\
  1162.     Clipboard.IsCut = false\
  1163. end\
  1164. \
  1165. function isEmpty()\
  1166.     return Clipboard.Content == nil\
  1167. end\
  1168. \
  1169. function Copy(content, _type)\
  1170.     Clipboard.Content = content\
  1171.     Clipboard.Type = _type or 'generic'\
  1172.     Clipboard.IsCut = false\
  1173. end\
  1174. \
  1175. function Cut(content, _type)\
  1176.     Clipboard.Content = content\
  1177.     Clipboard.Type = _type or 'generic'\
  1178.     Clipboard.IsCut = true\
  1179. end\
  1180. \
  1181. function Paste()\
  1182.     local c, t = Clipboard.Content, Clipboard.Type\
  1183.     if Clipboard.IsCut then\
  1184.         Clipboard.Empty()\
  1185.     end\
  1186.     return c, t\
  1187. end",["TextTool.lua"]="Name = 'Text'\
  1188. \
  1189. OnUse = function(artboard, event, side, x, y)\
  1190.     local layer = artboard:GetCurrentLayer()\
  1191.     if layer.Layer.LayerType ~= 'Normal' then\
  1192.         layer.Bedrock:DisplayAlertWindow('Tool Not Supported!', \"You cannot use the text tool on non-normal layers.\", {'Ok'}, function()end)\
  1193.     elseif side == 1 then\
  1194.         layer.CursorPos = {x, y}\
  1195.         layer.Bedrock:SetActiveObject(layer)\
  1196.     elseif side == 2 then\
  1197.         local pixels = layer:GetEffectedPixels(x, y, artboard.BrushSize, artboard.BrushShape, artboard.CorrectPixelRatio)\
  1198.         for i, pixel in ipairs(pixels) do\
  1199.             layer:SetPixel(pixel[1], pixel[2], nil, artboard.BrushColour)\
  1200.         end\
  1201.     end\
  1202. end\
  1203. \
  1204. OnStopUse = function(artboard)\
  1205.     local layer = artboard:GetCurrentLayer()\
  1206.     layer.Bedrock:SetActiveObject()\
  1207. end",["MoveTool.lua"]="Name = 'Move'\
  1208. \
  1209. OnUse = function(artboard, event, side, x, y)\
  1210.     if event == 'mouse_click' then\
  1211.         artboard.MoveHandle = {\
  1212.             X = x,\
  1213.             Y = y\
  1214.         }\
  1215.     elseif event == 'mouse_drag' then\
  1216.         if artboard.MoveHandle and artboard.MoveHandle.X and artboard.MoveHandle.Y then\
  1217.             artboard:GetCurrentLayer():Move(x - artboard.MoveHandle.X, y - artboard.MoveHandle.Y)\
  1218.             artboard.MoveHandle = {\
  1219.                 X = x,\
  1220.                 Y = y\
  1221.             }\
  1222.         end\
  1223.     end\
  1224. end",},["Resources"]={["circle.nft"]=" 7 7f  7 \
  1225. 7f   \
  1226.  7 7f  7 ",["square.nft"]="7f   \
  1227. 7f   \
  1228. 7f   ",["filterPreview.nft"]="3f  4 \
  1229. df   ",},["Views"]={["layerswindow.view"]="{\
  1230.     [\"Width\"]=20,\
  1231.     [\"Height\"]=9,\
  1232.     [\"BackgroundColour\"]=1,\
  1233.     [\"Children\"]={\
  1234.         [1]={\
  1235.             [\"Y\"]=1,\
  1236.             [\"X\"]=1,\
  1237.             [\"Width\"]=\"100%\",\
  1238.             [\"Height\"]=\"100%\",\
  1239.             [\"Type\"]=\"ScrollView\",\
  1240.             [\"Children\"]={\
  1241.             }\
  1242.         }\
  1243.     },\
  1244. }",["canvassizewindow.view"]="{\
  1245.     [\"Width\"]=28,\
  1246.     [\"Height\"]=10,\
  1247.     [\"BackgroundColour\"]=1,\
  1248.     [\"Children\"]={\
  1249.         [1]={\
  1250.             [\"Y\"]=2,\
  1251.             [\"X\"]=6,\
  1252.             [\"Align\"]=\"Center\",\
  1253.             [\"Type\"]=\"Label\",\
  1254.             [\"TextColour\"]=256,\
  1255.             [\"Text\"]=\"New Size\"\
  1256.         },\
  1257.         [2]={\
  1258.             [\"Y\"]=4,\
  1259.             [\"X\"]=3,\
  1260.             [\"Type\"]=\"Label\",\
  1261.             [\"TextColour\"]=32768,\
  1262.             [\"Text\"]=\"Width\"\
  1263.         },\
  1264.         [3]={\
  1265.             [\"Y\"]=4,\
  1266.             [\"X\"]=10,\
  1267.             [\"Name\"]=\"WidthNumberBox\",\
  1268.             [\"AutoWidth\"]=false,\
  1269.             [\"Type\"]=\"NumberBox\",\
  1270.             [\"Value\"]=1,\
  1271.         },\
  1272.         [4]={\
  1273.             [\"Y\"]=6,\
  1274.             [\"X\"]=3,\
  1275.             [\"Type\"]=\"Label\",\
  1276.             [\"TextColour\"]=32768,\
  1277.             [\"Text\"]=\"Height\"\
  1278.         },\
  1279.         [5]={\
  1280.             [\"Y\"]=6,\
  1281.             [\"X\"]=10,\
  1282.             [\"Name\"]=\"HeightNumberBox\",\
  1283.             [\"AutoWidth\"]=false,\
  1284.             [\"Type\"]=\"NumberBox\",\
  1285.             [\"Value\"]=1,\
  1286.         },\
  1287. \
  1288.         [6]={\
  1289.             [\"Y\"]=2,\
  1290.             [\"X\"]=20,\
  1291.             [\"Align\"]=\"Center\",\
  1292.             [\"Type\"]=\"Label\",\
  1293.             [\"TextColour\"]=256,\
  1294.             [\"Text\"]=\"Anchor\",\
  1295.         },\
  1296. \
  1297. \
  1298.         [7]={\
  1299.             [\"Y\"]=4,\
  1300.             [\"X\"]=21,\
  1301.             [\"Width\"]=1,\
  1302.             [\"AutoWidth\"]=false,\
  1303.             [\"Type\"]=\"Button\",\
  1304.             [\"Name\"]=\"Anchor1Button\",\
  1305.             [\"ActiveBackgroundColour\"]=256,\
  1306.             [\"ActiveTextColour\"]=32768,\
  1307.             [\"Text\"]=\" \"\
  1308.         },\
  1309.         [8]={\
  1310.             [\"Y\"]=4,\
  1311.             [\"X\"]=22,\
  1312.             [\"Width\"]=1,\
  1313.             [\"AutoWidth\"]=false,\
  1314.             [\"Type\"]=\"Button\",\
  1315.             [\"Name\"]=\"Anchor2Button\",\
  1316.             [\"ActiveBackgroundColour\"]=256,\
  1317.             [\"ActiveTextColour\"]=32768,\
  1318.             [\"Text\"]=\" \"\
  1319.         },\
  1320.         [9]={\
  1321.             [\"Y\"]=4,\
  1322.             [\"X\"]=23,\
  1323.             [\"Width\"]=1,\
  1324.             [\"AutoWidth\"]=false,\
  1325.             [\"Type\"]=\"Button\",\
  1326.             [\"Name\"]=\"Anchor3Button\",\
  1327.             [\"ActiveBackgroundColour\"]=256,\
  1328.             [\"ActiveTextColour\"]=32768,\
  1329.             [\"Text\"]=\" \"\
  1330.         },\
  1331.         [10]={\
  1332.             [\"Y\"]=5,\
  1333.             [\"X\"]=21,\
  1334.             [\"Width\"]=1,\
  1335.             [\"AutoWidth\"]=false,\
  1336.             [\"Type\"]=\"Button\",\
  1337.             [\"Name\"]=\"Anchor4Button\",\
  1338.             [\"ActiveBackgroundColour\"]=256,\
  1339.             [\"ActiveTextColour\"]=32768,\
  1340.             [\"Text\"]=\" \"\
  1341.         },\
  1342.         [11]={\
  1343.             [\"Y\"]=5,\
  1344.             [\"X\"]=22,\
  1345.             [\"Width\"]=1,\
  1346.             [\"AutoWidth\"]=false,\
  1347.             [\"Type\"]=\"Button\",\
  1348.             [\"Name\"]=\"Anchor5Button\",\
  1349.             [\"ActiveBackgroundColour\"]=256,\
  1350.             [\"ActiveTextColour\"]=32768,\
  1351.             [\"Text\"]=\" \"\
  1352.         },\
  1353.         [12]={\
  1354.             [\"Y\"]=5,\
  1355.             [\"X\"]=23,\
  1356.             [\"Width\"]=1,\
  1357.             [\"AutoWidth\"]=false,\
  1358.             [\"Type\"]=\"Button\",\
  1359.             [\"Name\"]=\"Anchor6Button\",\
  1360.             [\"ActiveBackgroundColour\"]=256,\
  1361.             [\"ActiveTextColour\"]=32768,\
  1362.             [\"Text\"]=\" \"\
  1363.         },\
  1364.         [13]={\
  1365.             [\"Y\"]=6,\
  1366.             [\"X\"]=21,\
  1367.             [\"Width\"]=1,\
  1368.             [\"AutoWidth\"]=false,\
  1369.             [\"Type\"]=\"Button\",\
  1370.             [\"Name\"]=\"Anchor7Button\",\
  1371.             [\"ActiveBackgroundColour\"]=256,\
  1372.             [\"ActiveTextColour\"]=32768,\
  1373.             [\"Text\"]=\" \"\
  1374.         },\
  1375.         [14]={\
  1376.             [\"Y\"]=6,\
  1377.             [\"X\"]=22,\
  1378.             [\"Width\"]=1,\
  1379.             [\"AutoWidth\"]=false,\
  1380.             [\"Type\"]=\"Button\",\
  1381.             [\"Name\"]=\"Anchor8Button\",\
  1382.             [\"ActiveBackgroundColour\"]=256,\
  1383.             [\"ActiveTextColour\"]=32768,\
  1384.             [\"Text\"]=\" \"\
  1385.         },\
  1386.         [15]={\
  1387.             [\"Y\"]=6,\
  1388.             [\"X\"]=23,\
  1389.             [\"Width\"]=1,\
  1390.             [\"AutoWidth\"]=false,\
  1391.             [\"Type\"]=\"Button\",\
  1392.             [\"Name\"]=\"Anchor9Button\",\
  1393.             [\"ActiveBackgroundColour\"]=256,\
  1394.             [\"ActiveTextColour\"]=32768,\
  1395.             [\"Text\"]=\" \"\
  1396.         },\
  1397. \
  1398. \
  1399. \
  1400. \
  1401.         [16]={\
  1402.             [\"Y\"]=\"100%,-1\",\
  1403.             [\"X\"]=\"100%,-13\",\
  1404.             [\"Type\"]=\"Button\",\
  1405.             [\"Name\"]=\"CancelButton\",\
  1406.             [\"Text\"]=\"Cancel\"\
  1407.         },\
  1408.         [17]={\
  1409.             [\"Y\"]=\"100%,-1\",\
  1410.             [\"X\"]=\"100%,-4\",\
  1411.             [\"Type\"]=\"Button\",\
  1412.             [\"Name\"]=\"OkButton\",\
  1413.             [\"Text\"]=\"Ok\"\
  1414.         },\
  1415.     },\
  1416. }",["sidebar.view"]="{\
  1417.  [\"Children\"]={\
  1418.    [1]={\
  1419.      [\"Y\"]=2,\
  1420.      [\"Type\"]=\"SidebarButton\",\
  1421.      [\"Name\"]=\"ColoursSidebarButton\",\
  1422.      [\"Text\"]=\"Col\",\
  1423.      [\"WindowName\"]=\"ColoursWindow\",\
  1424.      [\"Enabled\"]=false\
  1425.    },\
  1426.    [2]={\
  1427.      [\"Y\"]=4,\
  1428.      [\"Type\"]=\"SidebarButton\",\
  1429.      [\"Name\"]=\"ToolsSidebarButton\",\
  1430.      [\"Text\"]=\"Tol\",\
  1431.      [\"WindowName\"]=\"ToolsWindow\",\
  1432.      [\"Enabled\"]=false\
  1433.    },\
  1434.    [3]={\
  1435.      [\"Y\"]=6,\
  1436.      [\"Type\"]=\"SidebarButton\",\
  1437.      [\"Text\"]=\"Bru\",\
  1438.      [\"WindowName\"]=\"BrushWindow\",\
  1439.      [\"Enabled\"]=false\
  1440.    },\
  1441.    [4]={\
  1442.      [\"Y\"]=8,\
  1443.      [\"Type\"]=\"SidebarButton\",\
  1444.      [\"Text\"]=\"Lay\",\
  1445.      [\"WindowName\"]=\"LayersWindow\",\
  1446.      [\"Enabled\"]=false\
  1447.    },\
  1448.    [5]={\
  1449.      [\"Y\"]=10,\
  1450.      [\"Type\"]=\"SidebarButton\",\
  1451.      [\"Text\"]=\"Inf\",\
  1452.      [\"WindowName\"]=\"InfoWindow\",\
  1453.      [\"Enabled\"]=false\
  1454.    },\
  1455.    [6]={\
  1456.      [\"Y\"]=12,\
  1457.      [\"Type\"]=\"SidebarButton\",\
  1458.      [\"Text\"]=\"Flt\",\
  1459.      [\"WindowName\"]=\"FiltersWindow\",\
  1460.      [\"Enabled\"]=false\
  1461.    },\
  1462.  },\
  1463. }",["filterswindow.view"]="{\
  1464.     [\"Width\"]=22,\
  1465.     [\"Height\"]=14,\
  1466.     [\"BackgroundColour\"]=1,\
  1467.     [\"Children\"]={\
  1468.         [1]={\
  1469.             [\"Y\"]=1,\
  1470.             [\"X\"]=1,\
  1471.             [\"Width\"]=\"100%\",\
  1472.             [\"Height\"]=\"100%\",\
  1473.             [\"Type\"]=\"ScrollView\",\
  1474.             [\"Children\"]={\
  1475.                 [1]={\
  1476.                     [\"Y\"]=2,\
  1477.                     [\"X\"]=1,\
  1478.                     [\"Width\"]=\"100%\",\
  1479.                     [\"Type\"]=\"FilterPreview\",\
  1480.                     [\"Filter\"]=\"None\",\
  1481.                     [\"FilterName\"]=\"None\",\
  1482.                     [\"Enabled\"]=false,\
  1483.                     [\"TextColour\"]=256\
  1484.                 },\
  1485.                 [2]={\
  1486.                     [\"Y\"]=5,\
  1487.                     [\"X\"]=1,\
  1488.                     [\"Width\"]=\"100%\",\
  1489.                     [\"Type\"]=\"FilterPreview\",\
  1490.                     [\"Filter\"]=\"Greyscale\",\
  1491.                     [\"FilterName\"]=\"Greyscale\",\
  1492.                 },\
  1493.                 [3]={\
  1494.                     [\"Y\"]=8,\
  1495.                     [\"X\"]=1,\
  1496.                     [\"Width\"]=\"100%\",\
  1497.                     [\"Type\"]=\"FilterPreview\",\
  1498.                     [\"Filter\"]=\"BlackWhite\",\
  1499.                     [\"FilterName\"]=\"Black and White\",\
  1500.                 },\
  1501.                 [4]={\
  1502.                     [\"Y\"]=11,\
  1503.                     [\"X\"]=1,\
  1504.                     [\"Width\"]=\"100%\",\
  1505.                     [\"Type\"]=\"FilterPreview\",\
  1506.                     [\"Filter\"]=\"Darker\",\
  1507.                     [\"FilterName\"]=\"Darker\",\
  1508.                 },\
  1509.                 [5]={\
  1510.                     [\"Y\"]=14,\
  1511.                     [\"X\"]=1,\
  1512.                     [\"Width\"]=\"100%\",\
  1513.                     [\"Type\"]=\"FilterPreview\",\
  1514.                     [\"Filter\"]=\"Lighter\",\
  1515.                     [\"FilterName\"]=\"Lighter\",\
  1516.                 },\
  1517.                 [6]={\
  1518.                     [\"Y\"]=17,\
  1519.                     [\"X\"]=1,\
  1520.                     [\"Width\"]=\"100%\",\
  1521.                     [\"Type\"]=\"FilterPreview\",\
  1522.                     [\"Filter\"]=\"Invert\",\
  1523.                     [\"FilterName\"]=\"Invert\",\
  1524.                 },\
  1525.             }\
  1526.         }\
  1527.     },\
  1528. }",["infowindow.view"]="{\
  1529.     [\"Width\"]=13,\
  1530.     [\"Height\"]=13,\
  1531.     [\"BackgroundColour\"]=1,\
  1532.     [\"Children\"]={\
  1533.         [1]={\
  1534.             [\"Y\"]=2,\
  1535.             [\"X\"]=2,\
  1536.             [\"Type\"]=\"Label\",\
  1537.             [\"TextColour\"]=128,\
  1538.             [\"Text\"]=\"Canvas Size\"\
  1539.         },\
  1540.         [2]={\
  1541.             [\"Y\"]=3,\
  1542.             [\"X\"]=2,\
  1543.             [\"Type\"]=\"Label\",\
  1544.             [\"TextColour\"]=256,\
  1545.             [\"Text\"]=\"Width\"\
  1546.         },\
  1547.         [3]={\
  1548.             [\"Y\"]=3,\
  1549.             [\"X\"]=9,\
  1550.             [\"Width\"]=4,\
  1551.             [\"Align\"]=\"Left\",\
  1552.             [\"TextColour\"]=32768,\
  1553.             [\"Type\"]=\"Label\",\
  1554.             [\"Name\"]=\"CanvasWidthLabel\",\
  1555.             [\"Text\"]=\"-\"\
  1556.         },\
  1557.         [4]={\
  1558.             [\"Y\"]=4,\
  1559.             [\"X\"]=2,\
  1560.             [\"Type\"]=\"Label\",\
  1561.             [\"TextColour\"]=256,\
  1562.             [\"Text\"]=\"Height\"\
  1563.         },\
  1564.         [5]={\
  1565.             [\"Y\"]=4,\
  1566.             [\"X\"]=9,\
  1567.             [\"Width\"]=4,\
  1568.             [\"Align\"]=\"Left\",\
  1569.             [\"Type\"]=\"Label\",\
  1570.             [\"TextColour\"]=32768,\
  1571.             [\"Name\"]=\"CanvasHeightLabel\",\
  1572.             [\"Text\"]=\"-\"\
  1573.         },\
  1574. \
  1575.         [6]={\
  1576.             [\"Y\"]=6,\
  1577.             [\"X\"]=3,\
  1578.             [\"Type\"]=\"Label\",\
  1579.             [\"TextColour\"]=128,\
  1580.             [\"Text\"]=\"Selection\"\
  1581.         },\
  1582.         [7]={\
  1583.             [\"Y\"]=7,\
  1584.             [\"X\"]=2,\
  1585.             [\"Type\"]=\"Label\",\
  1586.             [\"TextColour\"]=256,\
  1587.             [\"Text\"]=\"Width\"\
  1588.         },\
  1589.         [8]={\
  1590.             [\"Y\"]=7,\
  1591.             [\"X\"]=9,\
  1592.             [\"Width\"]=4,\
  1593.             [\"Align\"]=\"Left\",\
  1594.             [\"Type\"]=\"Label\",\
  1595.             [\"TextColour\"]=32768,\
  1596.             [\"Name\"]=\"SelectionWidthLabel\",\
  1597.             [\"Text\"]=\"-\"\
  1598.         },\
  1599.         [9]={\
  1600.             [\"Y\"]=8,\
  1601.             [\"X\"]=2,\
  1602.             [\"Type\"]=\"Label\",\
  1603.             [\"TextColour\"]=256,\
  1604.             [\"Text\"]=\"Height\"\
  1605.         },\
  1606.         [10]={\
  1607.             [\"Y\"]=8,\
  1608.             [\"X\"]=9,\
  1609.             [\"Width\"]=4,\
  1610.             [\"Align\"]=\"Left\",\
  1611.             [\"Type\"]=\"Label\",\
  1612.             [\"TextColour\"]=32768,\
  1613.             [\"Name\"]=\"SelectionHeightLabel\",\
  1614.             [\"Text\"]=\"-\"\
  1615.         },\
  1616.         [11]={\
  1617.             [\"Y\"]=9,\
  1618.             [\"X\"]=4,\
  1619.             [\"Type\"]=\"Label\",\
  1620.             [\"TextColour\"]=256,\
  1621.             [\"Text\"]=\"X1\"\
  1622.         },\
  1623.         [12]={\
  1624.             [\"Y\"]=9,\
  1625.             [\"X\"]=9,\
  1626.             [\"Width\"]=4,\
  1627.             [\"Align\"]=\"Left\",\
  1628.             [\"Type\"]=\"Label\",\
  1629.             [\"TextColour\"]=32768,\
  1630.             [\"Name\"]=\"SelectionX1Label\",\
  1631.             [\"Text\"]=\"-\"\
  1632.         },\
  1633.         [13]={\
  1634.             [\"Y\"]=10,\
  1635.             [\"X\"]=4,\
  1636.             [\"Type\"]=\"Label\",\
  1637.             [\"TextColour\"]=256,\
  1638.             [\"Text\"]=\"Y1\"\
  1639.         },\
  1640.         [14]={\
  1641.             [\"Y\"]=10,\
  1642.             [\"X\"]=9,\
  1643.             [\"Width\"]=4,\
  1644.             [\"Align\"]=\"Left\",\
  1645.             [\"Type\"]=\"Label\",\
  1646.             [\"TextColour\"]=32768,\
  1647.             [\"Name\"]=\"SelectionY1Label\",\
  1648.             [\"Text\"]=\"-\"\
  1649.         },\
  1650.         [15]={\
  1651.             [\"Y\"]=11,\
  1652.             [\"X\"]=4,\
  1653.             [\"Type\"]=\"Label\",\
  1654.             [\"TextColour\"]=256,\
  1655.             [\"Text\"]=\"X2\"\
  1656.         },\
  1657.         [16]={\
  1658.             [\"Y\"]=11,\
  1659.             [\"X\"]=9,\
  1660.             [\"Width\"]=4,\
  1661.             [\"Align\"]=\"Left\",\
  1662.             [\"Type\"]=\"Label\",\
  1663.             [\"TextColour\"]=32768,\
  1664.             [\"Name\"]=\"SelectionX2Label\",\
  1665.             [\"Text\"]=\"-\"\
  1666.         },\
  1667.         [17]={\
  1668.             [\"Y\"]=12,\
  1669.             [\"X\"]=4,\
  1670.             [\"Type\"]=\"Label\",\
  1671.             [\"TextColour\"]=256,\
  1672.             [\"Text\"]=\"Y2\"\
  1673.         },\
  1674.         [18]={\
  1675.             [\"Y\"]=12,\
  1676.             [\"X\"]=9,\
  1677.             [\"Width\"]=4,\
  1678.             [\"Align\"]=\"Left\",\
  1679.             [\"Type\"]=\"Label\",\
  1680.             [\"TextColour\"]=32768,\
  1681.             [\"Name\"]=\"SelectionY2Label\",\
  1682.             [\"Text\"]=\"-\"\
  1683.         },\
  1684.         \
  1685.     }\
  1686. }",["toolbar.view"]="{\
  1687.  [\"Width\"]=\"100%\",\
  1688.  [\"Height\"]=1,\
  1689.  [\"Type\"]=\"View\",\
  1690.  [\"BackgroundColour\"]=128,\
  1691.  [\"Z\"]=100,\
  1692.  [\"Children\"]={\
  1693.    [1]={\
  1694.      [\"X\"]=1,\
  1695.      [\"Name\"]=\"FileMenuButton\",\
  1696.      [\"Type\"]=\"Button\",\
  1697.      [\"TextColour\"]=1,\
  1698.      [\"Text\"]=\"File\",\
  1699.      [\"BackgroundColour\"]=0,\
  1700.      [\"Toggle\"]=false\
  1701.    },\
  1702.    [2]={\
  1703.      [\"X\"]=7,\
  1704.      [\"Name\"]=\"EditMenuButton\",\
  1705.      [\"Type\"]=\"Button\",\
  1706.      [\"TextColour\"]=1,\
  1707.      [\"Text\"]=\"Edit\",\
  1708.      [\"BackgroundColour\"]=0,\
  1709.      [\"Toggle\"]=false\
  1710.    },\
  1711.    [3]={\
  1712.      [\"X\"]=13,\
  1713.      [\"Name\"]=\"ImageMenuButton\",\
  1714.      [\"Type\"]=\"Button\",\
  1715.      [\"TextColour\"]=1,\
  1716.      [\"Text\"]=\"Image\",\
  1717.      [\"BackgroundColour\"]=0,\
  1718.      [\"Toggle\"]=false\
  1719.    },\
  1720.    [4]={\
  1721.      [\"X\"]=20,\
  1722.      [\"Name\"]=\"ViewMenuButton\",\
  1723.      [\"Type\"]=\"Button\",\
  1724.      [\"TextColour\"]=1,\
  1725.      [\"Text\"]=\"View\",\
  1726.      [\"BackgroundColour\"]=0,\
  1727.      [\"Toggle\"]=false\
  1728.    },\
  1729.    [5]={\
  1730.      [\"X\"]=26,\
  1731.      [\"Name\"]=\"ToolsMenuButton\",\
  1732.      [\"Type\"]=\"Button\",\
  1733.      [\"TextColour\"]=1,\
  1734.      [\"Text\"]=\"Tools\",\
  1735.      [\"BackgroundColour\"]=0,\
  1736.      [\"Toggle\"]=false\
  1737.    },\
  1738. \
  1739.    [6]={\
  1740.      [\"Y\"]=1,\
  1741.      [\"X\"]=\"100%,-9\",\
  1742.      [\"Name\"]=\"CurrentToolLabel\",\
  1743.      [\"Type\"]=\"Label\",\
  1744.      [\"Width\"]=6,\
  1745.      [\"AutoWidth\"]=false,\
  1746.      [\"Height\"]=1,\
  1747.      [\"TextColour\"]=256,\
  1748.      [\"Text\"]=\"\",\
  1749.      [\"Align\"]=\"Right\"\
  1750.    },\
  1751.    [7]={\
  1752.      [\"Y\"]=1,\
  1753.      [\"X\"]=\"100%,-2\",\
  1754.      [\"Name\"]=\"PrimaryColourView\",\
  1755.      [\"Type\"]=\"View\",\
  1756.      [\"Width\"]=2,\
  1757.      [\"Height\"]=1,\
  1758.      [\"BackgroundColour\"]=0\
  1759.    },\
  1760.    [8]={\
  1761.      [\"Y\"]=1,\
  1762.      [\"X\"]=\"100%\",\
  1763.      [\"Name\"]=\"SecondaryColourView\",\
  1764.      [\"Type\"]=\"View\",\
  1765.      [\"Width\"]=1,\
  1766.      [\"Height\"]=1,\
  1767.      [\"BackgroundColour\"]=0\
  1768.    },\
  1769.  },\
  1770. }",["layermenu.view"]="{\
  1771.  [\"Type\"]=\"Menu\",\
  1772.  [\"Children\"]={\
  1773.    [1]={\
  1774.      [\"Name\"]=\"NewLayerMenuItem\",\
  1775.      [\"Type\"]=\"MenuItem\",\
  1776.      [\"Text\"]=\"New Layer...\"\
  1777.    },\
  1778.    [2]={\
  1779.      [\"Name\"]=\"Separator\",\
  1780.      [\"Type\"]=\"Separator\"\
  1781.    },\
  1782.    [3]={\
  1783.      [\"Name\"]=\"RenameLayerMenuItem\",\
  1784.      [\"Type\"]=\"MenuItem\",\
  1785.      [\"Text\"]=\"Rename Layer...\"\
  1786.    },\
  1787.    [4]={\
  1788.      [\"Name\"]=\"DeleteLayerMenuItem\",\
  1789.      [\"Type\"]=\"MenuItem\",\
  1790.      [\"Text\"]=\"Delete Layer\"\
  1791.    },\
  1792.    [5]={\
  1793.      [\"Name\"]=\"DuplicateLayerMenuItem\",\
  1794.      [\"Type\"]=\"MenuItem\",\
  1795.      [\"Text\"]=\"Duplicate Layer\"\
  1796.    },\
  1797.    [6]={\
  1798.      [\"Name\"]=\"MergeDownLayerMenuItem\",\
  1799.      [\"Type\"]=\"MenuItem\",\
  1800.      [\"Text\"]=\"Merge Down\"\
  1801.    },\
  1802.  },\
  1803. }",["toolsmenu.view"]="{\
  1804.  [\"Type\"]=\"Menu\",\
  1805.  [\"Owner\"]=\"ToolsMenuButton\",\
  1806.  [\"HideTop\"]=true,\
  1807.  [\"Children\"]={\
  1808.    [1]={\
  1809.      [\"Name\"]=\"ToolMenuItem\",\
  1810.      [\"ToolName\"]=\"HandTool\",\
  1811.      [\"Type\"]=\"MenuItem\",\
  1812.      [\"Text\"]=\"Hand\",\
  1813.      [\"Shortcut\"]=\"~H\"\
  1814.    },\
  1815.    [2]={\
  1816.      [\"Name\"]=\"ToolMenuItem\",\
  1817.      [\"ToolName\"]=\"PencilTool\",\
  1818.      [\"Type\"]=\"MenuItem\",\
  1819.      [\"Text\"]=\"Pencil\",\
  1820.      [\"Shortcut\"]=\"~P\"\
  1821.    },\
  1822.    [3]={\
  1823.      [\"Name\"]=\"ToolMenuItem\",\
  1824.      [\"ToolName\"]=\"FillTool\",\
  1825.      [\"Type\"]=\"MenuItem\",\
  1826.      [\"Text\"]=\"Fill\",\
  1827.      [\"Shortcut\"]=\"~F\"\
  1828.    },\
  1829.    [4]={\
  1830.      [\"Name\"]=\"ToolMenuItem\",\
  1831.      [\"ToolName\"]=\"EraserTool\",\
  1832.      [\"Type\"]=\"MenuItem\",\
  1833.      [\"Text\"]=\"Eraser\",\
  1834.      [\"Shortcut\"]=\"~E\"\
  1835.    },\
  1836.    [5]={\
  1837.      [\"Name\"]=\"ToolMenuItem\",\
  1838.      [\"ToolName\"]=\"TextTool\",\
  1839.      [\"Type\"]=\"MenuItem\",\
  1840.      [\"Text\"]=\"Text\",\
  1841.      [\"Shortcut\"]=\"~T\"\
  1842.    },\
  1843.    [6]={\
  1844.      [\"Name\"]=\"ToolMenuItem\",\
  1845.      [\"ToolName\"]=\"SprayTool\",\
  1846.      [\"Type\"]=\"MenuItem\",\
  1847.      [\"Text\"]=\"Spray\",\
  1848.      [\"Shortcut\"]=\"~R\"\
  1849.    },\
  1850.    [7]={\
  1851.      [\"Name\"]=\"ToolMenuItem\",\
  1852.      [\"ToolName\"]=\"MoveTool\",\
  1853.      [\"Type\"]=\"MenuItem\",\
  1854.      [\"Text\"]=\"Move\",\
  1855.      [\"Shortcut\"]=\"~M\"\
  1856.    },\
  1857.    [8]={\
  1858.      [\"Name\"]=\"ToolMenuItem\",\
  1859.      [\"ToolName\"]=\"SelectTool\",\
  1860.      [\"Type\"]=\"MenuItem\",\
  1861.      [\"Text\"]=\"Select\",\
  1862.      [\"Shortcut\"]=\"~S\"\
  1863.    },\
  1864.  },\
  1865. }",["imagemenu.view"]="{\
  1866.  [\"Type\"]=\"Menu\",\
  1867.  [\"Owner\"]=\"ImageMenuButton\",\
  1868.  [\"HideTop\"]=true,\
  1869.  [\"Children\"]={\
  1870.    [1]={\
  1871.      [\"Name\"]=\"ResizeMenuItem\",\
  1872.      [\"Type\"]=\"MenuItem\",\
  1873.      [\"Text\"]=\"Resize Image...\",\
  1874.      [\"Shortcut\"]=\"~#I\"\
  1875.    },\
  1876.    [2]={\
  1877.      [\"Name\"]=\"CanvasSizeMenuItem\",\
  1878.      [\"Type\"]=\"MenuItem\",\
  1879.      [\"Text\"]=\"Canvas Size...\",\
  1880.      [\"Shortcut\"]=\"~#C\"\
  1881.    },\
  1882.    [3]={\
  1883.      [\"Name\"]=\"CropMenuItem\",\
  1884.      [\"Type\"]=\"MenuItem\",\
  1885.      [\"Text\"]=\"Crop\",\
  1886.      [\"Shortcut\"]=\"~#X\"\
  1887.    },\
  1888.    [4]={\
  1889.      [\"Name\"]=\"Separator\",\
  1890.      [\"Type\"]=\"Separator\"\
  1891.    },\
  1892.    [5]={\
  1893.      [\"Name\"]=\"NewLayerImageMenuItem\",\
  1894.      [\"Type\"]=\"MenuItem\",\
  1895.      [\"Text\"]=\"New Layer\",\
  1896.      [\"Shortcut\"]=\"#L\"\
  1897.    },\
  1898.    [6]={\
  1899.      [\"Name\"]=\"Separator\",\
  1900.      [\"Type\"]=\"Separator\"\
  1901.    },\
  1902.    [7]={\
  1903.      [\"Name\"]=\"EraseMenuItem\",\
  1904.      [\"Type\"]=\"MenuItem\",\
  1905.      [\"Text\"]=\"Erase Selection\",\
  1906.      [\"Shortcut\"]=\"<\"\
  1907.    },\
  1908.    [8]={\
  1909.      [\"Name\"]=\"Separator\",\
  1910.      [\"Type\"]=\"Separator\"\
  1911.    },\
  1912.    [9]={\
  1913.      [\"Name\"]=\"FlattenMenuItem\",\
  1914.      [\"Type\"]=\"MenuItem\",\
  1915.      [\"Text\"]=\"Flatten Image\",\
  1916.      [\"Shortcut\"]=\"#F\"\
  1917.    }\
  1918.  },\
  1919. }",["saveasformatwindow.view"]="{\
  1920.     [\"Width\"]=30,\
  1921.     [\"Height\"]=15,\
  1922.     [\"BackgroundColour\"]=1,\
  1923.     [\"Children\"]={\
  1924.         [1]={\
  1925.             [\"Y\"]=2,\
  1926.             [\"X\"]=1,\
  1927.             [\"Width\"]=\"100%\",\
  1928.             [\"Align\"]=\"Center\",\
  1929.             [\"Type\"]=\"Label\",\
  1930.             [\"TextColour\"]=128,\
  1931.             [\"Text\"]=\"Choose Image Format\"\
  1932.         },\
  1933.         [2]={\
  1934.             [\"Y\"]=4,\
  1935.             [\"X\"]=2,\
  1936.             [\"Width\"]=1,\
  1937.             [\"Name\"]=\"FormatButton\",\
  1938.             [\"Format\"]=\"skch\",\
  1939.             [\"AutoWidth\"]=false,\
  1940.             [\"Type\"]=\"Button\",\
  1941.             [\"Toggle\"]=true,\
  1942.             [\"ActiveBackgroundColour\"]=2048,\
  1943.             [\"ActiveTextColour\"]=1,\
  1944.             [\"TextColour\"]=256,\
  1945.             [\"Text\"]=\"x\",\
  1946.         },\
  1947.         [3]={\
  1948.             [\"Y\"]=4,\
  1949.             [\"X\"]=4,\
  1950.             [\"Type\"]=\"Label\",\
  1951.             [\"TextColour\"]=128,\
  1952.             [\"Text\"]=\"Sketch (skch)\"\
  1953.         },\
  1954.         [4]={\
  1955.             [\"Y\"]=5,\
  1956.             [\"X\"]=4,\
  1957.             [\"Width\"]=\"100%,-4\",\
  1958.             [\"Type\"]=\"Label\",\
  1959.             [\"TextColour\"]=256,\
  1960.             [\"Text\"]=\"Supports layers, filters, colour and text.\"\
  1961.         },\
  1962. \
  1963. \
  1964.         [5]={\
  1965.             [\"Y\"]=8,\
  1966.             [\"X\"]=2,\
  1967.             [\"Width\"]=1,\
  1968.             [\"Name\"]=\"FormatButton\",\
  1969.             [\"Format\"]=\"nft\",\
  1970.             [\"AutoWidth\"]=false,\
  1971.             [\"Type\"]=\"Button\",\
  1972.             [\"Toggle\"]=false,\
  1973.             [\"ActiveBackgroundColour\"]=2048,\
  1974.             [\"ActiveTextColour\"]=1,\
  1975.             [\"TextColour\"]=256,\
  1976.             [\"Text\"]=\"x\",\
  1977.         },\
  1978.         [6]={\
  1979.             [\"Y\"]=8,\
  1980.             [\"X\"]=4,\
  1981.             [\"Type\"]=\"Label\",\
  1982.             [\"TextColour\"]=128,\
  1983.             [\"Text\"]=\"NitroFingers Text (nft)\"\
  1984.         },\
  1985.         [7]={\
  1986.             [\"Y\"]=9,\
  1987.             [\"X\"]=4,\
  1988.             [\"Width\"]=\"100%,-4\",\
  1989.             [\"Type\"]=\"Label\",\
  1990.             [\"TextColour\"]=256,\
  1991.             [\"Text\"]=\"Supports colour and text.\"\
  1992.         },\
  1993. \
  1994. \
  1995.         [8]={\
  1996.             [\"Y\"]=11,\
  1997.             [\"X\"]=2,\
  1998.             [\"Width\"]=1,\
  1999.             [\"Name\"]=\"FormatButton\",\
  2000.             [\"Format\"]=\"nfp\",\
  2001.             [\"AutoWidth\"]=false,\
  2002.             [\"Type\"]=\"Button\",\
  2003.             [\"Toggle\"]=false,\
  2004.             [\"ActiveBackgroundColour\"]=2048,\
  2005.             [\"ActiveTextColour\"]=1,\
  2006.             [\"TextColour\"]=256,\
  2007.             [\"Text\"]=\"x\",\
  2008.         },\
  2009.         [9]={\
  2010.             [\"Y\"]=11,\
  2011.             [\"X\"]=4,\
  2012.             [\"Type\"]=\"Label\",\
  2013.             [\"TextColour\"]=128,\
  2014.             [\"Text\"]=\"NitroFingers Paint (nfp)\"\
  2015.         },\
  2016.         [10]={\
  2017.             [\"Y\"]=12,\
  2018.             [\"X\"]=4,\
  2019.             [\"Width\"]=\"100%,-4\",\
  2020.             [\"Type\"]=\"Label\",\
  2021.             [\"TextColour\"]=256,\
  2022.             [\"Text\"]=\"Supports colour.\"\
  2023.         },\
  2024. \
  2025. \
  2026.         [11]={\
  2027.             [\"Y\"]=\"100%,-1\",\
  2028.             [\"X\"]=\"100%,-16\",\
  2029.             [\"Type\"]=\"Button\",\
  2030.             [\"Name\"]=\"CancelButton\",\
  2031.             [\"Text\"]=\"Cancel\"\
  2032.         },\
  2033.         [12]={\
  2034.             [\"Y\"]=\"100%,-1\",\
  2035.             [\"X\"]=\"100%,-6\",\
  2036.             [\"Type\"]=\"Button\",\
  2037.             [\"Name\"]=\"NextButton\",\
  2038.             [\"Text\"]=\"Next\"\
  2039.         },\
  2040.     },\
  2041. }",["sizepresetmenu.view"]="{\
  2042.  [\"Type\"]=\"Menu\",\
  2043.  [\"HideTop\"]=true,\
  2044.  [\"Children\"]={\
  2045.    [1]={\
  2046.      [\"Name\"]=\"CustomMenuItem\",\
  2047.      [\"Type\"]=\"MenuItem\",\
  2048.      [\"Text\"]=\"Custom\",\
  2049.    },\
  2050.    [2]={\
  2051.      [\"Type\"]=\"MenuItem\",\
  2052.      [\"Name\"]=\"PresetMenuItem\",\
  2053.      [\"Text\"]=\"OneOS Icon\",\
  2054.      [\"SizeWidth\"]=4,\
  2055.      [\"SizeHeight\"]=3,\
  2056.    },\
  2057.    [3]={\
  2058.      [\"Type\"]=\"MenuItem\",\
  2059.      [\"Name\"]=\"PresetMenuItem\",\
  2060.      [\"Text\"]=\"Computer Screen\",\
  2061.      [\"SizeWidth\"]=51,\
  2062.      [\"SizeHeight\"]=19,\
  2063.    },\
  2064.    [4]={\
  2065.      [\"Type\"]=\"MenuItem\",\
  2066.      [\"Name\"]=\"PresetMenuItem\",\
  2067.      [\"Text\"]=\"Pocket Computer Screen\",\
  2068.      [\"SizeWidth\"]=26,\
  2069.      [\"SizeHeight\"]=19,\
  2070.    },\
  2071.    [5]={\
  2072.      [\"Type\"]=\"MenuItem\",\
  2073.      [\"Name\"]=\"PresetMenuItem\",\
  2074.      [\"Text\"]=\"Turtle Screen\",\
  2075.      [\"SizeWidth\"]=39,\
  2076.      [\"SizeHeight\"]=13,\
  2077.    },\
  2078.  },\
  2079. }",["resizewindow.view"]="{\
  2080.     [\"Width\"]=20,\
  2081.     [\"Height\"]=13,\
  2082.     [\"BackgroundColour\"]=1,\
  2083.     [\"Children\"]={\
  2084.         [1]={\
  2085.             [\"Y\"]=2,\
  2086.             [\"X\"]=1,\
  2087.             [\"Width\"]=\"100%\",\
  2088.             [\"Align\"]=\"Center\",\
  2089.             [\"Type\"]=\"Label\",\
  2090.             [\"TextColour\"]=256,\
  2091.             [\"Text\"]=\"Stretch/Shrink\"\
  2092.         },\
  2093. \
  2094.         [2]={\
  2095.             [\"Y\"]=4,\
  2096.             [\"X\"]=4,\
  2097.             [\"Type\"]=\"Label\",\
  2098.             [\"TextColour\"]=32768,\
  2099.             [\"Text\"]=\"Width\"\
  2100.         },\
  2101.         [3]={\
  2102.             [\"Y\"]=4,\
  2103.             [\"X\"]=11,\
  2104.             [\"Name\"]=\"WidthNumberBox\",\
  2105.             [\"AutoWidth\"]=false,\
  2106.             [\"Type\"]=\"NumberBox\",\
  2107.             [\"Value\"]=1,\
  2108.         },\
  2109.         [4]={\
  2110.             [\"Y\"]=6,\
  2111.             [\"X\"]=4,\
  2112.             [\"Type\"]=\"Label\",\
  2113.             [\"TextColour\"]=32768,\
  2114.             [\"Text\"]=\"Height\"\
  2115.         },\
  2116.         [5]={\
  2117.             [\"Y\"]=6,\
  2118.             [\"X\"]=11,\
  2119.             [\"Name\"]=\"HeightNumberBox\",\
  2120.             [\"AutoWidth\"]=false,\
  2121.             [\"Type\"]=\"NumberBox\",\
  2122.             [\"Value\"]=1,\
  2123.         },\
  2124. \
  2125.         [6]={\
  2126.             [\"Y\"]=8,\
  2127.             [\"X\"]=2,\
  2128.             [\"Width\"]=1,\
  2129.             [\"Name\"]=\"ProportionsButton\",\
  2130.             [\"AutoWidth\"]=false,\
  2131.             [\"Type\"]=\"Button\",\
  2132.             [\"Toggle\"]=true,\
  2133.             [\"ActiveBackgroundColour\"]=2048,\
  2134.             [\"ActiveTextColour\"]=1,\
  2135.             [\"TextColour\"]=256,\
  2136.             [\"Text\"]=\"x\",\
  2137.         },\
  2138.         [7]={\
  2139.             [\"Y\"]=8,\
  2140.             [\"X\"]=4,\
  2141.             [\"Type\"]=\"Label\",\
  2142.             [\"TextColour\"]=128,\
  2143.             [\"Text\"]=\"Lock Proportions\"\
  2144.         },\
  2145.         [8]={\
  2146.             [\"Y\"]=10,\
  2147.             [\"X\"]=2,\
  2148.             [\"Width\"]=1,\
  2149.             [\"Name\"]=\"TextDetailButton\",\
  2150.             [\"AutoWidth\"]=false,\
  2151.             [\"Type\"]=\"Button\",\
  2152.             [\"Toggle\"]=true,\
  2153.             [\"ActiveBackgroundColour\"]=2048,\
  2154.             [\"ActiveTextColour\"]=1,\
  2155.             [\"TextColour\"]=256,\
  2156.             [\"Text\"]=\"x\",\
  2157.         },\
  2158.         [9]={\
  2159.             [\"Y\"]=10,\
  2160.             [\"X\"]=4,\
  2161.             [\"Type\"]=\"Label\",\
  2162.             [\"TextColour\"]=128,\
  2163.             [\"Text\"]=\"Keep Text Detail\"\
  2164.         },\
  2165. \
  2166.         [10]={\
  2167.             [\"Y\"]=\"100%,-1\",\
  2168.             [\"X\"]=\"100%,-17\",\
  2169.             [\"Type\"]=\"Button\",\
  2170.             [\"Name\"]=\"CancelButton\",\
  2171.             [\"Text\"]=\"Cancel\"\
  2172.         },\
  2173.         [11]={\
  2174.             [\"Y\"]=\"100%,-1\",\
  2175.             [\"X\"]=\"100%,-8\",\
  2176.             [\"Type\"]=\"Button\",\
  2177.             [\"Name\"]=\"ResizeButton\",\
  2178.             [\"Text\"]=\"Resize\"\
  2179.         },\
  2180.     },\
  2181. }",["brushwindow.view"]="{\
  2182.     [\"Width\"]=13,\
  2183.     [\"Height\"]=9,\
  2184.     [\"BackgroundColour\"]=1,\
  2185.     [\"Children\"]={\
  2186.         [1]={\
  2187.             [\"Y\"]=2,\
  2188.             [\"X\"]=2,\
  2189.             [\"Type\"]=\"Label\",\
  2190.             [\"TextColour\"]=256,\
  2191.             [\"Text\"]=\"Size\"\
  2192.         },\
  2193.         [2]={\
  2194.             [\"Y\"]=2,\
  2195.             [\"X\"]=7,\
  2196.             [\"Width\"]=6,\
  2197.             [\"Type\"]=\"NumberBox\",\
  2198.             [\"TextColour\"]=128,\
  2199.             [\"Text\"]=\"2\",\
  2200.         },\
  2201.         [3]={\
  2202.             [\"Y\"]=4,\
  2203.             [\"X\"]=2,\
  2204.             [\"Type\"]=\"Label\",\
  2205.             [\"TextColour\"]=256,\
  2206.             [\"Text\"]=\"Shape\"\
  2207.         },\
  2208.         [4]={\
  2209.             [\"Y\"]=6,\
  2210.             [\"X\"]=3,\
  2211.             [\"Width\"]=3,\
  2212.             [\"Height\"]=3,\
  2213.             [\"Type\"]=\"ImageView\",\
  2214.             [\"Name\"]=\"SquareImageView\",\
  2215.             [\"Path\"]=\"Resources/square.nft\"\
  2216.         },\
  2217.         [5]={\
  2218.             [\"Y\"]=6,\
  2219.             [\"X\"]=9,\
  2220.             [\"Width\"]=3,\
  2221.             [\"Height\"]=3,\
  2222.             [\"Type\"]=\"ImageView\",\
  2223.             [\"Name\"]=\"CircleImageView\",\
  2224.             [\"Path\"]=\"Resources/circle.nft\"\
  2225.         },\
  2226.     },\
  2227. }",["newdocumentwindow.view"]="{\
  2228.     [\"Width\"]=29,\
  2229.     [\"Height\"]=11,\
  2230.     [\"BackgroundColour\"]=1,\
  2231.     [\"Children\"]={\
  2232.         [1]={\
  2233.             [\"Y\"]=2,\
  2234.             [\"X\"]=1,\
  2235.             [\"Width\"]=15,\
  2236.             [\"Align\"]=\"Center\",\
  2237.             [\"Type\"]=\"Label\",\
  2238.             [\"TextColour\"]=128,\
  2239.             [\"Text\"]=\"Size\"\
  2240.         },\
  2241.         [2]={\
  2242.             [\"Y\"]=4,\
  2243.             [\"X\"]=2,\
  2244.             [\"Width\"]=15,\
  2245.             [\"Name\"]=\"PresetButton\",\
  2246.             [\"Type\"]=\"Button\",\
  2247.             [\"Text\"]=\"Custom      V\",\
  2248.             [\"Toggle\"]=false\
  2249.         },\
  2250.         [3]={\
  2251.             [\"Y\"]=6,\
  2252.             [\"X\"]=2,\
  2253.             [\"Type\"]=\"Label\",\
  2254.             [\"TextColour\"]=128,\
  2255.             [\"Text\"]=\"Width\"\
  2256.         },\
  2257.         [4]={\
  2258.             [\"Y\"]=6,\
  2259.             [\"X\"]=9,\
  2260.             [\"Width\"]=7,\
  2261.             [\"Name\"]=\"WidthNumberBox\",\
  2262.             [\"Type\"]=\"NumberBox\",\
  2263.             [\"Minimum\"]=1,\
  2264.             [\"Value\"]=15,\
  2265.         },\
  2266.         [5]={\
  2267.             [\"Y\"]=8,\
  2268.             [\"X\"]=2,\
  2269.             [\"Type\"]=\"Label\",\
  2270.             [\"TextColour\"]=128,\
  2271.             [\"Text\"]=\"Height\"\
  2272.         },\
  2273.         [6]={\
  2274.             [\"Y\"]=8,\
  2275.             [\"X\"]=9,\
  2276.             [\"Width\"]=7,\
  2277.             [\"Name\"]=\"HeightNumberBox\",\
  2278.             [\"Type\"]=\"NumberBox\",\
  2279.             [\"Minimum\"]=1,\
  2280.             [\"Value\"]=10,\
  2281.         },\
  2282. \
  2283.         [7]={\
  2284.             [\"Y\"]=1,\
  2285.             [\"X\"]=17,\
  2286.             [\"Height\"]=\"100%,-3\",\
  2287.             [\"Type\"]=\"Separator\",\
  2288.             [\"Minimum\"]=1,\
  2289.             [\"Value\"]=15,\
  2290.         },\
  2291. \
  2292.         [8]={\
  2293.             [\"Y\"]=2,\
  2294.             [\"X\"]=19,\
  2295.             [\"Width\"]=10,\
  2296.             [\"Align\"]=\"Center\",\
  2297.             [\"Type\"]=\"Label\",\
  2298.             [\"TextColour\"]=128,\
  2299.             [\"Text\"]=\"Background\"\
  2300.         },\
  2301. \
  2302. \
  2303.         [9]={\
  2304.             [\"X\"]=19,\
  2305.             [\"Y\"]=4,\
  2306.             [\"Name\"]=\"CurrentColourButton\",\
  2307.             [\"Type\"]=\"ColourView\",\
  2308.             [\"Width\"]=3,\
  2309.             [\"Height\"]=1,\
  2310.             [\"BackgroundColour\"]=0,\
  2311.             [\"ActiveBackgroundColour\"]=0\
  2312.         },\
  2313.         [10]={\
  2314.             [\"X\"]=23,\
  2315.             [\"Y\"]=4,\
  2316.             [\"Name\"]=\"NoneColourButton\",\
  2317.             [\"Type\"]=\"Button\",\
  2318.             [\"Height\"]=1,\
  2319.             [\"Text\"]=\"None\"\
  2320.         },\
  2321.         [11]={\
  2322.             [\"Y\"]=6,\
  2323.             [\"X\"]=20,\
  2324.             [\"Type\"]=\"Button\",\
  2325.             [\"Name\"]=\"BackgroundColourButton\",\
  2326.             [\"Width\"]=1,\
  2327.             [\"Height\"]=1,\
  2328.             [\"BackgroundColour\"]=1,\
  2329.             [\"ActiveBackgroundColour\"]=1\
  2330.         },\
  2331.         [12]={\
  2332.             [\"Y\"]=6,\
  2333.             [\"X\"]=21,\
  2334.             [\"Type\"]=\"Button\",\
  2335.             [\"Name\"]=\"BackgroundColourButton\",\
  2336.             [\"Width\"]=1,\
  2337.             [\"Height\"]=1,\
  2338.             [\"BackgroundColour\"]=16,\
  2339.             [\"ActiveBackgroundColour\"]=16\
  2340.         },\
  2341.         [13]={\
  2342.             [\"Y\"]=6,\
  2343.             [\"X\"]=22,\
  2344.             [\"Type\"]=\"Button\",\
  2345.             [\"Name\"]=\"BackgroundColourButton\",\
  2346.             [\"Width\"]=1,\
  2347.             [\"Height\"]=1,\
  2348.             [\"BackgroundColour\"]=2,\
  2349.             [\"ActiveBackgroundColour\"]=2\
  2350.         },\
  2351.         [14]={\
  2352.             [\"Y\"]=6,\
  2353.             [\"X\"]=23,\
  2354.             [\"Type\"]=\"Button\",\
  2355.             [\"Name\"]=\"BackgroundColourButton\",\
  2356.             [\"Width\"]=1,\
  2357.             [\"Height\"]=1,\
  2358.             [\"BackgroundColour\"]=16384,\
  2359.             [\"ActiveBackgroundColour\"]=16384\
  2360.         },\
  2361. \
  2362.         [15]={\
  2363.             [\"Y\"]=6,\
  2364.             [\"X\"]=24,\
  2365.             [\"Type\"]=\"Button\",\
  2366.             [\"Name\"]=\"BackgroundColourButton\",\
  2367.             [\"Width\"]=1,\
  2368.             [\"Height\"]=1,\
  2369.             [\"BackgroundColour\"]=8192,\
  2370.             [\"ActiveBackgroundColour\"]=8192\
  2371.         },\
  2372.         [16]={\
  2373.             [\"Y\"]=6,\
  2374.             [\"X\"]=25,\
  2375.             [\"Type\"]=\"Button\",\
  2376.             [\"Name\"]=\"BackgroundColourButton\",\
  2377.             [\"Width\"]=1,\
  2378.             [\"Height\"]=1,\
  2379.             [\"BackgroundColour\"]=32,\
  2380.             [\"ActiveBackgroundColour\"]=32\
  2381.         },\
  2382.         [17]={\
  2383.             [\"Y\"]=6,\
  2384.             [\"X\"]=26,\
  2385.             [\"Type\"]=\"Button\",\
  2386.             [\"Name\"]=\"BackgroundColourButton\",\
  2387.             [\"Width\"]=1,\
  2388.             [\"Height\"]=1,\
  2389.             [\"BackgroundColour\"]=4,\
  2390.             [\"ActiveBackgroundColour\"]=4\
  2391.         },\
  2392.         [18]={\
  2393.             [\"Y\"]=6,\
  2394.             [\"X\"]=27,\
  2395.             [\"Type\"]=\"Button\",\
  2396.             [\"Name\"]=\"BackgroundColourButton\",\
  2397.             [\"Width\"]=1,\
  2398.             [\"Height\"]=1,\
  2399.             [\"BackgroundColour\"]=64,\
  2400.             [\"ActiveBackgroundColour\"]=64\
  2401.         },\
  2402. \
  2403.         [19]={\
  2404.             [\"Y\"]=7,\
  2405.             [\"X\"]=20,\
  2406.             [\"Type\"]=\"Button\",\
  2407.             [\"Name\"]=\"BackgroundColourButton\",\
  2408.             [\"Width\"]=1,\
  2409.             [\"Height\"]=1,\
  2410.             [\"BackgroundColour\"]=1024,\
  2411.             [\"ActiveBackgroundColour\"]=1024\
  2412.         },\
  2413.         [20]={\
  2414.             [\"Y\"]=7,\
  2415.             [\"X\"]=21,\
  2416.             [\"Type\"]=\"Button\",\
  2417.             [\"Name\"]=\"BackgroundColourButton\",\
  2418.             [\"Width\"]=1,\
  2419.             [\"Height\"]=1,\
  2420.             [\"BackgroundColour\"]=2048,\
  2421.             [\"ActiveBackgroundColour\"]=2048\
  2422.         },\
  2423.         [21]={\
  2424.             [\"Y\"]=7,\
  2425.             [\"X\"]=22,\
  2426.             [\"Type\"]=\"Button\",\
  2427.             [\"Name\"]=\"BackgroundColourButton\",\
  2428.             [\"Width\"]=1,\
  2429.             [\"Height\"]=1,\
  2430.             [\"BackgroundColour\"]=512,\
  2431.             [\"ActiveBackgroundColour\"]=512\
  2432.         },\
  2433.         [22]={\
  2434.             [\"Y\"]=7,\
  2435.             [\"X\"]=23,\
  2436.             [\"Type\"]=\"Button\",\
  2437.             [\"Name\"]=\"BackgroundColourButton\",\
  2438.             [\"Width\"]=1,\
  2439.             [\"Height\"]=1,\
  2440.             [\"BackgroundColour\"]=8,\
  2441.             [\"ActiveBackgroundColour\"]=8\
  2442.         },\
  2443. \
  2444.         [23]={\
  2445.             [\"Y\"]=7,\
  2446.             [\"X\"]=24,\
  2447.             [\"Type\"]=\"Button\",\
  2448.             [\"Name\"]=\"BackgroundColourButton\",\
  2449.             [\"Width\"]=1,\
  2450.             [\"Height\"]=1,\
  2451.             [\"BackgroundColour\"]=256,\
  2452.             [\"ActiveBackgroundColour\"]=256\
  2453.         },\
  2454.         [24]={\
  2455.             [\"Y\"]=7,\
  2456.             [\"X\"]=25,\
  2457.             [\"Type\"]=\"Button\",\
  2458.             [\"Name\"]=\"BackgroundColourButton\",\
  2459.             [\"Width\"]=1,\
  2460.             [\"Height\"]=1,\
  2461.             [\"BackgroundColour\"]=128,\
  2462.             [\"ActiveBackgroundColour\"]=128\
  2463.         },\
  2464.         [25]={\
  2465.             [\"Y\"]=7,\
  2466.             [\"X\"]=26,\
  2467.             [\"Type\"]=\"Button\",\
  2468.             [\"Name\"]=\"BackgroundColourButton\",\
  2469.             [\"Width\"]=1,\
  2470.             [\"Height\"]=1,\
  2471.             [\"BackgroundColour\"]=32768,\
  2472.             [\"ActiveBackgroundColour\"]=32768\
  2473.         },\
  2474.         [26]={\
  2475.             [\"Y\"]=7,\
  2476.             [\"X\"]=27,\
  2477.             [\"Type\"]=\"Button\",\
  2478.             [\"Name\"]=\"BackgroundColourButton\",\
  2479.             [\"Width\"]=1,\
  2480.             [\"Height\"]=1,\
  2481.             [\"BackgroundColour\"]=4096,\
  2482.             [\"ActiveBackgroundColour\"]=4096\
  2483.         },\
  2484. \
  2485. \
  2486. \
  2487.         [27]={\
  2488.             [\"Y\"]=\"100%,-1\",\
  2489.             [\"X\"]=\"100%,-13\",\
  2490.             [\"Type\"]=\"Button\",\
  2491.             [\"Name\"]=\"CancelButton\",\
  2492.             [\"Text\"]=\"Cancel\"\
  2493.         },\
  2494.         [28]={\
  2495.             [\"Y\"]=\"100%,-1\",\
  2496.             [\"X\"]=\"100%,-4\",\
  2497.             [\"Type\"]=\"Button\",\
  2498.             [\"Name\"]=\"OkButton\",\
  2499.             [\"Text\"]=\"Ok\"\
  2500.         },\
  2501.     },\
  2502. }",["main.view"]="{\
  2503.  [\"Children\"]={\
  2504.    [1]={\
  2505.      [\"Y\"]=1,\
  2506.      [\"X\"]=1,\
  2507.      [\"Name\"]=\"Toolbar\",\
  2508.      [\"Type\"]=\"View\",\
  2509.      [\"InheritView\"]=\"toolbar\"\
  2510.    },\
  2511.    [2]={\
  2512.      [\"Y\"]=2,\
  2513.      [\"X\"]=\"100%,-2\",\
  2514.      [\"Type\"]=\"Sidebar\",\
  2515.      [\"InheritView\"]=\"sidebar\",\
  2516.      [\"Height\"]=\"100%,-1\",\
  2517.      [\"Width\"]=3\
  2518.    },\
  2519.  },\
  2520.  [\"BackgroundColour\"]=32768,\
  2521.  [\"ToolBarColour\"]=128,\
  2522.  [\"ToolBarTextColour\"]=1\
  2523. }",["editmenu.view"]="{\
  2524.  [\"Type\"]=\"Menu\",\
  2525.  [\"Owner\"]=\"EditMenuButton\",\
  2526.  [\"HideTop\"]=true,\
  2527.  [\"Children\"]={\
  2528.    [1]={\
  2529.      [\"Name\"]=\"UndoMenuItem\",\
  2530.      [\"Type\"]=\"MenuItem\",\
  2531.      [\"Text\"]=\"Undo\",\
  2532.      [\"Shortcut\"]=\"#Z\"\
  2533.    },\
  2534.    [2]={\
  2535.      [\"Name\"]=\"RedoMenuItem\",\
  2536.      [\"Type\"]=\"MenuItem\",\
  2537.      [\"Text\"]=\"Redo\",\
  2538.      [\"Shortcut\"]=\"#Y\"\
  2539.    },\
  2540.    [3]={\
  2541.      [\"Name\"]=\"Separator\",\
  2542.      [\"Type\"]=\"Separator\"\
  2543.    },\
  2544.    [4]={\
  2545.      [\"Name\"]=\"CutMenuItem\",\
  2546.      [\"Type\"]=\"MenuItem\",\
  2547.      [\"Text\"]=\"Cut \",\
  2548.      [\"Shortcut\"]=\"#X\"\
  2549.    },\
  2550.    [5]={\
  2551.      [\"Name\"]=\"CopyMenuItem\",\
  2552.      [\"Type\"]=\"MenuItem\",\
  2553.      [\"Text\"]=\"Copy\",\
  2554.      [\"Shortcut\"]=\"#C\"\
  2555.    },\
  2556.    [6]={\
  2557.      [\"Name\"]=\"PasteMenuItem\",\
  2558.      [\"Type\"]=\"MenuItem\",\
  2559.      [\"Text\"]=\"Paste\",\
  2560.      [\"Shortcut\"]=\"#V\"\
  2561.    }\
  2562.  },\
  2563. }",["filemenu.view"]="{\
  2564.  [\"Type\"]=\"Menu\",\
  2565.  [\"Owner\"]=\"FileMenuButton\",\
  2566.  [\"HideTop\"]=true,\
  2567.  [\"Children\"]={\
  2568.    [1]={\
  2569.      [\"Name\"]=\"NewMenuItem\",\
  2570.      [\"Type\"]=\"MenuItem\",\
  2571.      [\"Text\"]=\"New...\",\
  2572.      [\"Shortcut\"]=\"#N\"\
  2573.    },\
  2574.    [2]={\
  2575.      [\"Name\"]=\"OpenMenuItem\",\
  2576.      [\"Type\"]=\"MenuItem\",\
  2577.      [\"Text\"]=\"Open...\",\
  2578.      [\"Shortcut\"]=\"#O\"\
  2579.    },\
  2580.    [3]={\
  2581.      [\"Name\"]=\"Separator\",\
  2582.      [\"Type\"]=\"Separator\"\
  2583.    },\
  2584.    [4]={\
  2585.      [\"Name\"]=\"SaveMenuItem\",\
  2586.      [\"Type\"]=\"MenuItem\",\
  2587.      [\"Text\"]=\"Save\",\
  2588.      [\"Shortcut\"]=\"#S\"\
  2589.    },\
  2590.    [5]={\
  2591.      [\"Name\"]=\"SaveAsMenuItem\",\
  2592.      [\"Type\"]=\"MenuItem\",\
  2593.      [\"Text\"]=\"Save As...\",\
  2594.      [\"Shortcut\"]=\"^#S\"\
  2595.    },\
  2596.    [6]={\
  2597.      [\"Name\"]=\"Separator\",\
  2598.      [\"Type\"]=\"Separator\"\
  2599.    },\
  2600.    [7]={\
  2601.      [\"Name\"]=\"QuitMenuItem\",\
  2602.      [\"Type\"]=\"MenuItem\",\
  2603.      [\"Text\"]=\"Quit\",\
  2604.      [\"Shortcut\"]=\"#Q\"\
  2605.    },\
  2606.  },\
  2607. }",["colourswindow.view"]="{\
  2608.     [\"Width\"]=13,\
  2609.     [\"Height\"]=4,\
  2610.     [\"BackgroundColour\"]=1,\
  2611.     [\"Children\"]={\
  2612.         [1]={\
  2613.             [\"Y\"]=1,\
  2614.             [\"X\"]=1,\
  2615.             [\"Name\"]=\"PrimaryColourButton\",\
  2616.             [\"Type\"]=\"View\",\
  2617.             [\"Width\"]=5,\
  2618.             [\"Height\"]=2,\
  2619.             [\"BackgroundColour\"]=8,\
  2620.             [\"ActiveBackgroundColour\"]=8\
  2621.         },\
  2622.         [2]={\
  2623.             [\"Y\"]=3,\
  2624.             [\"X\"]=1,\
  2625.             [\"Name\"]=\"SecondaryColourButton\",\
  2626.             [\"Type\"]=\"View\",\
  2627.             [\"Width\"]=5,\
  2628.             [\"Height\"]=2,\
  2629.             [\"BackgroundColour\"]=4,\
  2630.             [\"ActiveBackgroundColour\"]=4\
  2631.         },\
  2632. \
  2633.         [3]={\
  2634.             [\"Y\"]=1,\
  2635.             [\"X\"]=6,\
  2636.             [\"Type\"]=\"Button\",\
  2637.             [\"Name\"]=\"ColourButton\",\
  2638.             [\"Width\"]=2,\
  2639.             [\"Height\"]=1,\
  2640.             [\"BackgroundColour\"]=4096,\
  2641.             [\"ActiveBackgroundColour\"]=4096\
  2642.         },\
  2643.         [4]={\
  2644.             [\"Y\"]=1,\
  2645.             [\"X\"]=8,\
  2646.             [\"Type\"]=\"Button\",\
  2647.             [\"Name\"]=\"ColourButton\",\
  2648.             [\"Width\"]=2,\
  2649.             [\"Height\"]=1,\
  2650.             [\"BackgroundColour\"]=16,\
  2651.             [\"ActiveBackgroundColour\"]=16\
  2652.         },\
  2653.         [5]={\
  2654.             [\"Y\"]=1,\
  2655.             [\"X\"]=10,\
  2656.             [\"Type\"]=\"Button\",\
  2657.             [\"Name\"]=\"ColourButton\",\
  2658.             [\"Width\"]=2,\
  2659.             [\"Height\"]=1,\
  2660.             [\"BackgroundColour\"]=2,\
  2661.             [\"ActiveBackgroundColour\"]=2\
  2662.         },\
  2663.         [6]={\
  2664.             [\"Y\"]=1,\
  2665.             [\"X\"]=12,\
  2666.             [\"Type\"]=\"Button\",\
  2667.             [\"Name\"]=\"ColourButton\",\
  2668.             [\"Width\"]=2,\
  2669.             [\"Height\"]=1,\
  2670.             [\"BackgroundColour\"]=16384,\
  2671.             [\"ActiveBackgroundColour\"]=16384\
  2672.         },\
  2673. \
  2674.         [7]={\
  2675.             [\"Y\"]=2,\
  2676.             [\"X\"]=6,\
  2677.             [\"Type\"]=\"Button\",\
  2678.             [\"Name\"]=\"ColourButton\",\
  2679.             [\"Width\"]=2,\
  2680.             [\"Height\"]=1,\
  2681.             [\"BackgroundColour\"]=8192,\
  2682.             [\"ActiveBackgroundColour\"]=8192\
  2683.         },\
  2684.         [8]={\
  2685.             [\"Y\"]=2,\
  2686.             [\"X\"]=8,\
  2687.             [\"Type\"]=\"Button\",\
  2688.             [\"Name\"]=\"ColourButton\",\
  2689.             [\"Width\"]=2,\
  2690.             [\"Height\"]=1,\
  2691.             [\"BackgroundColour\"]=32,\
  2692.             [\"ActiveBackgroundColour\"]=32\
  2693.         },\
  2694.         [9]={\
  2695.             [\"Y\"]=2,\
  2696.             [\"X\"]=10,\
  2697.             [\"Type\"]=\"Button\",\
  2698.             [\"Name\"]=\"ColourButton\",\
  2699.             [\"Width\"]=2,\
  2700.             [\"Height\"]=1,\
  2701.             [\"BackgroundColour\"]=4,\
  2702.             [\"ActiveBackgroundColour\"]=4\
  2703.         },\
  2704.         [10]={\
  2705.             [\"Y\"]=2,\
  2706.             [\"X\"]=12,\
  2707.             [\"Type\"]=\"Button\",\
  2708.             [\"Name\"]=\"ColourButton\",\
  2709.             [\"Width\"]=2,\
  2710.             [\"Height\"]=1,\
  2711.             [\"BackgroundColour\"]=64,\
  2712.             [\"ActiveBackgroundColour\"]=64\
  2713.         },\
  2714. \
  2715.         [11]={\
  2716.             [\"Y\"]=3,\
  2717.             [\"X\"]=6,\
  2718.             [\"Type\"]=\"Button\",\
  2719.             [\"Name\"]=\"ColourButton\",\
  2720.             [\"Width\"]=2,\
  2721.             [\"Height\"]=1,\
  2722.             [\"BackgroundColour\"]=1024,\
  2723.             [\"ActiveBackgroundColour\"]=1024\
  2724.         },\
  2725.         [12]={\
  2726.             [\"Y\"]=3,\
  2727.             [\"X\"]=8,\
  2728.             [\"Type\"]=\"Button\",\
  2729.             [\"Name\"]=\"ColourButton\",\
  2730.             [\"Width\"]=2,\
  2731.             [\"Height\"]=1,\
  2732.             [\"BackgroundColour\"]=2048,\
  2733.             [\"ActiveBackgroundColour\"]=2048\
  2734.         },\
  2735.         [13]={\
  2736.             [\"Y\"]=3,\
  2737.             [\"X\"]=10,\
  2738.             [\"Type\"]=\"Button\",\
  2739.             [\"Name\"]=\"ColourButton\",\
  2740.             [\"Width\"]=2,\
  2741.             [\"Height\"]=1,\
  2742.             [\"BackgroundColour\"]=512,\
  2743.             [\"ActiveBackgroundColour\"]=512\
  2744.         },\
  2745.         [14]={\
  2746.             [\"Y\"]=3,\
  2747.             [\"X\"]=12,\
  2748.             [\"Type\"]=\"Button\",\
  2749.             [\"Name\"]=\"ColourButton\",\
  2750.             [\"Width\"]=2,\
  2751.             [\"Height\"]=1,\
  2752.             [\"BackgroundColour\"]=8,\
  2753.             [\"ActiveBackgroundColour\"]=8\
  2754.         },\
  2755. \
  2756.         [15]={\
  2757.             [\"Y\"]=4,\
  2758.             [\"X\"]=6,\
  2759.             [\"Type\"]=\"Button\",\
  2760.             [\"Name\"]=\"ColourButton\",\
  2761.             [\"Width\"]=2,\
  2762.             [\"Height\"]=1,\
  2763.             [\"BackgroundColour\"]=256,\
  2764.             [\"ActiveBackgroundColour\"]=256\
  2765.         },\
  2766.         [16]={\
  2767.             [\"Y\"]=4,\
  2768.             [\"X\"]=8,\
  2769.             [\"Type\"]=\"Button\",\
  2770.             [\"Name\"]=\"ColourButton\",\
  2771.             [\"Width\"]=2,\
  2772.             [\"Height\"]=1,\
  2773.             [\"BackgroundColour\"]=128,\
  2774.             [\"ActiveBackgroundColour\"]=128\
  2775.         },\
  2776.         [17]={\
  2777.             [\"Y\"]=4,\
  2778.             [\"X\"]=10,\
  2779.             [\"Type\"]=\"Button\",\
  2780.             [\"Name\"]=\"ColourButton\",\
  2781.             [\"Width\"]=2,\
  2782.             [\"Height\"]=1,\
  2783.             [\"BackgroundColour\"]=32768,\
  2784.             [\"ActiveBackgroundColour\"]=32768\
  2785.         },\
  2786.         [18]={\
  2787.             [\"Y\"]=4,\
  2788.             [\"X\"]=12,\
  2789.             [\"Type\"]=\"Button\",\
  2790.             [\"Name\"]=\"ColourButton\",\
  2791.             [\"Width\"]=2,\
  2792.             [\"Height\"]=1,\
  2793.             [\"BackgroundColour\"]=1,\
  2794.             [\"ActiveBackgroundColour\"]=1\
  2795.         },\
  2796.     },\
  2797. }",["viewmenu.view"]="{\
  2798.  [\"Type\"]=\"Menu\",\
  2799.  [\"Owner\"]=\"ViewMenuButton\",\
  2800.  [\"HideTop\"]=true,\
  2801.  [\"Children\"]={\
  2802.    [1]={\
  2803.      [\"Name\"]=\"ZoomInMenuItem\",\
  2804.      [\"Type\"]=\"MenuItem\",\
  2805.      [\"Text\"]=\"Zoom In\",\
  2806.      [\"Shortcut\"]=\"#=\"\
  2807.    },\
  2808.    [2]={\
  2809.      [\"Name\"]=\"ZoomOutMenuItem\",\
  2810.      [\"Type\"]=\"MenuItem\",\
  2811.      [\"Text\"]=\"Zoom Out\",\
  2812.      [\"Shortcut\"]=\"#-\"\
  2813.    },\
  2814.    [3]={\
  2815.      [\"Name\"]=\"100%ZoomMenuItem\",\
  2816.      [\"Type\"]=\"MenuItem\",\
  2817.      [\"Text\"]=\"100% Zoom\",\
  2818.      [\"Shortcut\"]=\"#1\"\
  2819.    },\
  2820.    [4]={\
  2821.      [\"Name\"]=\"Separator\",\
  2822.      [\"Type\"]=\"Separator\"\
  2823.    },\
  2824.    [5]={\
  2825.      [\"Name\"]=\"FilterMaskMenuItem\",\
  2826.      [\"Type\"]=\"MenuItem\",\
  2827.      [\"Text\"]=\"Show Filter Masks\",\
  2828.      [\"Shortcut\"]=\"#M\"\
  2829.    },\
  2830.  },\
  2831. }",["toolswindow.view"]="{\
  2832.     [\"Width\"]=17,\
  2833.     [\"Height\"]=9,\
  2834.     [\"BackgroundColour\"]=1,\
  2835.     [\"Children\"]={\
  2836.         [1]={\
  2837.             [\"Y\"]=2,\
  2838.             [\"X\"]=2,\
  2839.             [\"Type\"]=\"Button\",\
  2840.             [\"Name\"]=\"ToolButton\",\
  2841.             [\"Text\"]=\"Hand\",\
  2842.             [\"ToolName\"]=\"HandTool\",\
  2843.         },\
  2844.         [2]={\
  2845.             [\"Y\"]=2,\
  2846.             [\"X\"]=9,\
  2847.             [\"Type\"]=\"Button\",\
  2848.             [\"Name\"]=\"ToolButton\",\
  2849.             [\"Text\"]=\"Pencil\",\
  2850.             [\"ToolName\"]=\"PencilTool\",\
  2851.         },\
  2852.         [3]={\
  2853.             [\"Y\"]=4,\
  2854.             [\"X\"]=2,\
  2855.             [\"Type\"]=\"Button\",\
  2856.             [\"Name\"]=\"ToolButton\",\
  2857.             [\"Text\"]=\"Fill\",\
  2858.             [\"ToolName\"]=\"FillTool\",\
  2859.         },\
  2860.         [4]={\
  2861.             [\"Y\"]=4,\
  2862.             [\"X\"]=9,\
  2863.             [\"Type\"]=\"Button\",\
  2864.             [\"Name\"]=\"ToolButton\",\
  2865.             [\"Text\"]=\"Eraser\",\
  2866.             [\"ToolName\"]=\"EraserTool\",\
  2867.         },\
  2868.         [5]={\
  2869.             [\"Y\"]=6,\
  2870.             [\"X\"]=2,\
  2871.             [\"Type\"]=\"Button\",\
  2872.             [\"Name\"]=\"ToolButton\",\
  2873.             [\"Text\"]=\"Text\",\
  2874.             [\"ToolName\"]=\"TextTool\",\
  2875.         },\
  2876.         [6]={\
  2877.             [\"Y\"]=6,\
  2878.             [\"X\"]=9,\
  2879.             [\"Width\"]=8,\
  2880.             [\"Type\"]=\"Button\",\
  2881.             [\"Name\"]=\"ToolButton\",\
  2882.             [\"Text\"]=\"Spray\",\
  2883.             [\"ToolName\"]=\"SprayTool\",\
  2884.         },\
  2885.         [7]={\
  2886.             [\"Y\"]=8,\
  2887.             [\"X\"]=2,\
  2888.             [\"Type\"]=\"Button\",\
  2889.             [\"Name\"]=\"ToolButton\",\
  2890.             [\"Text\"]=\"Move\",\
  2891.             [\"ToolName\"]=\"MoveTool\",\
  2892.         },\
  2893.         [8]={\
  2894.             [\"Y\"]=8,\
  2895.             [\"X\"]=9,\
  2896.             [\"Type\"]=\"Button\",\
  2897.             [\"Name\"]=\"ToolButton\",\
  2898.             [\"Text\"]=\"Select\",\
  2899.             [\"ToolName\"]=\"SelectTool\",\
  2900.         },\
  2901.     },\
  2902. }",},["Objects"]={["ToolsWindow.lua"]="Inherit = 'SnapWindow'\
  2903. ContentViewName = 'toolswindow'\
  2904. \
  2905. Title = 'Tools'\
  2906. \
  2907. OnContentLoad = function(self)\
  2908.     local buttons = self:GetObjects('ToolButton')\
  2909.     for i, button in ipairs(buttons) do\
  2910.         button.OnClick = function(_self, event, side, x , y)\
  2911.             local artboard = self.Bedrock:GetObject('Artboard')\
  2912.             if artboard then\
  2913.                 artboard:SetTool(getfenv()[button.ToolName])\
  2914.             end\
  2915.         end\
  2916.     end\
  2917. end",["FilterPreview.lua"]="Inherit = 'View'\
  2918. \
  2919. BackgroundColour = colours.transparent\
  2920. TextColour = colours.black\
  2921. Height = 3\
  2922. Image = nil\
  2923. Enabled = true\
  2924. \
  2925. OnLoad = function(self)\
  2926.     self.Image = Drawing.LoadImage('Resources/filterPreview.nft')\
  2927. \
  2928.     self:AddObject({\
  2929.         X = 6,\
  2930.         Y = 1,\
  2931.         Text = self.FilterName,\
  2932.         Type = 'Label',\
  2933.         BackgroundColour = colours.transparent,\
  2934.         TextColour = self.TextColour\
  2935.     })\
  2936. end\
  2937. \
  2938. OnDraw = function(self, x, y)\
  2939.     if self.BackgroundColour then\
  2940.         Drawing.DrawBlankArea(x, y, self.Width, self.Height, self.BackgroundColour)\
  2941.     end\
  2942. \
  2943.     local filter = Drawing.Filters[self.Filter]\
  2944.     if not filter then\
  2945.         filter = Drawing.Filters.None\
  2946.     end\
  2947. \
  2948.     for _y = 1, #self.Image do\
  2949.         for _x = 1, #self.Image[_y] do\
  2950.             local bgColour = Drawing.FilterColour(self.Image[_y][_x], filter)\
  2951.            local textColour = Drawing.FilterColour(self.Image.textcol[_y][_x] or colours.white, filter)\
  2952.            local char = self.Image.text[_y][_x]\
  2953.            Drawing.WriteToBuffer(x+_x, y+_y-1, char, textColour, bgColour)\
  2954.         end\
  2955.     end\
  2956. end\
  2957. \
  2958. OnClick = function(self, event, side, x, y)\
  2959.     if self.Enabled then\
  2960.         local artboard = self.Bedrock:GetObject('Artboard')\
  2961.         if artboard then\
  2962.             artboard:CreateLayer(self.FilterName .. ' Filter', colours.white, 'Filter:' .. self.Filter)\
  2963.         end\
  2964.     end\
  2965. end",["LayerView.lua"]="Inherit = 'View'\
  2966. \
  2967. BackgroundColour = colours.transparent\
  2968. ActiveBackgroundColour = colours.blue\
  2969. ActiveTextColour = colours.white\
  2970. Height = 3\
  2971. DragStart = nil\
  2972. DragTimer = nil\
  2973. \
  2974. \
  2975. OnLoad = function(self)\
  2976.     self:AddObject({\
  2977.         X = 2,\
  2978.         Y = 1,\
  2979.         Width = 1,\
  2980.         AutoWidth = false,\
  2981.         Text = (self.Layer.Visible and '@' or '*'),\
  2982.         Type = 'Button',\
  2983.         Name = 'VisibleButton',\
  2984.         BackgroundColour = colours.transparent,\
  2985.         ActiveBackgroundColour = colours.transparent,\
  2986.         TextColour = colours.grey,\
  2987.         ActiveTextColour = colours.black,\
  2988.         Toggle = self.Layer.Visible,\
  2989.         OnClick = function(_self)\
  2990.             if _self.Toggle then\
  2991.                 _self.Text = '@'\
  2992.             else\
  2993.                 _self.Text = '*'\
  2994.             end\
  2995.             self.Layer.Layer.Visible = _self.Toggle\
  2996.             self.Layer.Visible = _self.Toggle\
  2997.         end\
  2998.     })\
  2999. \
  3000.     self:AddObject({\
  3001.         X = 2,\
  3002.         Y = 2,\
  3003.         Width = 1,\
  3004.         AutoWidth = false,\
  3005.         Text = 'X',\
  3006.         Type = 'Button',\
  3007.         Name = 'DeleteButton',\
  3008.         BackgroundColour = colours.transparent,\
  3009.         ActiveBackgroundColour = colours.transparent,\
  3010.         TextColour = colours.red,\
  3011.         OnClick = function(_self)\
  3012.             self.Layer:DeleteLayer()\
  3013.         end\
  3014.     })\
  3015. \
  3016.     self:AddObject({\
  3017.         X = 9,\
  3018.         Y = 1,\
  3019.         Text = self.Layer.Layer.Name,\
  3020.         Type = 'Label',\
  3021.         Name = 'LayerNameLabel',\
  3022.         BackgroundColour = colours.transparent,\
  3023.         TextColour = colours.black\
  3024.     })\
  3025. end\
  3026. \
  3027. OnDraw = function(self, x, y)\
  3028.     local artboard = self.Bedrock:GetObject('Artboard')\
  3029. \
  3030.     local isActive = (artboard and artboard:GetCurrentLayer() == self.Layer)\
  3031. \
  3032.     if isActive then\
  3033.         Drawing.DrawBlankArea(x, y, self.Width, self.Height, self.ActiveBackgroundColour)\
  3034.         self:GetObject('VisibleButton').TextColour = colours.lightGrey\
  3035.         self:GetObject('VisibleButton').ActiveTextColour = colours.white\
  3036.         self:GetObject('DeleteButton').TextColour = colours.white\
  3037.         self:GetObject('LayerNameLabel').TextColour = colours.white\
  3038.     else\
  3039.         Drawing.DrawBlankArea(x, y, self.Width, self.Height, self.BackgroundColour)\
  3040.         self:GetObject('VisibleButton').TextColour = colours.grey\
  3041.         self:GetObject('VisibleButton').ActiveTextColour = colours.black\
  3042.         self:GetObject('DeleteButton').TextColour = colours.red\
  3043.         self:GetObject('LayerNameLabel').TextColour = colours.black\
  3044.     end\
  3045. \
  3046.     local previewX = 3\
  3047.     local previewY = 0\
  3048.     for _x = 1, 3 do\
  3049.         local odd = (_x % 2) == 1\
  3050.         for _y = 1, 2 do\
  3051.             if odd then\
  3052.                 Drawing.WriteToBuffer(previewX + x + _x - 1, previewY + y + _y - 1, \":\", colours.lightGrey, colours.white)\
  3053.             else\
  3054.                 Drawing.WriteToBuffer(previewX + x + _x - 1, previewY + y + _y - 1, \":\", colours.white, colours.lightGrey)\
  3055.             end\
  3056.             odd = not odd\
  3057.         end\
  3058.     end\
  3059. \
  3060.     for _x, col in ipairs(self.Layer:GetZoomPixels(3, 2)) do\
  3061.         for _y, pixel in ipairs(col) do\
  3062.             if pixel.Character ~= ' ' or pixel.BackgroundColour ~= colours.transparent then\
  3063.                 Drawing.WriteToBuffer(previewX + x + _x - 1, previewY + y + _y - 1, pixel.Character, pixel.TextColour, pixel.BackgroundColour)\
  3064.             end\
  3065.         end\
  3066.     end\
  3067. \
  3068.     local splitterColour = colours.lightGrey\
  3069. \
  3070. \
  3071.     Drawing.DrawArea(x, y  + self.Height - 1, self.Width, 1, '-', (isActive and colours.white or colours.lightGrey), colours.transparent)\
  3072. \
  3073. end\
  3074. \
  3075. OnClick = function(self, event, side, x, y)\
  3076.     if side == 1 then\
  3077.         self.DragStart = y\
  3078. \
  3079.         local artboard = self.Bedrock:GetObject('Artboard')\
  3080.         if artboard then\
  3081.             artboard:SetCurrentLayer(self.Layer)\
  3082.         end\
  3083.     elseif side == 2 then\
  3084.         if self:ToggleMenu('layermenu', x, y) then\
  3085.             local artboard = self.Bedrock:GetObject('Artboard')\
  3086.             if artboard then\
  3087.                 self.Bedrock:GetObject('NewLayerMenuItem').OnClick = function()\
  3088.                     artboard:NewLayer()\
  3089.                 end\
  3090.                 self.Bedrock:GetObject('RenameLayerMenuItem').OnClick = function()\
  3091.                     self.Layer:RenameLayer()\
  3092.                 end\
  3093.                 self.Bedrock:GetObject('DeleteLayerMenuItem').OnClick = function()\
  3094.                     self.Layer:DeleteLayer()\
  3095.                 end\
  3096.                 self.Bedrock:GetObject('DuplicateLayerMenuItem').OnClick = function()\
  3097.                     artboard:DuplicateLayer(self.Layer.Layer)\
  3098.                 end\
  3099.                 self.Bedrock:GetObject('MergeDownLayerMenuItem').OnClick = function()\
  3100.                     self.Layer:MergeDown()\
  3101.                 end\
  3102.             end\
  3103.         end\
  3104.     end\
  3105. end\
  3106. \
  3107. \
  3108. OnDrag = function(self, event, side, x, y)\
  3109.     if self.DragStart then\
  3110.         local deltaY = y - self.DragStart\
  3111.         self.Y = self.Y + deltaY\
  3112.         self.Parent.Parent.Parent:Rearrange(self, y)\
  3113.     end\
  3114. \
  3115.     self.DragTimer = self.Bedrock:StartTimer(function(_, timer)\
  3116.         if timer == self.DragTimer then\
  3117.             self.Parent.Parent.Parent:OrderLayers()\
  3118.             self.Parent.Parent.Parent:UpdateLayers()\
  3119.             self.DragStart = nil\
  3120.             self.DragTimer = nil\
  3121.         end\
  3122.     end, 1)\
  3123. end",["NumberBox.lua"]="Inherit = 'View'\
  3124. \
  3125. Value = 1\
  3126. Minimum = 1\
  3127. Maximum = 99\
  3128. BackgroundColour = colours.lightGrey\
  3129. TextBoxTimer = nil\
  3130. Width = 7\
  3131. \
  3132. OnLoad = function(self)\
  3133.     self:AddObject({\
  3134.         X = self.Width - 1,\
  3135.         Y = 1,\
  3136.         Width = 1,\
  3137.         AutoWidth = false,\
  3138.         Text = '-',\
  3139.         Type = 'Button',\
  3140.         Name = 'AddButton',\
  3141.         BackgroundColour = colours.transparent,\
  3142.         OnClick = function()\
  3143.             self:ShiftValue(-1)\
  3144.         end\
  3145.     })\
  3146. \
  3147.     self:AddObject({\
  3148.         X = self.Width,\
  3149.         Y = 1,\
  3150.         Width = 1,\
  3151.         AutoWidth = false,\
  3152.         Text = '+',\
  3153.         Type = 'Button',\
  3154.         Name = 'SubButton',\
  3155.         BackgroundColour = colours.transparent,\
  3156.         OnClick = function()\
  3157.             self:ShiftValue(1)\
  3158.         end\
  3159.     })\
  3160. \
  3161.     self:AddObject({\
  3162.         X = 1,\
  3163.         Y = 1,\
  3164.         Width = self.Width - 2,\
  3165.         Text = tostring(self.Value),\
  3166.         Align = 'Center',\
  3167.         Type = 'TextBox',\
  3168.         BackgroundColour = colours.transparent,\
  3169.         OnChange = function(_self, event, keychar)\
  3170.             if keychar == keys.enter then\
  3171.                 self:SetValue(tonumber(_self.Text))\
  3172.                 self.TextBoxTimer = nil\
  3173.             end\
  3174.             if self.TextBoxTimer then\
  3175.                 self.Bedrock:StopTimer(self.TextBoxTimer)\
  3176.             end\
  3177. \
  3178.             self.TextBoxTimer = self.Bedrock:StartTimer(function(_, timer)\
  3179.                 if timer and timer == self.TextBoxTimer then\
  3180.                     self:SetValue(tonumber(_self.Text))\
  3181.                     self.TextBoxTimer = nil\
  3182.                 end\
  3183.             end, 2)\
  3184.         end\
  3185.     })\
  3186. end\
  3187. \
  3188. OnScroll = function(self, event, dir, x, y)\
  3189.     self:ShiftValue(-dir)\
  3190. end\
  3191. \
  3192. ShiftValue = function(self, delta)\
  3193.     local val = tonumber(self:GetObject('TextBox').Text) or self.Minimum\
  3194.     self:SetValue(val + delta)\
  3195. end\
  3196. \
  3197. SetValue = function(self, newValue)\
  3198.     newValue = newValue or 0\
  3199.     if self.Maximum and newValue > self.Maximum then\
  3200.         newValue = self.Maximum\
  3201.     elseif self.Minimum and newValue < self.Minimum then\
  3202.         newValue = self.Minimum\
  3203.     end\
  3204.     self.Value = newValue\
  3205.     if self.OnChange then\
  3206.         self:OnChange()\
  3207.     end\
  3208. end\
  3209. \
  3210. OnUpdate = function(self, value)\
  3211.     if value == 'Value' then\
  3212.         local textbox = self:GetObject('TextBox')\
  3213.         if textbox then\
  3214.             textbox.Text = tostring(self.Value)\
  3215.         end\
  3216.     end\
  3217. end",["LayersWindow.lua"]="Inherit = 'SnapWindow'\
  3218. ContentViewName = 'layerswindow'\
  3219. \
  3220. Title = 'Layers'\
  3221. \
  3222. OnContentLoad = function(self)\
  3223.     self:UpdateLayers()\
  3224. end\
  3225. \
  3226. UpdateLayers = function(self)\
  3227.     self:GetObject('ScrollView'):RemoveAllObjects()\
  3228.     local artboard = self.Bedrock:GetObject('Artboard')\
  3229.     if artboard then\
  3230.         for i, layer in ipairs(artboard.Children) do\
  3231.             self:GetObject('ScrollView'):AddObject({\
  3232.                 Type = 'LayerView',\
  3233.                 X = 1,\
  3234.                 Y = 1 + (#artboard.Children - i) * LayerView.Height,\
  3235.                 Width = '100%',\
  3236.                 Layer = layer,\
  3237.                 LayerIndex = i\
  3238.             })\
  3239.         end\
  3240.         local maxHeight = Drawing.Screen.Height - 4\
  3241.         local height = #artboard.Children * LayerView.Height\
  3242.         if height > maxHeight then\
  3243.             height = maxHeight\
  3244.         end\
  3245. \
  3246.         self:GetObject('ContentView').Height = height\
  3247.         self:GetObject('ScrollView').Height = height\
  3248.         self:GetObject('ScrollView'):UpdateScroll()\
  3249.         self.Height = 1 + height\
  3250.     end\
  3251. end\
  3252. \
  3253. OrderLayers = function(self)\
  3254.     local artboard = self.Bedrock:GetObject('Artboard')\
  3255.     if artboard then\
  3256.         local layers = {}\
  3257.         for i, v in ipairs(self:GetObject('ScrollView').Children) do\
  3258.             if v.Type == 'LayerView' then\
  3259.                 table.insert(layers, v.Layer.Layer)\
  3260.             end\
  3261.         end\
  3262.         artboard.Layers = layers\
  3263.         artboard:PushState()\
  3264.     end\
  3265. end\
  3266. \
  3267. Rearrange = function(self, dragging, y)\
  3268.     local artboard = self.Bedrock:GetObject('Artboard')\
  3269.     if artboard then\
  3270.         local children = self:GetObject('ScrollView').Children\
  3271. \
  3272.         local scrollBar = self:GetObject('ScrollViewScrollBar')\
  3273. \
  3274.         local newIndex = #children - (scrollBar and 1 or 0) - math.floor((dragging.Y + y - 2 ) / 4)\
  3275.         if newIndex > #children then\
  3276.             newIndex = #children\
  3277.         elseif newIndex < 1 then\
  3278.             newIndex = 1\
  3279.         end\
  3280.         local oldIndex = dragging.LayerIndex\
  3281. \
  3282.         if newIndex ~= oldIndex then\
  3283.             local newChildren = {}\
  3284.             newChildren[newIndex] = dragging\
  3285.             dragging.LayerIndex = newIndex\
  3286. \
  3287.             for i, layer in ipairs(children) do\
  3288.                 if layer ~= dragging then\
  3289.                     table.insert(newChildren, layer)\
  3290.                     local index = #newChildren\
  3291.                     if index == newIndex then\
  3292.                         index = index - 1\
  3293.                     end\
  3294.                     layer.LayerIndex = index\
  3295.                     layer.Y = 1 + (#children - layer.LayerIndex) * 4\
  3296.                 end\
  3297.             end\
  3298.             self:GetObject('ScrollView').Children = newChildren\
  3299.         end\
  3300.     end\
  3301. end",["Layer.lua"]="BackgroundColour = colours.transparent\
  3302. DrawnPixels = nil\
  3303. UpdateDrawBlacklist = {['DrawnPixels']=true}\
  3304. Ready = false\
  3305. CursorPos = nil\
  3306. \
  3307. OnLoad = function(self)\
  3308.     -- self.LayerName = self.Layer.Nae\
  3309.     -- self.Pixels = ParseNFT(self.Layer.Pixels)\
  3310.     self.BackgroundColour = self.Layer.BackgroundColour\
  3311.     self.Visible = self.Layer.Visible\
  3312.     self.Ready = true\
  3313. end\
  3314. \
  3315. OnDraw = function(self, x, y)\
  3316.     if self.Layer.LayerType == 'Normal' or self.Parent.ShowFilterMask then\
  3317.         local drawnPixels = {}\
  3318.         for _x, col in ipairs(self:GetZoomPixels(self.Width, self.Height, true)) do\
  3319.             drawnPixels[_x] = {}\
  3320.             for _y, pixel in ipairs(col) do\
  3321.                 if pixel.Character ~= ' ' or pixel.BackgroundColour ~= colours.transparent then\
  3322.                     drawnPixels[_x][_y] = pixel\
  3323.                     Drawing.WriteToBuffer(x + _x - 1, y + _y - 1, pixel.Character, pixel.TextColour, pixel.BackgroundColour)\
  3324.                 end\
  3325.             end\
  3326.         end\
  3327.         self.DrawnPixels = drawnPixels\
  3328. \
  3329.         if self.Bedrock:GetActiveObject() == self then\
  3330.             self.Bedrock.CursorPos = {x + self.CursorPos[1] - 1, y + self.CursorPos[2] - 1}\
  3331.             self.Bedrock.CursorColour = self.Parent.BrushColour\
  3332.         else\
  3333.             self.CursorPos = nil\
  3334.         end\
  3335.     elseif self.Layer.LayerType:sub(1, 7) == 'Filter:' then\
  3336.         local drawnPixels = {}\
  3337.         for _x, col in ipairs(self:GetZoomPixels(self.Width, self.Height)) do\
  3338.             drawnPixels[_x] = {}\
  3339.             for _y, pixel in ipairs(col) do\
  3340.                 if pixel.BackgroundColour == colours.white then\
  3341.                     local bgColour, txtColour, char = self.Parent:GetPixelBelowLayer(_x, _y, self.LayerIndex)\
  3342.                     local filter = Drawing.Filters[self.Layer.LayerType:sub(8)]\
  3343.                     if not filter then\
  3344.                         filter = Drawing.Filters.None\
  3345.                     end\
  3346. \
  3347.                     bgColour = Drawing.FilterColour(bgColour, filter)\
  3348.                     txtColour = Drawing.FilterColour(txtColour, filter)\
  3349. \
  3350.                     if txtColour == colors.transparent then\
  3351.                         txtColour = colours.black\
  3352.                         char = ' '\
  3353.                     end\
  3354.                     drawnPixels[_x][_y] = {Character = char, TextColour = txtColour, BackgroundColour = bgColour}\
  3355.                     Drawing.WriteToBuffer(x + _x - 1, y + _y - 1, char, txtColour, bgColour)\
  3356.                 end\
  3357.             end\
  3358.         end\
  3359.         self.DrawnPixels = drawnPixels\
  3360.     end\
  3361. end\
  3362. \
  3363. GetZoomPixels = function(self, width, height, preserveDetail)\
  3364.     local pixels = {}\
  3365.     local deltaX = #self.Layer.Pixels / width\
  3366.     local deltaY = #self.Layer.Pixels[1] / height\
  3367. \
  3368.     if deltaX == 1 and deltaY == 1 then\
  3369.         return self.Layer.Pixels\
  3370.     end\
  3371. \
  3372.     for _x = 1, width do\
  3373.         local x = self.Bedrock.Helpers.Round(1*deltaX + (_x - 1) * deltaX)\
  3374.         if not self.Layer.Pixels[x] then\
  3375.             if x < 1 then\
  3376.                 x = 1\
  3377.             else\
  3378.                 x = #self.Layer.Pixels\
  3379.             end\
  3380.         end\
  3381.         pixels[_x] = {}\
  3382.         for _y = 1, height do\
  3383.             local y = self.Bedrock.Helpers.Round(1*deltaY + (_y - 1) * deltaY)\
  3384.             if not self.Layer.Pixels[x][y] then\
  3385.                 if y < 1 then\
  3386.                     y = 1\
  3387.                 else\
  3388.                     y = #self.Layer.Pixels[x]\
  3389.                 end\
  3390.             end\
  3391.             pixels[_x][_y] = self.Layer.Pixels[x][y]\
  3392.             if not preserveDetail and pixels[_x][_y].Character ~= ' ' then\
  3393.                 pixels[_x][_y].Character = '-'\
  3394.             end\
  3395.         end\
  3396.     end\
  3397.     return pixels\
  3398. end\
  3399. \
  3400. GetEffectedPixels = function(self, x, y, brushSize, brushShape, correctPixelRatio)\
  3401.     if brushSize == 1 then\
  3402.         return {\
  3403.             {x, y}\
  3404.         }\
  3405.     elseif brushShape == 'Square' then\
  3406.         local pixels = {}\
  3407.         local cornerX = math.ceil(x - brushSize/2)\
  3408.         local cornerY = math.ceil(y - brushSize/2)\
  3409.         for _x = 1, brushSize do\
  3410.             for _y = 1, brushSize do\
  3411.                 if self.Layer.Pixels[cornerX + _x] and self.Layer.Pixels[cornerX + _x][cornerY + _y] then\
  3412.                     table.insert(pixels, {cornerX + _x, cornerY + _y})\
  3413.                 end\
  3414.             end\
  3415.         end\
  3416.         return pixels\
  3417.     elseif brushShape == 'Circle' then\
  3418. \
  3419.         -- this circle algorithm looks terrible on odd values (try 5 and 3)\
  3420. \
  3421.         local pixels = {{x, y}}\
  3422.         local rSquared = math.pow(brushSize/2, 2)\
  3423. \
  3424.         local round = self.Bedrock.Helpers.Round\
  3425.         -- thanks to theoriginalbit for this (slightly modified) snippet\
  3426.         -- local radius = brushSize / 2\
  3427.  --       local radStep = 1/(1.5*radius)\
  3428.  --       for angle = 1 + radStep, math.pi+radStep, radStep do\
  3429.  --               local pX = math.cos( angle ) * radius * (correctPixelRatio and 1.5 or 1)\
  3430.  --               local pY = math.sin( angle ) * radius\
  3431. \
  3432.  --               local centreOffset =  1 - (brushSize % 2)\
  3433. \
  3434.         --      table.insert(pixels, {round(x + pX) + centreOffset, round(y + pY)})\
  3435.         --      table.insert(pixels, {round(x - pX), round(y + pY)})\
  3436. \
  3437.         --      table.insert(pixels, {round(x + pX) + centreOffset, round(y - pY) + centreOffset})\
  3438.         --      table.insert(pixels, {round(x - pX), round(y - pY) + centreOffset})\
  3439.  --       end\
  3440. \
  3441. \
  3442.     --  local Ys = {}\
  3443.     --  for _y = 1, math.floor(brushSize/2) do\
  3444.     --      Ys[_y] = math.sqrt(rSquared - math.pow(_y-1, 2))\
  3445.     --  end\
  3446.     --  local round = self.Bedrock.Helpers.Round\
  3447. \
  3448.     -- print(' ')\
  3449.         for _y = -brushSize/2, brushSize/2 do\
  3450.             _y = round(_y)\
  3451.             local _x = round(math.sqrt(math.abs(rSquared - math.pow(_y, 2))) * (correctPixelRatio and 1.5 or 1))\
  3452.             -- print(_x..', '.._y)\
  3453.             -- local xLeft = math.floor(x + (_x - 1))-- - 1 + (brushSize % 2))\
  3454.             -- local xLeft = round(x + -1 * (_x - 1))\
  3455.             -- local yTop = round(y + -1 * (_y - 1) )\
  3456.             -- local yBottom = round(y + (_y - 1) - 1 + (brushSize % 2))\
  3457.             local xLeft = x - _x\
  3458.             local xRight = x + _x\
  3459. \
  3460.             for xPixel = xLeft, xRight do\
  3461.                 table.insert(pixels, {xPixel, y + _y})\
  3462.             end\
  3463.             -- table.insert(pixels, {x - _x, y + _y})\
  3464. \
  3465. \
  3466.             -- for xPixel = xLeft, xRight do\
  3467.             --  table.insert(pixels, {xPixel, yBottom})\
  3468.             --  table.insert(pixels, {xPixel, yTop})\
  3469.             -- end\
  3470. \
  3471.             -- table.insert(pixels, {xRight, })\
  3472.             -- table.insert(pixels, {xLeft,  round(y + (_y - 1) + 1)})\
  3473. \
  3474.             -- table.insert(pixels, {round(x + (_x - 1) + 1), round(y + -1*(_y - 1))})\
  3475.             -- table.insert(pixels, {round(x + -1*(_x - 1)), round(y + -1*(_y - 1))})\
  3476.         end\
  3477.     -- print('.')\
  3478. \
  3479. \
  3480.         -- for _y, _x in ipairs(Ys) do\
  3481.         --  local xRight = math.floor(x + (_x - 1))-- - 1 + (brushSize % 2))\
  3482.         --  local xLeft = round(x + -1 * (_x - 1))\
  3483.         --  local yTop = round(y + -1 * (_y - 1) )\
  3484.         --  local yBottom = round(y + (_y - 1) - 1 + (brushSize % 2))\
  3485. \
  3486.         --      table.insert(pixels, {xLeft, yTop})\
  3487. \
  3488. \
  3489.         --  -- for xPixel = xLeft, xRight do\
  3490.         --  --  table.insert(pixels, {xPixel, yBottom})\
  3491.         --  --  table.insert(pixels, {xPixel, yTop})\
  3492.         --  -- end\
  3493. \
  3494.         --  -- table.insert(pixels, {xRight, })\
  3495.         --  -- table.insert(pixels, {xLeft,  round(y + (_y - 1) + 1)})\
  3496. \
  3497.         --  -- table.insert(pixels, {round(x + (_x - 1) + 1), round(y + -1*(_y - 1))})\
  3498.         --  -- table.insert(pixels, {round(x + -1*(_x - 1)), round(y + -1*(_y - 1))})\
  3499.         -- end\
  3500. \
  3501. \
  3502.         -- for a = -1, 1 do\
  3503.         --  if a ~= 0 then\
  3504.         --      for b = -1, 1 do\
  3505.         --          if b ~= 0 then\
  3506.         --              for _y, _x in ipairs(Ys) do\
  3507.         --                  table.insert(pixels, {round(x + a * (_x - 1)), round(y + b * (_y - 1))})\
  3508.         --              end\
  3509.         --          end\
  3510.         --      end \
  3511.         --  end\
  3512.         -- end\
  3513. \
  3514.         -- -- thanks to theoriginalbit for this (slightly modified) snippet\
  3515.         -- local radius = brushSize / 2\
  3516.  --       local radStep = 1/(1.5*radius)\
  3517.  --       for angle = 1, math.pi+radStep, radStep do\
  3518.  --               local pX = math.cos( angle ) * radius-- * 1.5\
  3519.  --               local pY = math.sin( angle ) * radius\
  3520. \
  3521.   --                        print(pX .. '@'..pY)\
  3522.   --                        sleep(0.5)\
  3523. \
  3524.  --               for i=-1,1,2 do\
  3525.  --                       for j=-1,1,2 do\
  3526.   --                        -- for _x = 0, pX do\
  3527.   --                            local _x = pX\
  3528.         --                      table.insert(pixels, {round(x + i*_x), round(y + j*pY)})\
  3529.   --                        -- end\
  3530.  --                       end\
  3531.  --               end\
  3532.  --       end\
  3533. \
  3534. \
  3535.         return pixels\
  3536.     end\
  3537. end\
  3538. \
  3539. SetPixel = function(self, x, y, backgroundColour, textColour, character)\
  3540.     if self.Layer.Pixels and self.Layer.Pixels[x] and self.Layer.Pixels[x][y] then\
  3541.         if backgroundColour then\
  3542.             self.Layer.Pixels[x][y].BackgroundColour = backgroundColour\
  3543.         end\
  3544.         if textColour then\
  3545.             self.Layer.Pixels[x][y].TextColour = textColour\
  3546.         end\
  3547.         if character then\
  3548.             self.Layer.Pixels[x][y].Character = character\
  3549.         end\
  3550.         self:ForceDraw()\
  3551.         self.Parent:DelayedPushState()\
  3552.     end\
  3553. end\
  3554. \
  3555. DeleteLayer = function(self, force)\
  3556.     if #self.Parent.Layers > 1 then\
  3557.         local function delete()\
  3558.             for i, v in ipairs(self.Parent.Layers) do\
  3559.                 if v == self.Layer then\
  3560.                     table.remove(self.Parent.Layers, i)\
  3561.                     self.Parent:SetCurrentLayer(nil)\
  3562.                     self.Parent:OnDeleteLayer(v)\
  3563.                     self.Parent:UpdateLayers()\
  3564.                     local window = self.Bedrock:GetObject('LayersWindow')\
  3565.                     if window then\
  3566.                         window:UpdateLayers()\
  3567.                     end\
  3568.                 end\
  3569.             end\
  3570.         end\
  3571.         if force then\
  3572.             delete()\
  3573.         else\
  3574.             self.Bedrock:DisplayAlertWindow('Delete Layer?', \"Are you sure you want to delete the layer '\"..self.Layer.Name..\"'\", {'Delete', 'Cancel'}, function(button)\
  3575.                 if button == 'Delete' then\
  3576.                     delete()\
  3577.                 end\
  3578.             end)\
  3579.         end\
  3580.     else\
  3581.         self.Bedrock:DisplayAlertWindow('Cannot delete layer!', \"You cannot delete the last layer of an image! Make another layer to delete this one.\", {'Ok'}, function()end)\
  3582.     end\
  3583. end\
  3584. \
  3585. GetSelectionBoundaries = function(self)\
  3586.     if self.Parent.Selection and self.Parent.Selection[1] and self.Parent.Selection[2] then\
  3587.         local selection = self.Parent.Selection\
  3588.         local left\
  3589.         local right\
  3590.         local top\
  3591.         local bottom\
  3592.         if selection[1].X > selection[2].X then\
  3593.             right = selection[1].X\
  3594.             left = selection[2].X\
  3595.         else\
  3596.             left = selection[1].X\
  3597.             right = selection[2].X\
  3598.         end\
  3599. \
  3600.         if selection[1].Y > selection[2].Y then\
  3601.             bottom = selection[1].Y\
  3602.             top = selection[2].Y\
  3603.         else\
  3604.             top = selection[1].Y\
  3605.             bottom = selection[2].Y\
  3606.         end\
  3607.         return left, right, top, bottom\
  3608.     end\
  3609. end\
  3610. \
  3611. GetSelectedPixels = function(self, cut)\
  3612.     local pixels = {}\
  3613.     local bg = self.Parent:GetBackgroundColour()\
  3614.     if self.Parent.Selection and self.Parent.Selection[1] and self.Parent.Selection[2] then\
  3615.         local left, right, top, bottom = self:GetSelectionBoundaries()\
  3616.         local x = 1\
  3617.         local y = 1\
  3618.         for x = left, right do\
  3619.             pixels[x] = {}\
  3620.             for y = top, bottom do\
  3621.                 if self.Layer.Pixels[x] and self.Layer.Pixels[x][y] then\
  3622.                     pixels[x][y] = self.Layer.Pixels[x][y]\
  3623.                     if cut then\
  3624.                         self.Layer.Pixels[x][y] = {\
  3625.                             BackgroundColour = bg,\
  3626.                             TextColour = colours.black,\
  3627.                             Character = ' '\
  3628.                         }\
  3629.                     end\
  3630.                 end\
  3631.                 y = y + 1\
  3632.             end\
  3633.             x = x + 1\
  3634.         end\
  3635.     end\
  3636.     self.Parent:PushState()\
  3637.     return pixels\
  3638. end\
  3639. \
  3640. Move = function(self, deltaX, deltaY)\
  3641.     local pixels = {}\
  3642.     local bg = self.Parent:GetBackgroundColour()\
  3643.     if self.Parent.Selection and self.Parent.Selection[1] and self.Parent.Selection[2] then\
  3644.         for x = 1, self.Width do\
  3645.             pixels[x] = {}\
  3646.             for y = 1, self.Height do\
  3647.                 pixels[x][y] = self.Layer.Pixels[x][y]\
  3648.             end\
  3649.         end\
  3650. \
  3651.         local left, right, top, bottom = self:GetSelectionBoundaries()\
  3652. \
  3653.         for x = left, right do\
  3654.             for y = top, bottom do\
  3655.                 if self.Layer.Pixels[x] and self.Layer.Pixels[x][y] and pixels[x] and pixels[x][y] then\
  3656.                     pixels[x][y] = {\
  3657.                         BackgroundColour = bg,\
  3658.                         TextColour = colours.black,\
  3659.                         Character = ' '\
  3660.                     }\
  3661.                 end\
  3662.             end\
  3663.         end\
  3664. \
  3665.         for x = left, right do\
  3666.             for y = top, bottom do\
  3667.                 if self.Layer.Pixels[x] and self.Layer.Pixels[x][y] and pixels[x + deltaX] and pixels[x + deltaX][y + deltaY] then\
  3668.                     pixels[x + deltaX][y + deltaY] = self.Layer.Pixels[x][y]\
  3669.                 end\
  3670.             end\
  3671.         end\
  3672. \
  3673.         selection[1].X = selection[1].X + deltaX\
  3674.         selection[1].Y = selection[1].Y + deltaY\
  3675.         selection[2].X = selection[2].X + deltaX\
  3676.         selection[2].Y = selection[2].Y + deltaY\
  3677.     else\
  3678.         for x = 1, self.Width do\
  3679.             pixels[x] = {}\
  3680.             for y = 1, self.Height do\
  3681.                 if self.Layer.Pixels[x - deltaX] and self.Layer.Pixels[x - deltaX][y - deltaY] then\
  3682.                     pixels[x][y] = self.Layer.Pixels[x - deltaX][y - deltaY]\
  3683.                 else\
  3684.                     pixels[x][y] = {\
  3685.                         BackgroundColour = bg,\
  3686.                         TextColour = colours.black,\
  3687.                         Character = ' '\
  3688.                     }\
  3689.                 end\
  3690.             end\
  3691.         end\
  3692.     end\
  3693.     self.Layer.Pixels = pixels\
  3694. end\
  3695. \
  3696. MergeWith = function(self, other)\
  3697.     for x, col in pairs(other.DrawnPixels) do\
  3698.         for y, pixel in pairs(col) do\
  3699.             if pixel then\
  3700.                 if pixel.BackgroundColour ~= colours.transparent then\
  3701.                     self.Layer.Pixels[x][y].BackgroundColour = pixel.BackgroundColour\
  3702.                 end\
  3703. \
  3704.                 if pixel.Character ~= ' ' then\
  3705.                     self.Layer.Pixels[x][y].Character = pixel.Character\
  3706.                     self.Layer.Pixels[x][y].TextColour = pixel.TextColour\
  3707.                 end\
  3708.             end\
  3709.         end\
  3710.     end\
  3711.     other:DeleteLayer(true)\
  3712.     self.Parent:PushState()\
  3713. end\
  3714. \
  3715. MergeDown = function(self)\
  3716.     if self.LayerIndex - 1 >= 1 then\
  3717.         local below = self.Parent.Children[self.LayerIndex - 1]\
  3718.         if self.Layer.LayerType == below.Layer.LayerType then\
  3719.             below:MergeWith(self)\
  3720.         else\
  3721.             self.Bedrock:DisplayAlertWindow('Cannot merge layer!', \"You can't merge layers of different types.\", {'Ok'}, function()end)\
  3722.         end\
  3723.     else\
  3724.         self.Bedrock:DisplayAlertWindow('Cannot merge layer!', \"There isn't a layer below this layer!\", {'Ok'}, function()end)\
  3725.     end\
  3726. end\
  3727. \
  3728. RenameLayer = function(self)\
  3729.     self.Bedrock:DisplayTextBoxWindow('Rename Layer', \"Enter the new name for the layer '\"..self.Layer.Name..\"'\", function(success, newName)\
  3730.         if success then\
  3731.             self.Layer.Name = newName\
  3732.             self.Parent:UpdateLayers()\
  3733.         end\
  3734.     end, self.Layer.Name, #self.Layer.Name)\
  3735. end\
  3736. \
  3737. OnUpdate = function(self, value)\
  3738.     if value == 'Visible' and self.Ready then\
  3739.         self.Layer.Visible = self.Visible\
  3740.     end\
  3741. end\
  3742. \
  3743. OnKeyChar = function(self, event, keychar)\
  3744.     local function updateCharPos()\
  3745.         if self.CursorPos[1] > #self.Layer.Pixels then\
  3746.             self.CursorPos[1] = 1\
  3747.             self.CursorPos[2] = self.CursorPos[2] + 1\
  3748.         elseif self.CursorPos[1] < 1 then\
  3749.             self.CursorPos[1] = #self.Layer.Pixels \
  3750.             self.CursorPos[2] = self.CursorPos[2] - 1\
  3751.         end\
  3752. \
  3753.         if self.CursorPos[2] > #self.Layer.Pixels[1] then\
  3754.             self.CursorPos = {1, 1}\
  3755.         elseif self.CursorPos[2] < 1 then\
  3756.             self.CursorPos = {#self.Layer.Pixels, #self.Layer.Pixels[1]}\
  3757.         end\
  3758.     end\
  3759.     if event == 'char' then\
  3760.         if keychar == 'nil' then\
  3761.             return\
  3762.         end\
  3763.         self.Layer.Pixels[self.CursorPos[1]][self.CursorPos[2]].Character = keychar\
  3764.         self.Layer.Pixels[self.CursorPos[1]][self.CursorPos[2]].TextColour = self.Parent.BrushColour\
  3765. \
  3766.         self.CursorPos[1] = self.CursorPos[1] + 1\
  3767.         updateCharPos()\
  3768.         self:ForceDraw()\
  3769.         return false\
  3770.     elseif event == 'key' then\
  3771.         if keychar == keys.enter then\
  3772.             self.CursorPos[2] = self.CursorPos[2] + 1\
  3773.         elseif keychar == keys.left then\
  3774.             self.CursorPos[1] = self.CursorPos[1] - 1\
  3775.         elseif keychar == keys.right then\
  3776.             self.CursorPos[1] = self.CursorPos[1] + 1\
  3777.         elseif keychar == keys.up then\
  3778.             self.CursorPos[2] = self.CursorPos[2] - 1\
  3779.         elseif keychar == keys.down then\
  3780.             self.CursorPos[2] = self.CursorPos[2] + 1\
  3781.         elseif keychar == keys.backspace then\
  3782.             self.CursorPos[1] = self.CursorPos[1] - 1\
  3783.             updateCharPos()\
  3784.             self.Layer.Pixels[self.CursorPos[1]][self.CursorPos[2]].Character = ' '\
  3785.             self.Layer.Pixels[self.CursorPos[1]][self.CursorPos[2]].TextColour = colours.black\
  3786.         elseif keychar == keys.home then\
  3787.             self.CursorPos[1] = 1\
  3788.         elseif keychar == keys.delete then\
  3789.             self.Layer.Pixels[self.CursorPos[1]][self.CursorPos[2]].Character = ' '\
  3790.             self.Layer.Pixels[self.CursorPos[1]][self.CursorPos[2]].TextColour = colours.black\
  3791.             self.CursorPos[1] = self.CursorPos[1] + 1\
  3792.         elseif keychar == keys[\"end\"] then\
  3793.             self.CursorPos[1] = #self.Layer.Pixels\
  3794.         else\
  3795.             return false\
  3796.         end\
  3797.         updateCharPos()\
  3798.         self:ForceDraw()\
  3799.     end\
  3800. end",["SidebarButton.lua"]="Inherit = 'Button'\
  3801. \
  3802. X = 1\
  3803. Width = 3\
  3804. Height = 1\
  3805. AutoWidth = false\
  3806. \
  3807. TextColour = colours.white\
  3808. ActiveTextColour = colours.lightGrey\
  3809. \
  3810. WindowDocked = false\
  3811. Window = false\
  3812. \
  3813. OnDraw = function(self, x, y)\
  3814.     local text = self.Text\
  3815.     if self.WindowDocked then\
  3816.         text = ' > '\
  3817.     end\
  3818. \
  3819.     local textColour = self.TextColour\
  3820.     if self.Toggle then\
  3821.         textColour = self.ActiveTextColour\
  3822.     end\
  3823.     if not self.Enabled then\
  3824.         textColour = self.DisabledTextColour\
  3825.     end\
  3826. \
  3827.     Drawing.DrawCharacters(x, y, text, textColour, colours.transparent)\
  3828. end\
  3829. \
  3830. \
  3831. OnClick = function(self, event, side, x, y)\
  3832.     if event == 'mouse_click' then\
  3833.         if self.WindowName and not self.Window then\
  3834.             self.Window = self.Bedrock:AddObject({\
  3835.                 [\"Y\"]=(self.Bedrock:GetAbsolutePosition(self)).Y,\
  3836.                 [\"Type\"]=self.WindowName,\
  3837.                 [\"Docked\"]=true,\
  3838.                 OnDockChange = function(_self, state)\
  3839.                     self.WindowDocked = state\
  3840.                     if state then\
  3841.                         _self.Y = (self.Bedrock:GetAbsolutePosition(self)).Y\
  3842.                         _self.X = Drawing.Screen.Width - _self.Width - 2\
  3843.                         self.Parent:OnDock()\
  3844.                     end\
  3845.                 end,\
  3846.                 OnClose = function(_self)\
  3847.                     self.Window = nil\
  3848.                     self.WindowDocked = false\
  3849.                 end\
  3850.             })\
  3851.             self.Window.X = Drawing.Screen.Width - self.Window.Width - 2\
  3852.             self.Parent:CloseDocked()\
  3853.             self.WindowDocked = true\
  3854.         else\
  3855.             self.Window:Close()\
  3856.         end\
  3857.     end\
  3858. end",["FiltersWindow.lua"]="Inherit = 'SnapWindow'\
  3859. ContentViewName = 'filterswindow'\
  3860. \
  3861. Title = 'Filters'\
  3862. \
  3863. OnContentLoad = function(self)\
  3864.     self:GetObject('ScrollView'):UpdateScroll()\
  3865. end",["InfoWindow.lua"]="Inherit = 'SnapWindow'\
  3866. ContentViewName = 'infowindow'\
  3867. \
  3868. Title = 'Info'\
  3869. \
  3870. OnContentLoad = function(self)\
  3871.     self:UpdateInfo()\
  3872. end\
  3873. \
  3874. UpdateInfo = function(self)\
  3875.     local artboard = self.Bedrock:GetObject('Artboard')\
  3876.     local selection = (artboard == nil or artboard.Selection == nil or artboard.Selection[1] == nil or artboard.Selection[2] == nil)\
  3877.     self:GetObject(\"CanvasWidthLabel\").Text = (artboard == nil and '-' or tostring(#artboard:GetCurrentLayer().Layer.Pixels))\
  3878.     self:GetObject(\"CanvasHeightLabel\").Text = (artboard == nil and '-' or tostring(#artboard:GetCurrentLayer().Layer.Pixels[1]))\
  3879.     self:GetObject(\"SelectionWidthLabel\").Text = (selection and '-' or tostring(math.abs(artboard.Selection[1].X-artboard.Selection[2].X)))\
  3880.     self:GetObject(\"SelectionHeightLabel\").Text = (selection and '-' or tostring(math.abs(artboard.Selection[1].Y-artboard.Selection[2].Y)))\
  3881.     self:GetObject(\"SelectionX1Label\").Text = (selection and '-' or tostring(artboard.Selection[1].X))\
  3882.     self:GetObject(\"SelectionY1Label\").Text = (selection and '-' or tostring(artboard.Selection[1].Y))\
  3883.     self:GetObject(\"SelectionX2Label\").Text = (selection and '-' or tostring(artboard.Selection[2].X))\
  3884.     self:GetObject(\"SelectionY2Label\").Text = (selection and '-' or tostring(artboard.Selection[2].Y))\
  3885. end",["ColourView.lua"]="OnDraw = function(self, x, y)\
  3886.     if self.BackgroundColour ~= colours.transparent then\
  3887.         Drawing.DrawBlankArea(x, y, self.Width, self.Height, self.BackgroundColour)\
  3888.     else\
  3889.         for _x = 1, self.Width do\
  3890.             local odd = (_x % 2) == 0\
  3891.             for _y = 1, self.Height do\
  3892.                 if odd then\
  3893.                     Drawing.WriteToBuffer(x + _x - 1, y + _y - 1, \":\", colours.lightGrey, colours.white)\
  3894.                 else\
  3895.                     Drawing.WriteToBuffer(x + _x - 1, y + _y - 1, \":\", colours.white, colours.lightGrey)\
  3896.                 end\
  3897.                 odd = not odd\
  3898.             end\
  3899.         end\
  3900.     end\
  3901. end",["BrushWindow.lua"]="Inherit = 'SnapWindow'\
  3902. ContentViewName = 'brushwindow'\
  3903. \
  3904. Title = 'Brush'\
  3905. \
  3906. OnContentLoad = function(self)\
  3907.     self:GetObject('SquareImageView').OnClick = function(_self, event, side, x, y)\
  3908.         local artboard = self.Bedrock:GetObject('Artboard')\
  3909.         if artboard then\
  3910.             artboard.BrushShape = 'Square'\
  3911.         end\
  3912.     end\
  3913. \
  3914.     self:GetObject('CircleImageView').OnClick = function(_self, event, side, x, y)\
  3915.         local artboard = self.Bedrock:GetObject('Artboard')\
  3916.         if artboard then\
  3917.             artboard.BrushShape = 'Circle'\
  3918.         end\
  3919.     end\
  3920. \
  3921.     local artboard = self.Bedrock:GetObject('Artboard')\
  3922.     if artboard then\
  3923.         self:GetObject('NumberBox').Value = artboard.BrushSize\
  3924.     end\
  3925. \
  3926.     self:GetObject('NumberBox').OnChange = function(_self)\
  3927.         local artboard = self.Bedrock:GetObject('Artboard')\
  3928.         if artboard then\
  3929.             artboard.BrushSize = _self.Value\
  3930.         end\
  3931.     end\
  3932. end",["ColoursWindow.lua"]="Inherit = 'SnapWindow'\
  3933. ContentViewName = 'colourswindow'\
  3934. \
  3935. Title = 'Colours'\
  3936. \
  3937. OnContentLoad = function(self)\
  3938.     local artboard = self.Bedrock:GetObject('Artboard')\
  3939.     if artboard then\
  3940.         self:GetObject('PrimaryColourButton').BackgroundColour = artboard.BrushColour\
  3941.         self:GetObject('SecondaryColourButton').BackgroundColour = artboard.SecondaryBrushColour\
  3942.     else\
  3943.         self:GetObject('PrimaryColourButton').BackgroundColour = colours.lightBlue\
  3944.         self:GetObject('SecondaryColourButton').BackgroundColour = colours.magenta\
  3945.     end\
  3946. \
  3947.     local buttons = self:GetObjects('ColourButton')\
  3948.     for i, button in ipairs(buttons) do\
  3949.         button.OnClick = function(_self, event, side, x , y)\
  3950.             local artboard = self.Bedrock:GetObject('Artboard')\
  3951.             if artboard then\
  3952.                 if side == 1 then\
  3953.                     artboard:SetBrushColour(button.BackgroundColour)\
  3954.                     self:GetObject('PrimaryColourButton').BackgroundColour = button.BackgroundColour\
  3955.                 elseif side == 2 then\
  3956.                     artboard:SetSecondaryBrushColour(button.BackgroundColour)\
  3957.                     self:GetObject('SecondaryColourButton').BackgroundColour = button.BackgroundColour\
  3958.                 end\
  3959.             end\
  3960.         end\
  3961.     end\
  3962. end",["SnapWindow.lua"]="Inherit = 'View'\
  3963. BackgroundColour = colours.white\
  3964. ToolBarColour = colours.grey\
  3965. ToolBarTextColour = colours.white\
  3966. ShadowColour = colours.grey\
  3967. Title = ''\
  3968. CanClose = true\
  3969. DragX = nil\
  3970. Z = 50\
  3971. \
  3972. OnLoad = function(self)\
  3973.     self:BringToFront()\
  3974.     self:AddObject({\
  3975.         X = 1, \
  3976.         Y = 1, \
  3977.         Width = 1, \
  3978.         Height = 1, \
  3979.         Type = 'Button', \
  3980.         BackgroundColour = colours.transparent,\
  3981.         TextColour = colours.lightGrey, \
  3982.         Text = 'x', \
  3983.         Name = 'CloseButton', \
  3984.         OnClick = function(btn)\
  3985.             if self.OnCloseButton then\
  3986.                 self:OnCloseButton()\
  3987.             end\
  3988.             self:Close()\
  3989.         end\
  3990.     })\
  3991. \
  3992.     local view = self:AddObject({\
  3993.         X = 1,\
  3994.         Y = 2,\
  3995.         InheritView = self.ContentViewName,\
  3996.         Type = 'View',\
  3997.         Name = 'ContentView'\
  3998.     })\
  3999. \
  4000.     if self.OnContentLoad then\
  4001.         self:OnContentLoad()\
  4002.     end\
  4003.     \
  4004.     self.Width = view.Width\
  4005.     self.Height = view.Height + 1\
  4006. \
  4007.     if self.Y + self.Height > Drawing.Screen.Height then\
  4008.         self.Y = Drawing.Screen.Height - self.Height + 1\
  4009.     end\
  4010. end\
  4011. \
  4012. OnWindowDrag = function(self, x, y)\
  4013.     local old = self.Docked\
  4014.     if x >= Drawing.Screen.Width - 2 then\
  4015.         self.Docked = true\
  4016.         self.Bedrock.DragWindow = nil\
  4017.     else\
  4018.         self.Docked = false\
  4019.     end\
  4020. \
  4021.     if old ~= self.Docked and self.OnDockChange then\
  4022.         self:OnDockChange(self.Docked)\
  4023.         if self.Y + self.Height > Drawing.Screen.Height then\
  4024.             self.Y = Drawing.Screen.Height - self.Height + 1\
  4025.         end\
  4026.     end\
  4027. end\
  4028. \
  4029. OnDraw = function(self, x, y)\
  4030.     Drawing.DrawBlankArea(x, y, self.Width, 1, self.ToolBarColour)\
  4031.     local title = self.Bedrock.Helpers.TruncateString(self.Title, self.Width - 2)\
  4032.     Drawing.DrawCharactersCenter(self.X, self.Y, self.Width, 1, title, self.ToolBarTextColour, self.ToolBarColour)\
  4033.     Drawing.IgnoreConstraint = true\
  4034.     Drawing.DrawBlankArea(x + 1, y + 1, self.Width, self.Height, self.ShadowColour)\
  4035.     Drawing.IgnoreConstraint = false\
  4036. end\
  4037. \
  4038. BringToFront = function(self)\
  4039.     for i = #self.Bedrock.View.Children, 1, -1 do\
  4040.         local child = self.Bedrock.View.Children[i]\
  4041. \
  4042.         if child.OnWindowDrag then\
  4043.             self.Z = child.Z + 1\
  4044.             break\
  4045.         end\
  4046.     end\
  4047.     self.Bedrock:ReorderObjects()\
  4048. end\
  4049. \
  4050. Click = function(self, event, side, x, y, z)\
  4051.     if self.Visible and not self.IgnoreClick then\
  4052.         self:BringToFront()\
  4053.         for i = #self.Children, 1, -1 do --children are ordered from smallest Z to highest, so this is done in reverse\
  4054.             local child = self.Children[i]\
  4055.             if self:DoClick(child, event, side, x, y) then\
  4056.                 if self.OnChildClick then\
  4057.                     self:OnChildClick(child, event, side, x, y)\
  4058.                 end\
  4059.                 return true\
  4060.             end\
  4061.         end\
  4062.         if event == 'mouse_click' and self.OnClick and self:OnClick(event, side, x, y) ~= false then\
  4063.             return true\
  4064.         elseif event == 'mouse_drag' and self.OnDrag and self:OnDrag(event, side, x, y) ~= false then\
  4065.             return true\
  4066.         elseif event == 'mouse_scroll' and self.OnScroll and self:OnScroll(event, side, x, y) ~= false then\
  4067.             return true\
  4068.         else\
  4069.             return false\
  4070.         end\
  4071.     else\
  4072.         return false\
  4073.     end\
  4074. end\
  4075. \
  4076. OnClick = function(self, event, side, x, y)\
  4077.     if x ~= 1 and y == 1 then\
  4078.         self.DragX = x\
  4079.         self.Bedrock.DragWindow = self\
  4080.         return true\
  4081.     end\
  4082.     return false\
  4083. end\
  4084. \
  4085. Close = function(self)\
  4086.     self.Bedrock:RemoveObject(self)\
  4087.     if self.OnClose then\
  4088.         self:OnClose()\
  4089.     end\
  4090. end\
  4091. \
  4092. OnUpdate = function(self, value)\
  4093.     if value == 'Children' and self:GetObject('ContentView') then\
  4094.         self.Width = self:GetObject('ContentView').Width\
  4095.         self.Height = self:GetObject('ContentView').Height + 1\
  4096.     end\
  4097. end",["Artboard.lua"]="Inherit = 'View'\
  4098. X = 2\
  4099. Y = 3\
  4100. Tool = nil\
  4101. BrushSize = 1\
  4102. BrushColour = nil\
  4103. SecondaryBrushColour = nil\
  4104. BrushShape = 'Circle'\
  4105. CorrectPixelRatio = false\
  4106. \
  4107. DragStart = nil\
  4108. DragTimer = nil\
  4109. Zoom = 1\
  4110. CurrentLayer = nil\
  4111. ShowFilterMasks = false\
  4112. History = {}\
  4113. HistoryPosition = 0\
  4114. SavedState = nil\
  4115. PushStateDelay = nil\
  4116. Selection = {}\
  4117. SelectionIsBlack = false\
  4118. SelectionTimer = nil\
  4119. UpdateDrawBlacklist = {['SelectionTimer']=true}\
  4120. \
  4121. OnDraw = function(self, x, y)\
  4122.     Drawing.IgnoreConstraint = true\
  4123.     Drawing.DrawBlankArea(x + 1, y + 1, self.Width, self.Height, colours.grey)\
  4124.     Drawing.IgnoreConstraint = false\
  4125.     \
  4126.     for _x = 1, self.Width do\
  4127.         local odd = (_x % 2) == 1\
  4128.         for _y = 1, self.Height do\
  4129.             if odd then\
  4130.                 Drawing.WriteToBuffer(x + _x - 1, y + _y - 1, \":\", colours.lightGrey, colours.white)\
  4131.             else\
  4132.                 Drawing.WriteToBuffer(x + _x - 1, y + _y - 1, \":\", colours.white, colours.lightGrey)\
  4133.             end\
  4134.             odd = not odd\
  4135.         end\
  4136.     end\
  4137. end\
  4138. \
  4139. OnPostChildrenDraw = function(self, x, y)\
  4140.     if self.Selection and self.Selection[1] and self.Selection[2] then\
  4141.         local point1 = {\
  4142.             X = self.Selection[1].X * self.Zoom,\
  4143.             Y = self.Selection[1].Y * self.Zoom\
  4144.         }\
  4145.         local point2 = {\
  4146.             X = self.Selection[2].X * self.Zoom,\
  4147.             Y = self.Selection[2].Y * self.Zoom\
  4148.         }\
  4149. \
  4150.         local size = {\
  4151.             X = point2.X - point1.X,\
  4152.             Y = point2.Y - point1.Y\
  4153.         }\
  4154. \
  4155.         local isBlack = self.SelectionIsBlack\
  4156. \
  4157.         local function c()\
  4158.             local c = colours.white\
  4159.             if isBlack then\
  4160.                 c = colours.black\
  4161.             end\
  4162.             isBlack = not isBlack\
  4163.             return c\
  4164.         end\
  4165. \
  4166.         function horizontal(y)\
  4167.             Drawing.WriteToBuffer(self.X - 1 + point1.X, self.Y - 1 + y, '+', c(), colours.transparent)\
  4168.             if size.X > 0 then\
  4169.                 for i = 1, size.X - 1 do\
  4170.                     Drawing.WriteToBuffer(self.X - 1 + point1.X + i, self.Y - 1 + y, '-', c(), colours.transparent)\
  4171.                 end\
  4172.             else\
  4173.                 for i = 1, (-1 * size.X) - 1 do\
  4174.                     Drawing.WriteToBuffer(self.X - 1 + point1.X - i, self.Y - 1 + y, '-', c(), colours.transparent)\
  4175.                 end\
  4176.             end\
  4177. \
  4178.             Drawing.WriteToBuffer(self.X - 1 + point1.X + size.X, self.Y - 1 + y, '+', c(), colours.transparent)\
  4179.         end\
  4180. \
  4181.         function vertical(x)\
  4182.             if size.Y < 0 then\
  4183.                 for i = 1, (-1 * size.Y) - 1 do\
  4184.                     Drawing.WriteToBuffer(self.X - 1 + x, self.Y - 1 + point1.Y  - i, '|', c(), colours.transparent)\
  4185.                 end\
  4186.             else\
  4187.                 for i = 1, size.Y - 1 do\
  4188.                     Drawing.WriteToBuffer(self.X - 1 + x, self.Y - 1 + point1.Y  + i, '|', c(), colours.transparent)\
  4189.                 end\
  4190.             end\
  4191.         end\
  4192. \
  4193.         horizontal(point1.Y)\
  4194.         vertical(point1.X)\
  4195.         horizontal(point1.Y + size.Y)\
  4196.         vertical(point1.X + size.X)\
  4197. \
  4198.         self.SelectionTimer = self.Bedrock:StartTimer(function(_, timer)\
  4199.             if timer == self.SelectionTimer then\
  4200.                 self.SelectionIsBlack = not self.SelectionIsBlack\
  4201.             end\
  4202.         end, 0.5)\
  4203.     end\
  4204. end\
  4205. \
  4206. CreateLayer = function(self, name, backgroundColour, _type, pixels, visible)\
  4207.     if not pixels then\
  4208.         self:PushState()\
  4209.         pixels = {}\
  4210. \
  4211.         for x = 1, self.Width do\
  4212.             pixels[x] = {}\
  4213.             for y = 1, self.Height do\
  4214.                 pixels[x][y] = {\
  4215.                     BackgroundColour = backgroundColour,\
  4216.                     TextColour = colours.black,\
  4217.                     Character = ' '\
  4218.                 }\
  4219.             end\
  4220.         end\
  4221.     elseif #pixels ~= self.Width or #pixels[1] ~= self.Height then\
  4222.         for x = 1, self.Width do\
  4223.             if not pixels[x] then\
  4224.                 pixels[x] = {}\
  4225.             end\
  4226.             for y = 1, self.Height do\
  4227.                 if not pixels[x][y] then\
  4228.                     pixels[x][y] = {\
  4229.                         BackgroundColour = backgroundColour,\
  4230.                         TextColour = colours.black,\
  4231.                         Character = ' '\
  4232.                     }\
  4233.                 end\
  4234.             end\
  4235.         end\
  4236.     end\
  4237. \
  4238.     local layer = {\
  4239.         Name = name,\
  4240.         Pixels = pixels,\
  4241.         BackgroundColour = backgroundColour or colours.transparent,\
  4242.         Visible = (visible ~= nil and visible or true),\
  4243.         Index = #self.Layers + 1,\
  4244.         LayerType = _type or 'Normal'\
  4245.     }\
  4246.     table.insert(self.Layers, layer)\
  4247. \
  4248.     self:UpdateLayers()\
  4249.     self:PushState()\
  4250.     return layer\
  4251. end\
  4252. \
  4253. \
  4254. -- copied from SO\
  4255. local function recursive_compare(t1,t2)\
  4256.  if t1==t2 then return true end\
  4257.  if (type(t1)~=\"table\") then return false end\
  4258.  local mt1 = getmetatable(t1)\
  4259.  local mt2 = getmetatable(t2)\
  4260.  if( not recursive_compare(mt1,mt2) ) then return false end\
  4261.  for k1,v1 in pairs(t1) do\
  4262.     if not t2[k1] then return false end\
  4263.    local v2 = t2[k1]\
  4264.    if( not recursive_compare(v1,v2) ) then return false end\
  4265.  end\
  4266.  for k2,v2 in pairs(t2) do\
  4267.     if not t1[k2] then return false end\
  4268.    local v1 = t1[k2]\
  4269.    if( not recursive_compare(v1,v2) ) then return false end\
  4270.  end\
  4271.  return true  \
  4272. end\
  4273. \
  4274. StatesEqual = function(self, one, two)\
  4275.     return recursive_compare(one, two)\
  4276. end\
  4277. \
  4278. -- copied from Lua docs\
  4279. local function deepcopy(orig)\
  4280.    local orig_type = type(orig)\
  4281.    local copy\
  4282.    if orig_type == 'table' then\
  4283.        copy = {}\
  4284.        for orig_key, orig_value in next, orig, nil do\
  4285.            copy[deepcopy(orig_key)] = deepcopy(orig_value)\
  4286.        end\
  4287.        setmetatable(copy, deepcopy(getmetatable(orig)))\
  4288.    else\
  4289.        copy = orig\
  4290.    end\
  4291.    return copy\
  4292. end\
  4293. \
  4294. PushState = function(self)\
  4295.     if #self.History == 0 or not self:StatesEqual(self.History[self.HistoryPosition], self.Layers) then\
  4296.         self.PushStateDelay = nil\
  4297.         table.insert(self.History, self.HistoryPosition + 1, deepcopy(self.Layers))\
  4298.         self.HistoryPosition = self.HistoryPosition + 1\
  4299.         self:UpdateUndoRedoMenuItems()\
  4300.     end\
  4301. end\
  4302. \
  4303. DelayedPushState = function(self)\
  4304.     if not self.PushStateDelay then\
  4305.         self.PushStateDelay = self.Bedrock:StartTimer(function()\
  4306.             self:PushState()\
  4307.         end, 1)\
  4308.     end\
  4309. end\
  4310. \
  4311. GoToHistoryPosition = function(self, position)\
  4312.     if position ~= self.HistoryPosition and position >= 1 and position <= #self.History then\
  4313.         self.HistoryPosition = position\
  4314.         self.Layers = deepcopy(self.History[self.HistoryPosition])\
  4315.         self:SetZoom(self.Zoom)\
  4316.         self:UpdateLayers()\
  4317.         self:ForceDraw()\
  4318.         self:UpdateUndoRedoMenuItems()\
  4319.     end\
  4320. end\
  4321. \
  4322. Undo = function(self)\
  4323.     self:GoToHistoryPosition(self.HistoryPosition - 1)\
  4324. end\
  4325. \
  4326. Redo = function(self)\
  4327.     self:GoToHistoryPosition(self.HistoryPosition + 1)\
  4328. end\
  4329. \
  4330. EraseSelection = function(self)\
  4331.     return (self:GetCurrentLayer():GetSelectedPixels(true) ~= nil)\
  4332. end\
  4333. \
  4334. Copy = function(self)\
  4335.     Clipboard.Copy(deepcopy(self:GetCurrentLayer():GetSelectedPixels()), 'sketchpixels')\
  4336.     self.Selection = nil\
  4337.     self:UpdateSelectionMenuItems()\
  4338.     self:UpdateClipboardMenuItems()\
  4339. end\
  4340. \
  4341. Cut = function(self)\
  4342.     Clipboard.Cut(deepcopy(self:GetCurrentLayer():GetSelectedPixels(true)), 'sketchpixels')\
  4343.     self.Selection = nil\
  4344.     self:UpdateSelectionMenuItems()\
  4345.     self:UpdateClipboardMenuItems()\
  4346. end\
  4347. \
  4348. Paste = function(self)\
  4349.     local pixels, t = Clipboard.Paste()\
  4350.     if pixels and t == 'sketchpixels' then\
  4351.         self:SetCurrentLayer(nil)\
  4352.         self:CreateLayer('Pasted Content', colours.transparent, 'Normal', pixels)\
  4353.         -- self:UpdateLayers()\
  4354.     end\
  4355.     self:UpdateClipboardMenuItems()\
  4356. end\
  4357. \
  4358. DuplicateLayer = function(self, layer)\
  4359.     local newLayer = deepcopy(layer)\
  4360.     newLayer.Name = newLayer.Name .. ' Copy'\
  4361.     table.insert(self.Layers, newLayer)\
  4362.     self:UpdateLayers()\
  4363.     self:PushState()\
  4364. end\
  4365. \
  4366. UpdateUndoRedoMenuItems = function(self)\
  4367.     self.Bedrock:GetObject('RedoMenuItem').Enabled = self.HistoryPosition < #self.History\
  4368.     self.Bedrock:GetObject('UndoMenuItem').Enabled = self.HistoryPosition > 1\
  4369. end\
  4370. \
  4371. UpdateSelectionMenuItems = function(self)\
  4372.     local selection = (self.Selection ~= nil and self.Selection[1] ~= nil and self.Selection[2] ~= nil)\
  4373.     self.Bedrock:GetObject('CutMenuItem').Enabled = selection\
  4374.     self.Bedrock:GetObject('CopyMenuItem').Enabled = selection\
  4375.     self.Bedrock:GetObject('CropMenuItem').Enabled = selection\
  4376.     self.Bedrock:GetObject('EraseMenuItem').Enabled = selection\
  4377.     local window = self.Bedrock:GetObject('InfoWindow')\
  4378.     if window then\
  4379.         window:UpdateInfo()\
  4380.     end\
  4381. end\
  4382. \
  4383. UpdateClipboardMenuItems = function(self)\
  4384.     self.Bedrock:GetObject('PasteMenuItem').Enabled = (Clipboard.Content ~= nil and Clipboard.Type == 'sketchpixels')\
  4385. end\
  4386. \
  4387. Modified = function(self, layers)\
  4388.     return not self:StatesEqual(self.History[self.HistoryPosition], self.SavedState)\
  4389. end\
  4390. \
  4391. SetBrushColour = function(self, value)\
  4392.     self.BrushColour = value\
  4393.     self.Bedrock:GetObject('PrimaryColourView').BackgroundColour = self.BrushColour\
  4394.     self:PushState()\
  4395. end\
  4396. \
  4397. SetSecondaryBrushColour = function(self, value)\
  4398.     self.SecondaryBrushColour = value\
  4399.     self.Bedrock:GetObject('SecondaryColourView').BackgroundColour = self.SecondaryBrushColour\
  4400.     self:PushState()\
  4401. end\
  4402. \
  4403. SetTool = function(self, value)\
  4404.     if not value.OnSelect or value.OnSelect(self) then\
  4405.         if self.Tool and self.Tool.OnStopUse then\
  4406.             self.Tool.OnStopUse(self)\
  4407.         end\
  4408. \
  4409.         self.Tool = value\
  4410.         self.Bedrock:GetObject('CurrentToolLabel').Text = self.Tool.Name\
  4411.         self:PushState()\
  4412.     end\
  4413. end\
  4414. \
  4415. SetZoom = function(self, value)\
  4416.     if value > 0 and value <= 4 then\
  4417.         self.Zoom = value\
  4418.         local pixels = self:GetCurrentLayer().Layer.Pixels\
  4419.         local width = self.Bedrock.Helpers.Round(self.Zoom * #pixels)\
  4420.         local height = self.Bedrock.Helpers.Round(self.Zoom * #pixels[1])\
  4421.         if width < 1 then\
  4422.             width = 1\
  4423.         end\
  4424.         if height < 1 then\
  4425.             height = 1\
  4426.         end\
  4427. \
  4428.         self.X = self.Bedrock.Helpers.Round(self.X + (self.Width - width)/2)\
  4429.         self.Y = self.Bedrock.Helpers.Round(self.Y + (self.Height - height)/2)\
  4430. \
  4431.         self.Width = width\
  4432.         self.Height = height\
  4433.     end\
  4434. end\
  4435. \
  4436. UpdateLayers = function(self)\
  4437.     self.CurrentLayer = nil\
  4438.     self:RemoveAllObjects()\
  4439. \
  4440.     for i, v in ipairs(self.Layers) do\
  4441.         self:AddObject({\
  4442.             Type = \"Layer\",\
  4443.             Layer = v,\
  4444.             Width = self.Width,\
  4445.             Height = self.Height,\
  4446.             LayerIndex = i\
  4447.         })\
  4448.     end\
  4449.     self:GetCurrentLayer()\
  4450. \
  4451.     local window = self.Bedrock:GetObject('LayersWindow')\
  4452.     if window then\
  4453.         window:UpdateLayers()\
  4454.     end\
  4455. end\
  4456. \
  4457. GetPixelBelowLayer = function(self, x, y, layerIndex)\
  4458.     local bgColour = colours.transparent\
  4459.     local txtColour = colours.transparent\
  4460.     local char = ' '\
  4461. \
  4462.     for i = 1, layerIndex - 1 do\
  4463.         if self.Children[i].Visible then\
  4464.             local p = self.Children[i].DrawnPixels[x][y]\
  4465.             if p then\
  4466.                 if p.BackgroundColour ~= colours.transparent then\
  4467.                     bgColour = p.BackgroundColour\
  4468.                 end\
  4469. \
  4470.                 if p.TextColour ~= colours.transparent and p.Character ~= ' ' then\
  4471.                     txtColour = p.TextColour\
  4472.                     char = p.Character\
  4473.                 end\
  4474.             end\
  4475.         end\
  4476.     end\
  4477.     return bgColour, txtColour, char\
  4478. end\
  4479. \
  4480. GetBackgroundColour = function(self)\
  4481.     for i = #self.Layers, 1, -1 do --children are ordered from smallest Z to highest, so this is done in reverse\
  4482.         if self.Layers[i].BackgroundColour ~= colours.transparent then\
  4483.             return self.Layers[i].BackgroundColour\
  4484.         end\
  4485.     end\
  4486.     return colours.transparent\
  4487. end\
  4488. \
  4489. GetFlattenedPixels = function(self)\
  4490.     local pixels = {}\
  4491.     for x = 1, self.Width do\
  4492.         pixels[x] = {}\
  4493.         for y = 1, self.Height do\
  4494.             pixels[x][y] = {\
  4495.                 BackgroundColour = self:GetBackgroundColour(),\
  4496.                 TextColour = colours.black,\
  4497.                 Character = ' '\
  4498.             }\
  4499.         end\
  4500.     end\
  4501. \
  4502.     self:Draw()\
  4503.     for i, v in ipairs(self.Children) do\
  4504.         for x, col in pairs(v.DrawnPixels) do\
  4505.             for y, pixel in pairs(col) do\
  4506.                 if pixel then\
  4507.                     if pixel.BackgroundColour ~= colours.transparent then\
  4508.                         pixels[x][y].BackgroundColour = pixel.BackgroundColour\
  4509.                     end\
  4510. \
  4511.                     if pixel.Character ~= ' ' then\
  4512.                         pixels[x][y].Character = pixel.Character\
  4513.                         pixels[x][y].TextColour = pixel.TextColour\
  4514.                     end\
  4515.                 end\
  4516.             end\
  4517.         end\
  4518.     end\
  4519.     return pixels\
  4520. end\
  4521. \
  4522. FlattenImage = function(self)\
  4523.     local pixels = self:GetFlattenedPixels()\
  4524.     self.Layers = {}\
  4525.     self:CreateLayer('Background', self:GetBackgroundColour(), 'Normal', pixels)\
  4526.     self:PushState()\
  4527. end\
  4528. \
  4529. Resize = function(self, width, height, keepTextDetail)\
  4530.     for i, layer in ipairs(self.Layers) do\
  4531.         self.Layers[i].Pixels = self.Children[i]:GetZoomPixels(width, height, keepTextDetail)\
  4532.     end\
  4533.     self.Width = width\
  4534.     self.Height = height\
  4535.     self.X = self.Bedrock.Helpers.Round((Drawing.Screen.Width - self.Width - 3) / 2)\
  4536.     self.Y = self.Bedrock.Helpers.Round((Drawing.Screen.Height - self.Height) / 2)\
  4537.     self:PushState()\
  4538.     self:UpdateLayers()\
  4539.     self:ForceDraw()\
  4540. end\
  4541. \
  4542. ChangeCanvasSize = function(self, width, height, anchor, top, bottom, left, right)\
  4543.     top = top or 0\
  4544.     bottom = bottom or 0\
  4545.     left = left or 0\
  4546.     right = right or 0\
  4547. \
  4548.     if anchor then\
  4549.         if anchor == 2 or anchor == 5 or anchor == 8 then\
  4550.             left = math.floor((width - self.Width) / 2)\
  4551.             right = math.ceil((width - self.Width) / 2)\
  4552.         elseif anchor == 1 or anchor == 4 or anchor == 7 then\
  4553.             right = width - self.Width\
  4554.         elseif anchor == 3 or anchor == 6 or anchor == 9 then\
  4555.             left = width - self.Width\
  4556.         end\
  4557. \
  4558.         if anchor / 3 <= 1 then\
  4559.             bottom = height - self.Height\
  4560.         elseif anchor / 3 <= 2 then\
  4561.             top = math.floor((height - self.Height) / 2)\
  4562.             bottom = math.ceil((height - self.Height) / 2)\
  4563.         else\
  4564.             top = height - self.Height\
  4565.         end\
  4566.     end\
  4567. \
  4568.     for i, layer in ipairs(self.Layers) do\
  4569.         if left < 0 then\
  4570.             for x = 1, -left do\
  4571.                 table.remove(layer.Pixels, 1)\
  4572.             end\
  4573.         end\
  4574. \
  4575.         if right < 0 then\
  4576.             for x = 1, -right do\
  4577.                 table.remove(layer.Pixels, #layer.Pixels)\
  4578.             end\
  4579.         end\
  4580. \
  4581.         if top < 0 then\
  4582.             for y = 1, -top do\
  4583.                 for x = 1, self.Width do\
  4584.                     if layer.Pixels[x] then\
  4585.                         table.remove(layer.Pixels[x], 1)\
  4586.                     end\
  4587.                 end\
  4588.             end\
  4589.         end\
  4590. \
  4591.         if bottom < 0 then\
  4592.             for y = 1, -bottom do\
  4593.                 for x = 1, self.Width do\
  4594.                     if layer.Pixels[x] then\
  4595.                         table.remove(layer.Pixels[x], #layer.Pixels[x])\
  4596.                     end\
  4597.                 end\
  4598.             end\
  4599.         end\
  4600. \
  4601.         for x = 1, left do\
  4602.             table.insert(layer.Pixels, 1, {})\
  4603.             for y = 1, height do\
  4604.                 layer.Pixels[1][y] = {BackgroundColour = layer.BackgroundColour, TextColour = colours.black, Character = ' '}\
  4605.             end\
  4606.         end\
  4607. \
  4608.         for x = 1, right do\
  4609.             table.insert(layer.Pixels, {})\
  4610.             for y = 1, height do\
  4611.                 layer.Pixels[#layer.Pixels][y] = {BackgroundColour = layer.BackgroundColour, TextColour = colours.black, Character = ' '}\
  4612.             end\
  4613.         end\
  4614. \
  4615.         for y = 1, top do\
  4616.             for x = 1, width do\
  4617.                 table.insert(layer.Pixels[x], 1, {})\
  4618.                 layer.Pixels[x][1] = {BackgroundColour = layer.BackgroundColour, TextColour = colours.black, Character = ' '}\
  4619.             end\
  4620.         end\
  4621. \
  4622.         for y = 1, bottom do\
  4623.             for x = 1, width do\
  4624.                 table.insert(layer.Pixels[x], {})\
  4625.                 layer.Pixels[x][#layer.Pixels[x]] = {BackgroundColour = layer.BackgroundColour, TextColour = colours.black, Character = ' '}\
  4626.             end\
  4627.         end\
  4628.     end\
  4629. \
  4630.     self.Width = width\
  4631.     self.Height = height\
  4632.     self.X = self.Bedrock.Helpers.Round((Drawing.Screen.Width - self.Width - 3) / 2)\
  4633.     self.Y = self.Bedrock.Helpers.Round((Drawing.Screen.Height - self.Height) / 2)\
  4634.     self:PushState()\
  4635.     self:UpdateLayers()\
  4636.     self:ForceDraw()\
  4637. end\
  4638. \
  4639. Crop = function(self)\
  4640.     if self.Selection and self.Selection[1] and self.Selection[2] then\
  4641.         local top = 0\
  4642.         local left = 0\
  4643.         local bottom = 0\
  4644.         local right = 0\
  4645.         if self.Selection[1].X < self.Selection[2].X then\
  4646.             left = self.Selection[1].X - 1\
  4647.             right = self.Width - self.Selection[2].X\
  4648.         else\
  4649.             left = self.Selection[2].X - 1\
  4650.             right = self.Width - self.Selection[1].X\
  4651.         end\
  4652.         if self.Selection[1].Y < self.Selection[2].Y then\
  4653.             top = self.Selection[1].Y - 1\
  4654.             bottom = self.Height - self.Selection[2].Y\
  4655.         else\
  4656.             top = self.Selection[2].Y - 1\
  4657.             bottom = self.Height - self.Selection[1].Y\
  4658.         end\
  4659.         self:ChangeCanvasSize(self.Width - left - right, self.Height - top - bottom, nil, -top, -bottom, -left, -right)\
  4660.         self.Selection = {}\
  4661.     end\
  4662. end\
  4663. \
  4664. SetSavedState = function(self)\
  4665.     self.SavedState = deepcopy(self.History[self.HistoryPosition])\
  4666. end\
  4667. \
  4668. OnLoad = function(self)\
  4669.     self:UpdateLayers()\
  4670.     self:SetTool(PencilTool)\
  4671.     self:SetBrushColour(colours.lightBlue)\
  4672.     self:SetSecondaryBrushColour(colours.magenta)\
  4673.     self.BrushSize = 1\
  4674. \
  4675.     self:PushState()\
  4676.     self:SetSavedState()\
  4677. \
  4678.     self.Bedrock.OnArtboardOpen(self)\
  4679.     self:UpdateUndoRedoMenuItems()\
  4680.     self:UpdateSelectionMenuItems()\
  4681.     self:UpdateClipboardMenuItems()\
  4682. end\
  4683. \
  4684. OnDeleteLayer = function(self, layer)\
  4685.     if layer == self.CurrentLayer then\
  4686.         self.CurrentLayer = self.Children[#self.Children]\
  4687.     end\
  4688.     self:PushState()\
  4689. end\
  4690. \
  4691. GetCurrentLayer = function(self)\
  4692.     if not self.CurrentLayer then\
  4693.         self:SetCurrentLayer(self.Children[#self.Children])\
  4694.     end\
  4695.     return self.CurrentLayer\
  4696. end\
  4697. \
  4698. SetCurrentLayer = function(self, layer)\
  4699.     self.CurrentLayer = layer\
  4700. \
  4701.     local window = self.Bedrock:GetObject('LayersWindow')\
  4702.     if window then\
  4703.         window:UpdateLayers()\
  4704.     end\
  4705. end\
  4706. \
  4707. OnUpdate = function(self, value)\
  4708.     if value == 'Layers' or value == 'Width' or value == 'Height' then\
  4709.         self:UpdateLayers()\
  4710.     elseif value == 'Selection' then\
  4711.         self:UpdateSelectionMenuItems()\
  4712.     end\
  4713. end\
  4714. \
  4715. OnClick = function(self, event, side, x, y)\
  4716.     if self.Tool then\
  4717.         self.Tool.OnUse(self, event, side, x, y)\
  4718.     end\
  4719. end\
  4720. \
  4721. OnRemove = function(self)\
  4722.     self.Bedrock.OnArtboardClose(self)\
  4723. end\
  4724. \
  4725. OnDrag = OnClick\
  4726. \
  4727. NewLayer = function(self)\
  4728.     self.Bedrock:DisplayTextBoxWindow('New Layer', \"Enter the name for the new layer.\", function(success, name)\
  4729.         if success then\
  4730.             self:CreateLayer(name, colours.transparent)\
  4731.         end\
  4732.     end)\
  4733. end",["Sidebar.lua"]="Inherit = 'View'\
  4734. \
  4735. BackgroundColour = colours.grey\
  4736. FlashingColour = colours.lightBlue\
  4737. Z = 101\
  4738. Flashing = false\
  4739. \
  4740. OnDraw = function(self, x, y)\
  4741.     local bgColour = self.BackgroundColour\
  4742.     if self.Flashing then\
  4743.         bgColour = self.FlashingColour\
  4744.     end\
  4745.     Drawing.DrawBlankArea(x, y, self.Width, self.Height, bgColour)\
  4746. end\
  4747. \
  4748. UpdateButtons = function(self, enabled)\
  4749.     for i, v in ipairs(self.Children) do\
  4750.         v.Enabled = enabled\
  4751.     end\
  4752. end\
  4753. \
  4754. CloseDocked = function(self)\
  4755.     for i, v in ipairs(self.Children) do\
  4756.         if v.WindowDocked then\
  4757.             v.Window:Close()\
  4758.         end\
  4759.     end\
  4760. end\
  4761. \
  4762. OnDock = function(self)\
  4763.     self.Flashing = true\
  4764.     self.Bedrock:StartTimer(function()\
  4765.         self.Flashing = false\
  4766.     end, 0.2)\
  4767. end",},}
  4768.  
  4769. local function run(tArgs)
  4770.  
  4771.   local fnFile, err = loadstring(files['startup'], 'startup')
  4772.   if err then
  4773.     error(err)
  4774.   end
  4775.  
  4776.   local function split(str, pat)
  4777.      local t = {}
  4778.      local fpat = "(.-)" .. pat
  4779.      local last_end = 1
  4780.      local s, e, cap = str:find(fpat, 1)
  4781.      while s do
  4782.         if s ~= 1 or cap ~= "" then
  4783.      table.insert(t,cap)
  4784.         end
  4785.         last_end = e+1
  4786.         s, e, cap = str:find(fpat, last_end)
  4787.      end
  4788.      if last_end <= #str then
  4789.         cap = str:sub(last_end)
  4790.         table.insert(t, cap)
  4791.      end
  4792.      return t
  4793.   end
  4794.  
  4795.   local function resolveTreeForPath(path, single)
  4796.     local _files = files
  4797.     local parts = split(path, '/')
  4798.     if parts then
  4799.       for i, v in ipairs(parts) do
  4800.         if #v > 0 then
  4801.           if _files[v] then
  4802.             _files = _files[v]
  4803.           else
  4804.             _files = nil
  4805.             break
  4806.           end
  4807.         end
  4808.       end
  4809.     elseif #path > 0 and path ~= '/' then
  4810.       _files = _files[path]
  4811.     end
  4812.     if not single or type(_files) == 'string' then
  4813.       return _files
  4814.     end
  4815.   end
  4816.  
  4817.   local oldFs = fs
  4818.   local env
  4819.   env = {
  4820.     fs = {
  4821.       list = function(path)
  4822.               local list = {}
  4823.               if fs.exists(path) then
  4824.             list = fs.list(path)
  4825.               end
  4826.         for k, v in pairs(resolveTreeForPath(path)) do
  4827.           if not fs.exists(path .. '/' ..k) then
  4828.             table.insert(list, k)
  4829.           end
  4830.         end
  4831.         return list
  4832.       end,
  4833.  
  4834.       exists = function(path)
  4835.         if fs.exists(path) then
  4836.           return true
  4837.         elseif resolveTreeForPath(path) then
  4838.           return true
  4839.         else
  4840.           return false
  4841.         end
  4842.       end,
  4843.  
  4844.       isDir = function(path)
  4845.         if fs.isDir(path) then
  4846.           return true
  4847.         else
  4848.           local tree = resolveTreeForPath(path)
  4849.           if tree and type(tree) == 'table' then
  4850.             return true
  4851.           else
  4852.             return false
  4853.           end
  4854.         end
  4855.       end,
  4856.  
  4857.       isReadOnly = function(path)
  4858.         if not fs.isReadOnly(path) then
  4859.           return false
  4860.         else
  4861.           return true
  4862.         end
  4863.       end,
  4864.  
  4865.       getName = fs.getName,
  4866.  
  4867.       getSize = fs.getSize,
  4868.  
  4869.       getFreespace = fs.getFreespace,
  4870.  
  4871.       makeDir = fs.makeDir,
  4872.  
  4873.       move = fs.move,
  4874.  
  4875.       copy = fs.copy,
  4876.  
  4877.       delete = fs.delete,
  4878.  
  4879.       combine = fs.combine,
  4880.  
  4881.       open = function(path, mode)
  4882.         if fs.exists(path) then
  4883.           return fs.open(path, mode)
  4884.         elseif type(resolveTreeForPath(path)) == 'string' then
  4885.           local handle = {close = function()end}
  4886.           if mode == 'r' then
  4887.             local content = resolveTreeForPath(path)
  4888.             handle.readAll = function()
  4889.               return content
  4890.             end
  4891.  
  4892.             local line = 1
  4893.             local lines = split(content, '\n')
  4894.             handle.readLine = function()
  4895.               if line > #lines then
  4896.                 return nil
  4897.               else
  4898.                 return lines[line]
  4899.               end
  4900.               line = line + 1
  4901.             end
  4902.                       return handle
  4903.           else
  4904.             error('Cannot write to read-only file (compilr archived).')
  4905.           end
  4906.         else
  4907.           return fs.open(path, mode)
  4908.         end
  4909.       end
  4910.     },
  4911.  
  4912.     io = {
  4913.       input = io.input,
  4914.       output = io.output,
  4915.       type = io.type,
  4916.       close = io.close,
  4917.       write = io.write,
  4918.       flush = io.flush,
  4919.       lines = io.lines,
  4920.       read = io.read,
  4921.       open = function(path, mode)
  4922.         if fs.exists(path) then
  4923.           return io.open(path, mode)
  4924.         elseif type(resolveTreeForPath(path)) == 'string' then
  4925.           local content = resolveTreeForPath(path)
  4926.           local f = fs.open(path, 'w')
  4927.           f.write(content)
  4928.           f.close()
  4929.           if mode == 'r' then
  4930.             return io.open(path, mode)
  4931.           else
  4932.             error('Cannot write to read-only file (compilr archived).')
  4933.           end
  4934.         else
  4935.           return io.open(path, mode)
  4936.         end
  4937.       end
  4938.     },
  4939.  
  4940.     loadfile = function( _sFile )
  4941.         local file = env.fs.open( _sFile, "r" )
  4942.         if file then
  4943.             local func, err = loadstring( file.readAll(), fs.getName( _sFile ) )
  4944.             file.close()
  4945.             return func, err
  4946.         end
  4947.         return nil, "File not found: ".._sFile
  4948.     end,
  4949.  
  4950.     dofile = function( _sFile )
  4951.         local fnFile, e = env.loadfile( _sFile )
  4952.         if fnFile then
  4953.             setfenv( fnFile, getfenv(2) )
  4954.             return fnFile()
  4955.         else
  4956.             error( e, 2 )
  4957.         end
  4958.     end
  4959.   }
  4960.  
  4961.   setmetatable( env, { __index = _G } )
  4962.  
  4963.   local tAPIsLoading = {}
  4964.   env.os.loadAPI = function( _sPath )
  4965.       local sName = fs.getName( _sPath )
  4966.       if tAPIsLoading[sName] == true then
  4967.           printError( "API "..sName.." is already being loaded" )
  4968.           return false
  4969.       end
  4970.       tAPIsLoading[sName] = true
  4971.          
  4972.       local tEnv = {}
  4973.       setmetatable( tEnv, { __index = env } )
  4974.       local fnAPI, err = env.loadfile( _sPath )
  4975.       if fnAPI then
  4976.           setfenv( fnAPI, tEnv )
  4977.           fnAPI()
  4978.       else
  4979.           printError( err )
  4980.           tAPIsLoading[sName] = nil
  4981.           return false
  4982.       end
  4983.      
  4984.       local tAPI = {}
  4985.       for k,v in pairs( tEnv ) do
  4986.           tAPI[k] =  v
  4987.       end
  4988.      
  4989.       env[sName] = tAPI    
  4990.       tAPIsLoading[sName] = nil
  4991.       return true
  4992.   end
  4993.  
  4994.   env.shell = shell
  4995.  
  4996.   setfenv( fnFile, env )
  4997.   fnFile(unpack(tArgs))
  4998. end
  4999.  
  5000. local function extract()
  5001.     local function node(path, tree)
  5002.         if type(tree) == 'table' then
  5003.             fs.makeDir(path)
  5004.             for k, v in pairs(tree) do
  5005.                 node(path .. '/' .. k, v)
  5006.             end
  5007.         else
  5008.             local f = fs.open(path, 'w')
  5009.             if f then
  5010.                 f.write(tree)
  5011.                 f.close()
  5012.             end
  5013.         end
  5014.     end
  5015.     node('', files)
  5016. end
  5017.  
  5018. local tArgs = {...}
  5019. if #tArgs == 1 and tArgs[1] == '--extract' then
  5020.   extract()
  5021. else
  5022.   run(tArgs)
  5023. end
Add Comment
Please, Sign In to add comment