Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Hideously Smashed Together by Compilr, a Hideous Smash-Stuff-Togetherer, (c) 2014 oeed --
- -- This file REALLLLLLLY isn't suitable to be used for anything other than being executed --
- -- To extract all the files, run: "<filename> --extract" in the Shell --
- local files = {["Icons"]={["nft"]="4f 3bnft\
- 3f d \
- df ",["nfp"]="4f 3bnfp\
- 3f d \
- df ",["skch"]="3bskch\
- 3f d \
- df ",},["icon"]="bf \
- b0Skch\
- 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\
- \
- local program = Bedrock:Initialise()\
- \
- function ViewClick(self, event, side, x, y)\
- if program.DragWindow and event == 'mouse_drag' then\
- program.DragWindow.X = x - program.DragWindow.DragX\
- program.DragWindow.Y = y\
- program.DragWindow:OnWindowDrag(x, y)\
- program.WindowDragTimer = program:StartTimer(function(_,timer)\
- if timer and timer == program.WindowDragTimer then\
- program.WindowDragTimer = nil\
- program.DragWindow = nil\
- end\
- end, 0.8)\
- elseif self.Visible and not self.IgnoreClick then\
- for i = #self.Children, 1, -1 do --children are ordered from smallest Z to highest, so this is done in reverse\
- local child = self.Children[i]\
- if self:DoClick(child, event, side, x, y) then\
- if self.OnChildClick then\
- self:OnChildClick(child, event, side, x, y)\
- end\
- return true\
- end\
- end\
- if event == 'mouse_click' and self.OnClick and self:OnClick(event, side, x, y) ~= false then\
- return true\
- elseif event == 'mouse_drag' and self.OnDrag and self:OnDrag(event, side, x, y) ~= false then\
- return true\
- elseif event == 'mouse_scroll' and self.OnScroll and self:OnScroll(event, side, x, y) ~= false then\
- return true\
- else\
- return false\
- end\
- else\
- return false\
- end\
- end\
- \
- function OpenDocument(path)\
- CloseDocument(function(success)\
- if success then\
- program:RemoveObject('Artboard')\
- local image = ImageIO.LoadDocument(path, program)\
- if image then\
- program:AddObject({\
- Type = 'Artboard',\
- X = program.Helpers.Round((Drawing.Screen.Width - image.Width - 3) / 2),\
- Y = program.Helpers.Round((Drawing.Screen.Height - image.Height) / 2),\
- Width = image.Width,\
- Height = image.Height,\
- ImageName = image.ImageName,\
- ImagePath = image.ImagePath,\
- ImageFormat = image.ImageFormat,\
- Layers = image.Layers,\
- })\
- end\
- end\
- end)\
- end\
- \
- function SaveWithFormat(path, format)\
- local err\
- local content\
- \
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- format = format:gsub('%.', '')\
- if format == 'skch' then\
- content = textutils.serialize(ImageIO.SaveSKCH(artboard.Layers))\
- elseif format == 'nft' then\
- content = ''\
- local lines = ImageIO.SaveNFT(artboard:GetFlattenedPixels())\
- for i, v in ipairs(lines) do\
- content = content .. v .. '\\n'\
- end\
- elseif format == 'nfp' then\
- content = ''\
- local lines = ImageIO.SaveNFP(artboard:GetFlattenedPixels())\
- for i, v in ipairs(lines) do\
- content = content .. v .. '\\n'\
- end\
- else\
- err = 'Unknown format \"'..format..'\"'\
- end\
- if not err and content then\
- local _fs = fs\
- if OneOS then\
- _fs = OneOS.FS\
- end\
- local h = _fs.open(path, 'w')\
- if h then\
- h.write(content)\
- h.close()\
- else\
- err = 'Could not open file.'\
- end\
- else\
- err = 'Content conversion failed.'\
- end\
- else\
- err = 'No artboard.'\
- end\
- \
- if err then\
- program:DisplayAlertWindow('Save Failed', \"Document write failed: \"..err, {'Ok'}, function(button)\
- end)\
- end\
- end\
- \
- function SaveDocument(callback)\
- callback = callback or function()end\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- if artboard.ImagePath then\
- SaveWithFormat(artboard.ImagePath, artboard.ImageFormat:lower())\
- artboard:SetSavedState()\
- callback(true)\
- else\
- program:DisplaySaveFileWindow('Save Image', function(success, path, filename)\
- if success then\
- SaveWithFormat(path, artboard.ImageFormat:lower())\
- artboard:SetSavedState()\
- artboard.ImagePath = path\
- callback(true)\
- else\
- callback(false)\
- end\
- end, artboard.ImageFormat:lower())\
- end\
- else\
- callback(false)\
- end\
- end\
- \
- local artboardOnlyMenuItems = {\
- 'Tool',\
- 'Save',\
- 'SaveAs',\
- 'Undo',\
- 'Redo',\
- 'Cut',\
- 'Copy',\
- 'Paste',\
- 'Resize',\
- 'CanvasSize',\
- 'Crop',\
- 'Erase',\
- 'Flatten',\
- 'ZoomIn',\
- 'ZoomOut',\
- '100%Zoom',\
- 'FitZoom',\
- 'FilterMask',\
- 'NewLayerImage'\
- }\
- \
- function program.OnArtboardOpen(artboard)\
- for i, v in ipairs(artboardOnlyMenuItems) do\
- for i2, v2 in ipairs(program:GetObjects(v..'MenuItem')) do\
- v2.Enabled = true\
- end\
- end\
- program:GetObject('Sidebar'):UpdateButtons(true)\
- end\
- \
- function program.OnArtboardClose(artboard)\
- for i, v in ipairs(artboardOnlyMenuItems) do\
- for i2, v2 in ipairs(program:GetObjects(v..'MenuItem')) do\
- v2.Enabled = false\
- end\
- end\
- program:GetObject('Sidebar'):UpdateButtons(false)\
- program:GetObject('CurrentToolLabel').Text = ''\
- program:GetObject('PrimaryColourView').BackgroundColour = colours.transparent\
- program:GetObject('SecondaryColourView').BackgroundColour = colours.transparent\
- end\
- \
- function NewDocument()\
- CloseDocument(function(success)\
- if success then\
- program:DisplayWindow('newdocumentwindow', 'New Document')\
- \
- local colourView = program.Window:GetObject('CurrentColourButton')\
- program.Window:GetObject('NoneColourButton').OnClick = function()\
- colourView.BackgroundColour = colours.transparent\
- end\
- \
- for i, v in ipairs(program.Window:GetObjects('BackgroundColourButton')) do\
- v.OnClick = function(self)\
- colourView.BackgroundColour = self.BackgroundColour\
- end\
- end\
- \
- local presetChanging = false\
- program:GetObject('WidthNumberBox').OnChange = function()\
- if not presetChanging then\
- program:GetObject('PresetButton').Text = 'Custom V'\
- end\
- end\
- program:GetObject('HeightNumberBox').OnChange = function()\
- if not presetChanging then\
- program:GetObject('PresetButton').Text = 'Custom V'\
- end\
- end\
- \
- program:GetObject('PresetButton').OnClick = function(self)\
- if self:ToggleMenu('sizepresetmenu', 1, 1) then\
- program:GetObject('CustomMenuItem').OnClick = function()\
- self.Text = 'Custom V'\
- end\
- \
- for i, v in ipairs(program:GetObjects('PresetMenuItem')) do\
- v.OnClick = function(_self)\
- local text = program.Helpers.TruncateString(_self.Text, 12)\
- for i = 1, 12 - #text do\
- text = text .. ' '\
- end\
- text = text .. 'V'\
- self.Text = text\
- presetChanging = true\
- program:GetObject('WidthNumberBox').Value = _self.SizeWidth\
- program:GetObject('HeightNumberBox').Value = _self.SizeHeight\
- presetChanging = false\
- end\
- end\
- end\
- end\
- \
- program:GetObject('CancelButton').OnClick = function()\
- program.Window:Close()\
- end\
- \
- program:GetObject('OkButton').OnClick = function()\
- local width = program:GetObject('WidthNumberBox').Value\
- local height = program:GetObject('HeightNumberBox').Value\
- local background = colourView.BackgroundColour\
- program.Window:Close()\
- \
- local pixels = {}\
- \
- for x = 1, width do\
- pixels[x] = {}\
- for y = 1, height do\
- pixels[x][y] = {\
- BackgroundColour = background,\
- TextColour = colours.black,\
- Character = ' '\
- }\
- end\
- end\
- \
- program:AddObject({\
- Type = 'Artboard',\
- X = program.Helpers.Round((Drawing.Screen.Width - width - 3) / 2),\
- Y = program.Helpers.Round((Drawing.Screen.Height - height) / 2),\
- Width = width,\
- Height = height,\
- ImageFormat = 'skch',\
- Layers = {\
- {\
- Name = 'Background',\
- Pixels = pixels,\
- BackgroundColour = background,\
- Visible = true,\
- Index = 1,\
- LayerType = 'Normal'\
- }\
- },\
- })\
- end\
- end\
- end)\
- end\
- \
- function SaveDocumentAs()\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- program:DisplayWindow('saveasformatwindow', 'Save As')\
- \
- local formatButtons = program:GetObjects('FormatButton')\
- local format = 'skch'\
- \
- for i, v in ipairs(formatButtons) do\
- v.OnClick = function(self)\
- self.Toggle = true\
- format = self.Format\
- for i2, v2 in ipairs(formatButtons) do\
- if v2 ~= self then\
- v2.Toggle = false\
- end\
- end\
- end\
- end\
- \
- program:GetObject('CancelButton').OnClick = function()\
- program.Window:Close()\
- end\
- \
- program:GetObject('NextButton').OnClick = function()\
- program.Window:Close()\
- program:DisplaySaveFileWindow('Save Image As', function(success, path, filename)\
- if success then\
- SaveWithFormat(path, format)\
- end\
- end, format)\
- end\
- end\
- end\
- \
- function CloseDocument(callback)\
- local artboard = program:GetObject('Artboard')\
- if artboard and artboard:Modified() then\
- program:DisplayAlertWindow('Unsaved Changes!', \"Save changes to your document?\", {'Save', 'Cancel', \"Don't Save\"}, function(button)\
- if button == 'Cancel' then\
- callback(false)\
- elseif button == \"Don't Save\" then\
- callback(true)\
- program:RemoveObject(artboard)\
- else\
- SaveDocument(function(success)\
- if success then\
- program:RemoveObject(artboard)\
- end\
- callback(success)\
- end)\
- end\
- end)\
- return false\
- else\
- program:RemoveObject('Artboard')\
- callback(true)\
- return true\
- end\
- end\
- \
- if OneOS then\
- OneOS.CanClose = function()\
- return CloseDocument(function(close)\
- if close then\
- program:Quit()\
- end\
- end)\
- end\
- end\
- \
- function ResizeDocument()\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- program:DisplayWindow('resizewindow', 'Resize Image')\
- \
- local constrainProportions = true\
- local keepTextDetail = true\
- local proportions = artboard.Width / artboard.Height\
- \
- local widthNumberBox = program:GetObject('WidthNumberBox')\
- local heightNumberBox = program:GetObject('HeightNumberBox')\
- \
- widthNumberBox.Value = artboard.Width\
- heightNumberBox.Value = artboard.Height\
- \
- local proportionChange = false\
- \
- widthNumberBox.OnChange = function()\
- if constrainProportions and not proportionChange then\
- proportionChange = true\
- heightNumberBox:SetValue(program.Helpers.Round(widthNumberBox.Value / proportions))\
- else\
- proportionChange = false\
- end\
- end\
- \
- heightNumberBox.OnChange = function()\
- if constrainProportions and not proportionChange then\
- proportionChange = true\
- widthNumberBox:SetValue(program.Helpers.Round(heightNumberBox.Value * proportions))\
- else\
- proportionChange = false\
- end\
- end\
- \
- program:GetObject('ProportionsButton').OnClick = function(self)\
- constrainProportions = self.Toggle\
- end\
- \
- program:GetObject('TextDetailButton').OnClick = function(self)\
- keepTextDetail = self.Toggle\
- end\
- \
- program:GetObject('ResizeButton').OnClick = function()\
- artboard:Resize(widthNumberBox.Value, heightNumberBox.Value, keepTextDetail)\
- program.Window:Close()\
- end\
- \
- program:GetObject('CancelButton').OnClick = function()\
- program.Window:Close()\
- end\
- end\
- end\
- \
- function ChangeCanvasSize()\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- print('splie')\
- program:DisplayWindow('canvassizewindow', 'Change Canvas Size')\
- \
- -- local constrainProportions = true\
- -- local keepTextDetail = true\
- -- local proportions = artboard.Width / artboard.Height\
- \
- local widthNumberBox = program:GetObject('WidthNumberBox')\
- local heightNumberBox = program:GetObject('HeightNumberBox')\
- \
- widthNumberBox.Value = artboard.Width\
- heightNumberBox.Value = artboard.Height\
- \
- local anchorPosition = 5\
- \
- local function updateAnchorButtons(self)\
- local anchors = {' ',' ',' ',' ',' ',' ',' ',' ',' '}\
- \
- -- i'm sure there's a better way to do this...\
- if anchorPosition == 1 then\
- anchors[1] = '#'\
- anchors[2] = '>'\
- anchors[4] = 'v'\
- elseif anchorPosition == 2 then\
- anchors[1] = '<'\
- anchors[2] = '#'\
- anchors[3] = '>'\
- anchors[5] = 'v'\
- elseif anchorPosition == 3 then\
- anchors[2] = '<'\
- anchors[3] = '#'\
- anchors[6] = 'v'\
- elseif anchorPosition == 4 then\
- anchors[1] = '^'\
- anchors[4] = '#'\
- anchors[5] = '>'\
- anchors[7] = 'v'\
- elseif anchorPosition == 5 then\
- anchors[2] = '^'\
- anchors[4] = '<'\
- anchors[5] = '#'\
- anchors[6] = '>'\
- anchors[8] = 'v'\
- elseif anchorPosition == 6 then\
- anchors[3] = '^'\
- anchors[6] = '#'\
- anchors[5] = '<'\
- anchors[9] = 'v'\
- elseif anchorPosition == 7 then\
- anchors[4] = '^'\
- anchors[7] = '#'\
- anchors[8] = '>'\
- elseif anchorPosition == 8 then\
- anchors[5] = '^'\
- anchors[8] = '#'\
- anchors[7] = '<'\
- anchors[9] = '>'\
- elseif anchorPosition == 9 then\
- anchors[6] = '^'\
- anchors[9] = '#'\
- anchors[8] = '<'\
- end\
- \
- if artboard.Height > heightNumberBox.Value then\
- for i, v in ipairs(anchors) do\
- if string.find(v, \"%^\") then\
- v = v:gsub('%^','v')\
- elseif string.find(v, \"v\") then\
- v = v:gsub('v','%^')\
- end\
- anchors[i] = v\
- end\
- end\
- \
- if artboard.Width > widthNumberBox.Value then\
- for i, v in ipairs(anchors) do\
- if string.find(v, \">\") then\
- v = v:gsub('>','<')\
- elseif string.find(v, \"<\") then\
- v = v:gsub('<','>')\
- end\
- anchors[i] = v\
- end\
- end\
- \
- for i, v in ipairs(anchors) do\
- program:GetObject('Anchor'..i..'Button').Text = v\
- end\
- end\
- \
- for i = 1, 9 do\
- program:GetObject('Anchor'..i..'Button').OnClick = function()\
- anchorPosition = i\
- updateAnchorButtons()\
- end\
- end\
- \
- updateAnchorButtons()\
- \
- widthNumberBox.OnChange = function()\
- updateAnchorButtons()\
- end\
- \
- heightNumberBox.OnChange = function()\
- updateAnchorButtons()\
- end\
- \
- program:GetObject('OkButton').OnClick = function()\
- artboard:ChangeCanvasSize(widthNumberBox.Value, heightNumberBox.Value, anchorPosition)\
- program.Window:Close()\
- end\
- \
- program:GetObject('CancelButton').OnClick = function()\
- program.Window:Close()\
- end\
- end\
- end\
- \
- local tArgs = {...}\
- \
- program:Run(function()\
- \
- if OneOS then\
- Clipboard = OneOS.Clipboard\
- end\
- \
- \
- -- NewDocument()\
- --------------------------------File Menu---------------------------------------\
- program:PrepareMenu('filemenu')\
- \
- program:GetObject('NewMenuItem').OnClick = function(self, event, side, x, y)\
- NewDocument()\
- end\
- program:GetObject('OpenMenuItem').OnClick = function(self, event, side, x, y)\
- program:DisplayOpenFileWindow('Open Image', function(success, path)\
- if success then\
- OpenDocument(path)\
- end\
- end)\
- end\
- program:GetObject('SaveMenuItem').OnClick = function(self, event, side, x, y)\
- SaveDocument()\
- end\
- program:GetObject('SaveAsMenuItem').OnClick = function(self, event, side, x, y)\
- SaveDocumentAs()\
- end\
- program:GetObject('QuitMenuItem').OnClick = function(self, event, side, x, y)\
- CloseDocument(function(close)\
- if close then\
- program:Quit()\
- term.setBackgroundColour(colours.black)\
- term.setTextColour(colours.white)\
- term.clear()\
- term.setCursorPos(1, 1)\
- \
- local function PrintCentered(text, y)\
- local w, h = term.getSize()\
- x = math.ceil(math.ceil((w / 2) - (#text / 2)), 0)+1\
- term.setCursorPos(x, y)\
- print(text)\
- end\
- \
- PrintCentered(\"Thanks for using Sketch 2!\", (Drawing.Screen.Height / 2) - 1)\
- term.setTextColour(colours.lightGrey)\
- PrintCentered(\"Photoshop Inspired Image Editor for ComputerCraft\", (Drawing.Screen.Height / 2))\
- term.setTextColour(colours.white)\
- PrintCentered(\"(c) oeed 2013 - 2014\", (Drawing.Screen.Height / 2) + 3)\
- term.setCursorPos(1, Drawing.Screen.Height)\
- end\
- end)\
- end\
- \
- program:GetObject('FileMenuButton').OnClick = function(self, event, side, x, y)\
- self:ToggleMenu('filemenu')\
- end\
- --------------------------------------------------------------------------------\
- \
- --------------------------------Edit Menu---------------------------------------\
- program:PrepareMenu('editmenu')\
- \
- program:GetObject('UndoMenuItem').OnClick = function(self, event, side, x, y)\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- artboard:Undo()\
- end\
- end\
- program:GetObject('RedoMenuItem').OnClick = function(self, event, side, x, y)\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- artboard:Redo()\
- end\
- end\
- program:GetObject('CutMenuItem').OnClick = function(self, event, side, x, y)\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- artboard:Cut()\
- end\
- end\
- program:GetObject('CopyMenuItem').OnClick = function(self, event, side, x, y)\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- artboard:Copy()\
- end\
- end\
- program:GetObject('PasteMenuItem').OnClick = function(self, event, side, x, y)\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- artboard:Paste()\
- end\
- end\
- \
- program:GetObject('EditMenuButton').OnClick = function(self, event, side, x, y)\
- self:ToggleMenu('editmenu')\
- end\
- --------------------------------------------------------------------------------\
- \
- --------------------------------Image Menu--------------------------------------\
- program:PrepareMenu('imagemenu')\
- \
- program:GetObject('ResizeMenuItem').OnClick = function(self, event, side, x, y)\
- ResizeDocument()\
- end\
- program:GetObject('CanvasSizeMenuItem').OnClick = function(self, event, side, x, y)\
- ChangeCanvasSize()\
- end\
- program:GetObject('CropMenuItem').OnClick = function(self, event, side, x, y)\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- artboard:Crop()\
- end\
- end\
- program:GetObject('EraseMenuItem').OnClick = function(self, event, side, x, y)\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- return artboard:EraseSelection()\
- end\
- return false\
- end\
- program:GetObject('NewLayerImageMenuItem').OnClick = function(self, event, side, x, y)\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- artboard:NewLayer()\
- end\
- end\
- program:GetObject('FlattenMenuItem').OnClick = function(self, event, side, x, y)\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- artboard:FlattenImage()\
- end\
- end\
- \
- program:GetObject('ImageMenuButton').OnClick = function(self, event, side, x, y)\
- self:ToggleMenu('imagemenu')\
- end\
- --------------------------------------------------------------------------------\
- \
- --------------------------------View Menu---------------------------------------\
- program:PrepareMenu('viewmenu')\
- \
- program:GetObject('ZoomOutMenuItem').OnClick = function(self, event, side, x, y)\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- artboard:SetZoom(artboard.Zoom / 2)\
- end\
- end\
- program:GetObject('ZoomInMenuItem').OnClick = function(self, event, side, x, y)\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- artboard:SetZoom(artboard.Zoom * 2)\
- end\
- end\
- program:GetObject('100%ZoomMenuItem').OnClick = function(self, event, side, x, y)\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- artboard:SetZoom(1)\
- end\
- end\
- program:GetObject('FilterMaskMenuItem').OnClick = function(self, event, side, x, y)\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- artboard.ShowFilterMask = not artboard.ShowFilterMask\
- end\
- end\
- \
- program:GetObject('ViewMenuButton').OnClick = function(self, event, side, x, y)\
- self:ToggleMenu('viewmenu')\
- end\
- --------------------------------------------------------------------------------\
- \
- --------------------------------Tools Menu--------------------------------------\
- program:PrepareMenu('toolsmenu')\
- \
- for i, v in ipairs(program:GetObjects('ToolMenuItem')) do\
- v.OnClick = function(self, event, side, x, y)\
- local artboard = program:GetObject('Artboard')\
- if artboard then\
- artboard:SetTool(getfenv()[self.ToolName])\
- end\
- end\
- end\
- program:GetObject('ToolsMenuButton').OnClick = function(self, event, side, x, y)\
- self:ToggleMenu('toolsmenu')\
- end\
- --------------------------------------------------------------------------------\
- \
- \
- program:GetObject('PrimaryColourView').OnClick = function(self, event, side, x, y)\
- program:GetObject('ColoursSidebarButton'):Click(event, side, x, y)\
- end\
- \
- program:GetObject('SecondaryColourView').OnClick = function(self, event, side, x, y)\
- program:GetObject('ColoursSidebarButton'):Click(event, side, x, y)\
- end\
- \
- program:GetObject('CurrentToolLabel').OnClick = function(self, event, side, x, y)\
- program:GetObject('ToolsSidebarButton'):Click(event, side, x, y)\
- end\
- \
- program.View.Click = ViewClick\
- \
- \
- program.OnArtboardClose()\
- \
- if #tArgs == 1 then\
- OpenDocument(tArgs[1])\
- else\
- NewDocument()\
- end\
- -- TODO: remove!\
- -- program:RegisterKeyboardShortcut({'\\\\'}, function()os.reboot()end)\
- end)",["APIs"]={["EraserTool.lua"]="Name = 'Eraser'\
- \
- OnUse = function(artboard, event, side, x, y)\
- local layer = artboard:GetCurrentLayer()\
- local pixels = layer:GetEffectedPixels(x, y, artboard.BrushSize, artboard.BrushShape, artboard.CorrectPixelRatio)\
- \
- local colour = colours.transparent\
- if layer.Layer.LayerType ~= 'Normal' then\
- colour = colours.black\
- else\
- colour = layer.BackgroundColour\
- end\
- \
- for i, pixel in ipairs(pixels) do\
- if side == 1 then\
- layer:SetPixel(pixel[1], pixel[2], colour)\
- elseif side == 2 then\
- layer:SetPixel(pixel[1], pixel[2], nil, colours.black, ' ')\
- end\
- end\
- end",["SprayTool.lua"]="Name = 'Spray'\
- \
- OnUse = function(artboard, event, side, x, y)\
- local layer = artboard:GetCurrentLayer()\
- -- artboard.BrushSize\
- local pixels = layer:GetEffectedPixels(x, y, artboard.BrushSize, artboard.BrushShape, artboard.CorrectPixelRatio)\
- \
- local colour = (side == 1 and artboard.BrushColour or artboard.SecondaryBrushColour)\
- if layer.Layer.LayerType ~= 'Normal' then\
- if colour == colours.transparent then\
- colour = colours.black\
- end\
- colour = Drawing.FilterColour(colour, Drawing.Filters.BlackWhite)\
- end\
- \
- for i, pixel in ipairs(pixels) do\
- if math.random(0, 3) == 0 then\
- if side == 1 then\
- layer:SetPixel(pixel[1], pixel[2], colour)\
- elseif side == 3 then\
- layer:SetPixel(pixel[1], pixel[2], nil, colour)\
- end\
- end\
- end\
- end",["SelectTool.lua"]="Name = 'Select'\
- \
- OnUse = function(artboard, event, side, x, y)\
- if event == 'mouse_click' then\
- artboard.Selection = {\
- {\
- X = x,\
- Y = y\
- },\
- nil\
- }\
- elseif event == 'mouse_drag' then\
- if artboard.Selection and artboard.Selection[1] then\
- artboard.Selection = {\
- artboard.Selection[1],\
- {\
- X = x,\
- Y = y\
- }\
- }\
- end\
- end\
- end",["HandTool.lua"]="Name = 'Hand'\
- \
- OnUse = function(artboard, event, side, x, y)\
- if event == 'mouse_click' then\
- artboard.DragStart = {x, y}\
- elseif event == 'mouse_drag' and artboard.DragStart then\
- local deltaX = x - artboard.DragStart[1]\
- local deltaY = y - artboard.DragStart[2]\
- artboard.X = artboard.X + deltaX\
- artboard.Y = artboard.Y + deltaY\
- else return\
- end\
- \
- artboard.DragTimer = artboard.Bedrock:StartTimer(function(_, timer)\
- if timer == artboard.DragTimer then\
- artboard.DragStart = nil\
- artboard.DragTimer = nil\
- end\
- end, 1)\
- end",["PencilTool.lua"]="Name = 'Pencil'\
- \
- OnUse = function(artboard, event, side, x, y)\
- local layer = artboard:GetCurrentLayer()\
- local pixels = layer:GetEffectedPixels(x, y, artboard.BrushSize, artboard.BrushShape, artboard.CorrectPixelRatio)\
- \
- local colour = (side == 1 and artboard.BrushColour or artboard.SecondaryBrushColour)\
- if layer.Layer.LayerType ~= 'Normal' then\
- if colour == colours.transparent then\
- colour = colours.black\
- end\
- colour = Drawing.FilterColour(colour, Drawing.Filters.BlackWhite)\
- end\
- \
- for i, pixel in ipairs(pixels) do\
- layer:SetPixel(pixel[1], pixel[2], colour)\
- -- elseif side == 3 then\
- -- layer:SetPixel(pixel[1], pixel[2], nil, colour)\
- -- end\
- end\
- end",["FillTool.lua"]="Name = 'Fill'\
- \
- OnUse = function(artboard, event, side, x, y)\
- local layer = artboard:GetCurrentLayer()\
- local pixels = layer.Layer.Pixels\
- local replaceColour = pixels[x][y].BackgroundColour\
- -- if side == 2 then\
- -- replaceColour = pixels[x][y].TextColour\
- -- end\
- \
- local colour = (side == 1 and artboard.BrushColour or artboard.SecondaryBrushColour)\
- \
- local nodes = {{X = x, Y = y}}\
- \
- while #nodes > 0 do\
- local node = nodes[1]\
- if pixels[node.X] and pixels[node.X][node.Y] then\
- local replacing = pixels[node.X][node.Y].BackgroundColour\
- -- if side == 2 then\
- -- replacing = pixels[node.X][node.Y].TextColour\
- -- end\
- if replacing == replaceColour and replacing ~= colour then\
- -- if side == 1 then\
- layer:SetPixel(node.X, node.Y, colour)\
- -- elseif side == 2 then\
- -- layer:SetPixel(node.X, node.Y, nil, colour)\
- -- end\
- table.insert(nodes, {X = node.X, Y = node.Y + 1})\
- table.insert(nodes, {X = node.X + 1, Y = node.Y})\
- if x > 1 then\
- table.insert(nodes, {X = node.X - 1, Y = node.Y})\
- end\
- if y > 1 then\
- table.insert(nodes, {X = node.X, Y = node.Y - 1})\
- end\
- end\
- end\
- table.remove(nodes, 1)\
- end\
- end\
- ",["ImageIO.lua"]="local hexnums = { [10] = \"a\", [11] = \"b\", [12] = \"c\", [13] = \"d\", [14] = \"e\" , [15] = \"f\" }\
- local function getHexOf(colour)\
- if colour == colours.transparent or not colour or not tonumber(colour) then\
- return \" \"\
- end\
- local value = math.log(colour)/math.log(2)\
- if value > 9 then\
- value = hexnums[value]\
- end\
- return value\
- end\
- \
- local function getColourOf(hex)\
- if hex == ' ' then\
- return colours.transparent\
- end\
- local value = tonumber(hex, 16)\
- if not value then return nil end\
- value = math.pow(2,value)\
- return value\
- end\
- \
- function SaveSKCH(layersIn)\
- local layers = {}\
- for i, l in ipairs(layersIn) do\
- local pixels = SaveNFT(l.Pixels)\
- local layer = {\
- Name = l.Name,\
- Pixels = pixels,\
- BackgroundColour = l.BackgroundColour,\
- Visible = l.Visible,\
- Index = l.Index,\
- LayerType = l.LayerType\
- }\
- table.insert(layers, layer)\
- end\
- return layers\
- end\
- \
- function SaveNFT(pixels)\
- local lines = {}\
- local width = #pixels\
- local height = #pixels[1]\
- for y = 1, height do\
- local line = ''\
- local currentBackgroundColour = nil\
- local currentTextColour = nil\
- for x = 1, width do\
- local pixel = pixels[x][y]\
- if pixel.BackgroundColour ~= currentBackgroundColour then\
- line = line..string.char(30)..getHexOf(pixel.BackgroundColour)\
- currentBackgroundColour = pixel.BackgroundColour\
- end\
- if pixel.TextColour ~= currentTextColour then\
- line = line..string.char(31)..getHexOf(pixel.TextColour)\
- currentTextColour = pixel.TextColour\
- end\
- line = line .. pixel.Character\
- end\
- table.insert(lines, line)\
- end\
- return lines\
- end\
- \
- function SaveNFP(pixels)\
- local lines = {}\
- local width = #pixels\
- local height = #pixels[1]\
- for y = 1, height do\
- local line = ''\
- for x = 1, width do\
- line = line .. getHexOf(pixels[x][y].BackgroundColour)\
- end\
- table.insert(lines, line)\
- end\
- return lines\
- end\
- \
- function ReadNFP(path)\
- local pixels = {}\
- local _fs = fs\
- if OneOS then\
- _fs = OneOS.FS\
- end\
- local file = _fs.open(path, 'r')\
- local line = file.readLine()\
- local y = 1\
- while line do\
- for x = 1, #line do\
- if not pixels[x] then\
- pixels[x] = {}\
- end\
- pixels[x][y] = {BackgroundColour = getColourOf(line:sub(x,x)), TextColour = colours.black, Character = ' '}\
- end\
- y = y + 1\
- line = file.readLine()\
- end\
- file.close()\
- return {{Pixels = pixels}}\
- end\
- \
- function ReadNFT(path)\
- local _fs = fs\
- if OneOS then\
- _fs = OneOS.FS\
- end\
- local file = _fs.open(path, 'r')\
- local line = file.readLine()\
- local lines = {}\
- while line do\
- table.insert(lines, line)\
- line = file.readLine()\
- end\
- file.close()\
- return {{Pixels = ParseNFT(lines)}}\
- end\
- \
- function ParseNFT(lines)\
- local pixels = {}\
- for y, line in ipairs(lines) do\
- local bgNext, fgNext = false, false\
- local currBG, currFG = nil,nil\
- local writePosition = 1\
- for x = 1, #line do\
- if not pixels[writePosition] then\
- pixels[writePosition] = {}\
- end\
- \
- local nextChar = string.sub(line, x, x)\
- if nextChar:byte() == 30 then\
- bgNext = true\
- elseif nextChar:byte() == 31 then\
- fgNext = true\
- elseif bgNext then\
- currBG = getColourOf(nextChar)\
- if currBG == nil then\
- currBG = colours.transparent\
- end\
- bgNext = false\
- elseif fgNext then\
- currFG = getColourOf(nextChar)\
- fgNext = false\
- else\
- if nextChar ~= \" \" and currFG == nil then\
- currFG = colours.white\
- end\
- pixels[writePosition][y] = {BackgroundColour = currBG, TextColour = currFG, Character = nextChar}\
- writePosition = writePosition + 1\
- end\
- end\
- end\
- return pixels\
- end\
- \
- function ReadSKCH(path)\
- local _fs = fs\
- if OneOS then\
- _fs = OneOS.FS\
- end\
- local file = _fs.open(path, 'r')\
- local _layers = textutils.unserialize(file.readAll())\
- file.close()\
- local layers = {}\
- \
- for i, l in ipairs(_layers) do\
- local layer = {\
- Name = l.Name,\
- Pixels = ParseNFT(l.Pixels),\
- BackgroundColour = l.BackgroundColour,\
- Visible = l.Visible,\
- Index = l.Index,\
- LayerType = l.LayerType or 'Normal'\
- }\
- table.insert(layers, layer)\
- end\
- return layers\
- end\
- \
- function GetFormat(path)\
- local _fs = fs\
- if OneOS then\
- _fs = OneOS.FS\
- end\
- local file = _fs.open(path, 'r')\
- local content = file.readAll()\
- file.close()\
- if type(textutils.unserialize(content)) == 'table' then\
- -- It's a serlized table, asume sketch\
- return '.skch'\
- elseif string.find(content, string.char(30)) or string.find(content, string.char(31)) then\
- -- Contains the characters that set colours, asume nft\
- return '.nft'\
- else\
- -- Otherwise asume nfp\
- return '.nfp'\
- end\
- end\
- \
- function LoadDocument(path, program)\
- local _fs = fs\
- if OneOS then\
- _fs = OneOS.FS\
- end\
- if _fs.exists(path) and not _fs.isDir(path) then\
- local format = program.Helpers.Extension(path, true)\
- if (not format or format == '') and (format ~= '.nfp' and format ~= '.nft' and format ~= '.skch') then\
- format = GetFormat(path)\
- end\
- local layers = {}\
- if format == '.nfp' then\
- layers = ReadNFP(path)\
- elseif format == '.nft' then\
- layers = ReadNFT(path) \
- elseif format == '.skch' then\
- layers = ReadSKCH(path)\
- end\
- \
- for i, layer in ipairs(layers) do\
- if layer.Visible == nil then\
- layer.Visible = true\
- end\
- if layer.Index == nil then\
- layer.Index = 1\
- end\
- if layer.Name == nil then\
- if layer.Index == 1 then\
- layer.Name = 'Background'\
- else\
- layer.Name = 'Layer'\
- end\
- end\
- \
- if layer.LayerType == nil then\
- layer.LayerType = 'Normal'\
- end\
- \
- if layer.BackgroundColour == nil then\
- layer.BackgroundColour = colours.white\
- end\
- end\
- \
- if not layers or not layers[1] or not layers[1].Pixels then\
- program:DisplayAlertWindow('File Read Failed', 'The image file appears to be corrupt, maybe it is of a unsupported format?', {'Ok'})\
- return\
- end\
- \
- local width = #layers[1].Pixels\
- local height = #layers[1].Pixels[1]\
- local _fs = fs\
- if OneOS then\
- _fs = OneOS.FS\
- end\
- \
- return {\
- Width=width,\
- Height=height,\
- ImageName=_fs.getName(path),\
- ImagePath=path,\
- ImageFormat=format,\
- Layers=layers\
- }\
- end\
- end",["Clipboard.lua"]="Content = nil\
- Type = nil\
- IsCut = false\
- \
- function Empty()\
- Clipboard.Content = nil\
- Clipboard.Type = nil\
- Clipboard.IsCut = false\
- end\
- \
- function isEmpty()\
- return Clipboard.Content == nil\
- end\
- \
- function Copy(content, _type)\
- Clipboard.Content = content\
- Clipboard.Type = _type or 'generic'\
- Clipboard.IsCut = false\
- end\
- \
- function Cut(content, _type)\
- Clipboard.Content = content\
- Clipboard.Type = _type or 'generic'\
- Clipboard.IsCut = true\
- end\
- \
- function Paste()\
- local c, t = Clipboard.Content, Clipboard.Type\
- if Clipboard.IsCut then\
- Clipboard.Empty()\
- end\
- return c, t\
- end",["TextTool.lua"]="Name = 'Text'\
- \
- OnUse = function(artboard, event, side, x, y)\
- local layer = artboard:GetCurrentLayer()\
- if layer.Layer.LayerType ~= 'Normal' then\
- layer.Bedrock:DisplayAlertWindow('Tool Not Supported!', \"You cannot use the text tool on non-normal layers.\", {'Ok'}, function()end)\
- elseif side == 1 then\
- layer.CursorPos = {x, y}\
- layer.Bedrock:SetActiveObject(layer)\
- elseif side == 2 then\
- local pixels = layer:GetEffectedPixels(x, y, artboard.BrushSize, artboard.BrushShape, artboard.CorrectPixelRatio)\
- for i, pixel in ipairs(pixels) do\
- layer:SetPixel(pixel[1], pixel[2], nil, artboard.BrushColour)\
- end\
- end\
- end\
- \
- OnStopUse = function(artboard)\
- local layer = artboard:GetCurrentLayer()\
- layer.Bedrock:SetActiveObject()\
- end",["MoveTool.lua"]="Name = 'Move'\
- \
- OnUse = function(artboard, event, side, x, y)\
- if event == 'mouse_click' then\
- artboard.MoveHandle = {\
- X = x,\
- Y = y\
- }\
- elseif event == 'mouse_drag' then\
- if artboard.MoveHandle and artboard.MoveHandle.X and artboard.MoveHandle.Y then\
- artboard:GetCurrentLayer():Move(x - artboard.MoveHandle.X, y - artboard.MoveHandle.Y)\
- artboard.MoveHandle = {\
- X = x,\
- Y = y\
- }\
- end\
- end\
- end",},["Resources"]={["circle.nft"]=" 7 7f 7 \
- 7f \
- 7 7f 7 ",["square.nft"]="7f \
- 7f \
- 7f ",["filterPreview.nft"]="3f 4 \
- df ",},["Views"]={["layerswindow.view"]="{\
- [\"Width\"]=20,\
- [\"Height\"]=9,\
- [\"BackgroundColour\"]=1,\
- [\"Children\"]={\
- [1]={\
- [\"Y\"]=1,\
- [\"X\"]=1,\
- [\"Width\"]=\"100%\",\
- [\"Height\"]=\"100%\",\
- [\"Type\"]=\"ScrollView\",\
- [\"Children\"]={\
- }\
- }\
- },\
- }",["canvassizewindow.view"]="{\
- [\"Width\"]=28,\
- [\"Height\"]=10,\
- [\"BackgroundColour\"]=1,\
- [\"Children\"]={\
- [1]={\
- [\"Y\"]=2,\
- [\"X\"]=6,\
- [\"Align\"]=\"Center\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"New Size\"\
- },\
- [2]={\
- [\"Y\"]=4,\
- [\"X\"]=3,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=32768,\
- [\"Text\"]=\"Width\"\
- },\
- [3]={\
- [\"Y\"]=4,\
- [\"X\"]=10,\
- [\"Name\"]=\"WidthNumberBox\",\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"NumberBox\",\
- [\"Value\"]=1,\
- },\
- [4]={\
- [\"Y\"]=6,\
- [\"X\"]=3,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=32768,\
- [\"Text\"]=\"Height\"\
- },\
- [5]={\
- [\"Y\"]=6,\
- [\"X\"]=10,\
- [\"Name\"]=\"HeightNumberBox\",\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"NumberBox\",\
- [\"Value\"]=1,\
- },\
- \
- [6]={\
- [\"Y\"]=2,\
- [\"X\"]=20,\
- [\"Align\"]=\"Center\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"Anchor\",\
- },\
- \
- \
- [7]={\
- [\"Y\"]=4,\
- [\"X\"]=21,\
- [\"Width\"]=1,\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"Anchor1Button\",\
- [\"ActiveBackgroundColour\"]=256,\
- [\"ActiveTextColour\"]=32768,\
- [\"Text\"]=\" \"\
- },\
- [8]={\
- [\"Y\"]=4,\
- [\"X\"]=22,\
- [\"Width\"]=1,\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"Anchor2Button\",\
- [\"ActiveBackgroundColour\"]=256,\
- [\"ActiveTextColour\"]=32768,\
- [\"Text\"]=\" \"\
- },\
- [9]={\
- [\"Y\"]=4,\
- [\"X\"]=23,\
- [\"Width\"]=1,\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"Anchor3Button\",\
- [\"ActiveBackgroundColour\"]=256,\
- [\"ActiveTextColour\"]=32768,\
- [\"Text\"]=\" \"\
- },\
- [10]={\
- [\"Y\"]=5,\
- [\"X\"]=21,\
- [\"Width\"]=1,\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"Anchor4Button\",\
- [\"ActiveBackgroundColour\"]=256,\
- [\"ActiveTextColour\"]=32768,\
- [\"Text\"]=\" \"\
- },\
- [11]={\
- [\"Y\"]=5,\
- [\"X\"]=22,\
- [\"Width\"]=1,\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"Anchor5Button\",\
- [\"ActiveBackgroundColour\"]=256,\
- [\"ActiveTextColour\"]=32768,\
- [\"Text\"]=\" \"\
- },\
- [12]={\
- [\"Y\"]=5,\
- [\"X\"]=23,\
- [\"Width\"]=1,\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"Anchor6Button\",\
- [\"ActiveBackgroundColour\"]=256,\
- [\"ActiveTextColour\"]=32768,\
- [\"Text\"]=\" \"\
- },\
- [13]={\
- [\"Y\"]=6,\
- [\"X\"]=21,\
- [\"Width\"]=1,\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"Anchor7Button\",\
- [\"ActiveBackgroundColour\"]=256,\
- [\"ActiveTextColour\"]=32768,\
- [\"Text\"]=\" \"\
- },\
- [14]={\
- [\"Y\"]=6,\
- [\"X\"]=22,\
- [\"Width\"]=1,\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"Anchor8Button\",\
- [\"ActiveBackgroundColour\"]=256,\
- [\"ActiveTextColour\"]=32768,\
- [\"Text\"]=\" \"\
- },\
- [15]={\
- [\"Y\"]=6,\
- [\"X\"]=23,\
- [\"Width\"]=1,\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"Anchor9Button\",\
- [\"ActiveBackgroundColour\"]=256,\
- [\"ActiveTextColour\"]=32768,\
- [\"Text\"]=\" \"\
- },\
- \
- \
- \
- \
- [16]={\
- [\"Y\"]=\"100%,-1\",\
- [\"X\"]=\"100%,-13\",\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"CancelButton\",\
- [\"Text\"]=\"Cancel\"\
- },\
- [17]={\
- [\"Y\"]=\"100%,-1\",\
- [\"X\"]=\"100%,-4\",\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"OkButton\",\
- [\"Text\"]=\"Ok\"\
- },\
- },\
- }",["sidebar.view"]="{\
- [\"Children\"]={\
- [1]={\
- [\"Y\"]=2,\
- [\"Type\"]=\"SidebarButton\",\
- [\"Name\"]=\"ColoursSidebarButton\",\
- [\"Text\"]=\"Col\",\
- [\"WindowName\"]=\"ColoursWindow\",\
- [\"Enabled\"]=false\
- },\
- [2]={\
- [\"Y\"]=4,\
- [\"Type\"]=\"SidebarButton\",\
- [\"Name\"]=\"ToolsSidebarButton\",\
- [\"Text\"]=\"Tol\",\
- [\"WindowName\"]=\"ToolsWindow\",\
- [\"Enabled\"]=false\
- },\
- [3]={\
- [\"Y\"]=6,\
- [\"Type\"]=\"SidebarButton\",\
- [\"Text\"]=\"Bru\",\
- [\"WindowName\"]=\"BrushWindow\",\
- [\"Enabled\"]=false\
- },\
- [4]={\
- [\"Y\"]=8,\
- [\"Type\"]=\"SidebarButton\",\
- [\"Text\"]=\"Lay\",\
- [\"WindowName\"]=\"LayersWindow\",\
- [\"Enabled\"]=false\
- },\
- [5]={\
- [\"Y\"]=10,\
- [\"Type\"]=\"SidebarButton\",\
- [\"Text\"]=\"Inf\",\
- [\"WindowName\"]=\"InfoWindow\",\
- [\"Enabled\"]=false\
- },\
- [6]={\
- [\"Y\"]=12,\
- [\"Type\"]=\"SidebarButton\",\
- [\"Text\"]=\"Flt\",\
- [\"WindowName\"]=\"FiltersWindow\",\
- [\"Enabled\"]=false\
- },\
- },\
- }",["filterswindow.view"]="{\
- [\"Width\"]=22,\
- [\"Height\"]=14,\
- [\"BackgroundColour\"]=1,\
- [\"Children\"]={\
- [1]={\
- [\"Y\"]=1,\
- [\"X\"]=1,\
- [\"Width\"]=\"100%\",\
- [\"Height\"]=\"100%\",\
- [\"Type\"]=\"ScrollView\",\
- [\"Children\"]={\
- [1]={\
- [\"Y\"]=2,\
- [\"X\"]=1,\
- [\"Width\"]=\"100%\",\
- [\"Type\"]=\"FilterPreview\",\
- [\"Filter\"]=\"None\",\
- [\"FilterName\"]=\"None\",\
- [\"Enabled\"]=false,\
- [\"TextColour\"]=256\
- },\
- [2]={\
- [\"Y\"]=5,\
- [\"X\"]=1,\
- [\"Width\"]=\"100%\",\
- [\"Type\"]=\"FilterPreview\",\
- [\"Filter\"]=\"Greyscale\",\
- [\"FilterName\"]=\"Greyscale\",\
- },\
- [3]={\
- [\"Y\"]=8,\
- [\"X\"]=1,\
- [\"Width\"]=\"100%\",\
- [\"Type\"]=\"FilterPreview\",\
- [\"Filter\"]=\"BlackWhite\",\
- [\"FilterName\"]=\"Black and White\",\
- },\
- [4]={\
- [\"Y\"]=11,\
- [\"X\"]=1,\
- [\"Width\"]=\"100%\",\
- [\"Type\"]=\"FilterPreview\",\
- [\"Filter\"]=\"Darker\",\
- [\"FilterName\"]=\"Darker\",\
- },\
- [5]={\
- [\"Y\"]=14,\
- [\"X\"]=1,\
- [\"Width\"]=\"100%\",\
- [\"Type\"]=\"FilterPreview\",\
- [\"Filter\"]=\"Lighter\",\
- [\"FilterName\"]=\"Lighter\",\
- },\
- [6]={\
- [\"Y\"]=17,\
- [\"X\"]=1,\
- [\"Width\"]=\"100%\",\
- [\"Type\"]=\"FilterPreview\",\
- [\"Filter\"]=\"Invert\",\
- [\"FilterName\"]=\"Invert\",\
- },\
- }\
- }\
- },\
- }",["infowindow.view"]="{\
- [\"Width\"]=13,\
- [\"Height\"]=13,\
- [\"BackgroundColour\"]=1,\
- [\"Children\"]={\
- [1]={\
- [\"Y\"]=2,\
- [\"X\"]=2,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=128,\
- [\"Text\"]=\"Canvas Size\"\
- },\
- [2]={\
- [\"Y\"]=3,\
- [\"X\"]=2,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"Width\"\
- },\
- [3]={\
- [\"Y\"]=3,\
- [\"X\"]=9,\
- [\"Width\"]=4,\
- [\"Align\"]=\"Left\",\
- [\"TextColour\"]=32768,\
- [\"Type\"]=\"Label\",\
- [\"Name\"]=\"CanvasWidthLabel\",\
- [\"Text\"]=\"-\"\
- },\
- [4]={\
- [\"Y\"]=4,\
- [\"X\"]=2,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"Height\"\
- },\
- [5]={\
- [\"Y\"]=4,\
- [\"X\"]=9,\
- [\"Width\"]=4,\
- [\"Align\"]=\"Left\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=32768,\
- [\"Name\"]=\"CanvasHeightLabel\",\
- [\"Text\"]=\"-\"\
- },\
- \
- [6]={\
- [\"Y\"]=6,\
- [\"X\"]=3,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=128,\
- [\"Text\"]=\"Selection\"\
- },\
- [7]={\
- [\"Y\"]=7,\
- [\"X\"]=2,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"Width\"\
- },\
- [8]={\
- [\"Y\"]=7,\
- [\"X\"]=9,\
- [\"Width\"]=4,\
- [\"Align\"]=\"Left\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=32768,\
- [\"Name\"]=\"SelectionWidthLabel\",\
- [\"Text\"]=\"-\"\
- },\
- [9]={\
- [\"Y\"]=8,\
- [\"X\"]=2,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"Height\"\
- },\
- [10]={\
- [\"Y\"]=8,\
- [\"X\"]=9,\
- [\"Width\"]=4,\
- [\"Align\"]=\"Left\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=32768,\
- [\"Name\"]=\"SelectionHeightLabel\",\
- [\"Text\"]=\"-\"\
- },\
- [11]={\
- [\"Y\"]=9,\
- [\"X\"]=4,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"X1\"\
- },\
- [12]={\
- [\"Y\"]=9,\
- [\"X\"]=9,\
- [\"Width\"]=4,\
- [\"Align\"]=\"Left\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=32768,\
- [\"Name\"]=\"SelectionX1Label\",\
- [\"Text\"]=\"-\"\
- },\
- [13]={\
- [\"Y\"]=10,\
- [\"X\"]=4,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"Y1\"\
- },\
- [14]={\
- [\"Y\"]=10,\
- [\"X\"]=9,\
- [\"Width\"]=4,\
- [\"Align\"]=\"Left\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=32768,\
- [\"Name\"]=\"SelectionY1Label\",\
- [\"Text\"]=\"-\"\
- },\
- [15]={\
- [\"Y\"]=11,\
- [\"X\"]=4,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"X2\"\
- },\
- [16]={\
- [\"Y\"]=11,\
- [\"X\"]=9,\
- [\"Width\"]=4,\
- [\"Align\"]=\"Left\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=32768,\
- [\"Name\"]=\"SelectionX2Label\",\
- [\"Text\"]=\"-\"\
- },\
- [17]={\
- [\"Y\"]=12,\
- [\"X\"]=4,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"Y2\"\
- },\
- [18]={\
- [\"Y\"]=12,\
- [\"X\"]=9,\
- [\"Width\"]=4,\
- [\"Align\"]=\"Left\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=32768,\
- [\"Name\"]=\"SelectionY2Label\",\
- [\"Text\"]=\"-\"\
- },\
- \
- }\
- }",["toolbar.view"]="{\
- [\"Width\"]=\"100%\",\
- [\"Height\"]=1,\
- [\"Type\"]=\"View\",\
- [\"BackgroundColour\"]=128,\
- [\"Z\"]=100,\
- [\"Children\"]={\
- [1]={\
- [\"X\"]=1,\
- [\"Name\"]=\"FileMenuButton\",\
- [\"Type\"]=\"Button\",\
- [\"TextColour\"]=1,\
- [\"Text\"]=\"File\",\
- [\"BackgroundColour\"]=0,\
- [\"Toggle\"]=false\
- },\
- [2]={\
- [\"X\"]=7,\
- [\"Name\"]=\"EditMenuButton\",\
- [\"Type\"]=\"Button\",\
- [\"TextColour\"]=1,\
- [\"Text\"]=\"Edit\",\
- [\"BackgroundColour\"]=0,\
- [\"Toggle\"]=false\
- },\
- [3]={\
- [\"X\"]=13,\
- [\"Name\"]=\"ImageMenuButton\",\
- [\"Type\"]=\"Button\",\
- [\"TextColour\"]=1,\
- [\"Text\"]=\"Image\",\
- [\"BackgroundColour\"]=0,\
- [\"Toggle\"]=false\
- },\
- [4]={\
- [\"X\"]=20,\
- [\"Name\"]=\"ViewMenuButton\",\
- [\"Type\"]=\"Button\",\
- [\"TextColour\"]=1,\
- [\"Text\"]=\"View\",\
- [\"BackgroundColour\"]=0,\
- [\"Toggle\"]=false\
- },\
- [5]={\
- [\"X\"]=26,\
- [\"Name\"]=\"ToolsMenuButton\",\
- [\"Type\"]=\"Button\",\
- [\"TextColour\"]=1,\
- [\"Text\"]=\"Tools\",\
- [\"BackgroundColour\"]=0,\
- [\"Toggle\"]=false\
- },\
- \
- [6]={\
- [\"Y\"]=1,\
- [\"X\"]=\"100%,-9\",\
- [\"Name\"]=\"CurrentToolLabel\",\
- [\"Type\"]=\"Label\",\
- [\"Width\"]=6,\
- [\"AutoWidth\"]=false,\
- [\"Height\"]=1,\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"\",\
- [\"Align\"]=\"Right\"\
- },\
- [7]={\
- [\"Y\"]=1,\
- [\"X\"]=\"100%,-2\",\
- [\"Name\"]=\"PrimaryColourView\",\
- [\"Type\"]=\"View\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=0\
- },\
- [8]={\
- [\"Y\"]=1,\
- [\"X\"]=\"100%\",\
- [\"Name\"]=\"SecondaryColourView\",\
- [\"Type\"]=\"View\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=0\
- },\
- },\
- }",["layermenu.view"]="{\
- [\"Type\"]=\"Menu\",\
- [\"Children\"]={\
- [1]={\
- [\"Name\"]=\"NewLayerMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"New Layer...\"\
- },\
- [2]={\
- [\"Name\"]=\"Separator\",\
- [\"Type\"]=\"Separator\"\
- },\
- [3]={\
- [\"Name\"]=\"RenameLayerMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Rename Layer...\"\
- },\
- [4]={\
- [\"Name\"]=\"DeleteLayerMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Delete Layer\"\
- },\
- [5]={\
- [\"Name\"]=\"DuplicateLayerMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Duplicate Layer\"\
- },\
- [6]={\
- [\"Name\"]=\"MergeDownLayerMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Merge Down\"\
- },\
- },\
- }",["toolsmenu.view"]="{\
- [\"Type\"]=\"Menu\",\
- [\"Owner\"]=\"ToolsMenuButton\",\
- [\"HideTop\"]=true,\
- [\"Children\"]={\
- [1]={\
- [\"Name\"]=\"ToolMenuItem\",\
- [\"ToolName\"]=\"HandTool\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Hand\",\
- [\"Shortcut\"]=\"~H\"\
- },\
- [2]={\
- [\"Name\"]=\"ToolMenuItem\",\
- [\"ToolName\"]=\"PencilTool\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Pencil\",\
- [\"Shortcut\"]=\"~P\"\
- },\
- [3]={\
- [\"Name\"]=\"ToolMenuItem\",\
- [\"ToolName\"]=\"FillTool\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Fill\",\
- [\"Shortcut\"]=\"~F\"\
- },\
- [4]={\
- [\"Name\"]=\"ToolMenuItem\",\
- [\"ToolName\"]=\"EraserTool\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Eraser\",\
- [\"Shortcut\"]=\"~E\"\
- },\
- [5]={\
- [\"Name\"]=\"ToolMenuItem\",\
- [\"ToolName\"]=\"TextTool\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Text\",\
- [\"Shortcut\"]=\"~T\"\
- },\
- [6]={\
- [\"Name\"]=\"ToolMenuItem\",\
- [\"ToolName\"]=\"SprayTool\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Spray\",\
- [\"Shortcut\"]=\"~R\"\
- },\
- [7]={\
- [\"Name\"]=\"ToolMenuItem\",\
- [\"ToolName\"]=\"MoveTool\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Move\",\
- [\"Shortcut\"]=\"~M\"\
- },\
- [8]={\
- [\"Name\"]=\"ToolMenuItem\",\
- [\"ToolName\"]=\"SelectTool\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Select\",\
- [\"Shortcut\"]=\"~S\"\
- },\
- },\
- }",["imagemenu.view"]="{\
- [\"Type\"]=\"Menu\",\
- [\"Owner\"]=\"ImageMenuButton\",\
- [\"HideTop\"]=true,\
- [\"Children\"]={\
- [1]={\
- [\"Name\"]=\"ResizeMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Resize Image...\",\
- [\"Shortcut\"]=\"~#I\"\
- },\
- [2]={\
- [\"Name\"]=\"CanvasSizeMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Canvas Size...\",\
- [\"Shortcut\"]=\"~#C\"\
- },\
- [3]={\
- [\"Name\"]=\"CropMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Crop\",\
- [\"Shortcut\"]=\"~#X\"\
- },\
- [4]={\
- [\"Name\"]=\"Separator\",\
- [\"Type\"]=\"Separator\"\
- },\
- [5]={\
- [\"Name\"]=\"NewLayerImageMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"New Layer\",\
- [\"Shortcut\"]=\"#L\"\
- },\
- [6]={\
- [\"Name\"]=\"Separator\",\
- [\"Type\"]=\"Separator\"\
- },\
- [7]={\
- [\"Name\"]=\"EraseMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Erase Selection\",\
- [\"Shortcut\"]=\"<\"\
- },\
- [8]={\
- [\"Name\"]=\"Separator\",\
- [\"Type\"]=\"Separator\"\
- },\
- [9]={\
- [\"Name\"]=\"FlattenMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Flatten Image\",\
- [\"Shortcut\"]=\"#F\"\
- }\
- },\
- }",["saveasformatwindow.view"]="{\
- [\"Width\"]=30,\
- [\"Height\"]=15,\
- [\"BackgroundColour\"]=1,\
- [\"Children\"]={\
- [1]={\
- [\"Y\"]=2,\
- [\"X\"]=1,\
- [\"Width\"]=\"100%\",\
- [\"Align\"]=\"Center\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=128,\
- [\"Text\"]=\"Choose Image Format\"\
- },\
- [2]={\
- [\"Y\"]=4,\
- [\"X\"]=2,\
- [\"Width\"]=1,\
- [\"Name\"]=\"FormatButton\",\
- [\"Format\"]=\"skch\",\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"Button\",\
- [\"Toggle\"]=true,\
- [\"ActiveBackgroundColour\"]=2048,\
- [\"ActiveTextColour\"]=1,\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"x\",\
- },\
- [3]={\
- [\"Y\"]=4,\
- [\"X\"]=4,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=128,\
- [\"Text\"]=\"Sketch (skch)\"\
- },\
- [4]={\
- [\"Y\"]=5,\
- [\"X\"]=4,\
- [\"Width\"]=\"100%,-4\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"Supports layers, filters, colour and text.\"\
- },\
- \
- \
- [5]={\
- [\"Y\"]=8,\
- [\"X\"]=2,\
- [\"Width\"]=1,\
- [\"Name\"]=\"FormatButton\",\
- [\"Format\"]=\"nft\",\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"Button\",\
- [\"Toggle\"]=false,\
- [\"ActiveBackgroundColour\"]=2048,\
- [\"ActiveTextColour\"]=1,\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"x\",\
- },\
- [6]={\
- [\"Y\"]=8,\
- [\"X\"]=4,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=128,\
- [\"Text\"]=\"NitroFingers Text (nft)\"\
- },\
- [7]={\
- [\"Y\"]=9,\
- [\"X\"]=4,\
- [\"Width\"]=\"100%,-4\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"Supports colour and text.\"\
- },\
- \
- \
- [8]={\
- [\"Y\"]=11,\
- [\"X\"]=2,\
- [\"Width\"]=1,\
- [\"Name\"]=\"FormatButton\",\
- [\"Format\"]=\"nfp\",\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"Button\",\
- [\"Toggle\"]=false,\
- [\"ActiveBackgroundColour\"]=2048,\
- [\"ActiveTextColour\"]=1,\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"x\",\
- },\
- [9]={\
- [\"Y\"]=11,\
- [\"X\"]=4,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=128,\
- [\"Text\"]=\"NitroFingers Paint (nfp)\"\
- },\
- [10]={\
- [\"Y\"]=12,\
- [\"X\"]=4,\
- [\"Width\"]=\"100%,-4\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"Supports colour.\"\
- },\
- \
- \
- [11]={\
- [\"Y\"]=\"100%,-1\",\
- [\"X\"]=\"100%,-16\",\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"CancelButton\",\
- [\"Text\"]=\"Cancel\"\
- },\
- [12]={\
- [\"Y\"]=\"100%,-1\",\
- [\"X\"]=\"100%,-6\",\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"NextButton\",\
- [\"Text\"]=\"Next\"\
- },\
- },\
- }",["sizepresetmenu.view"]="{\
- [\"Type\"]=\"Menu\",\
- [\"HideTop\"]=true,\
- [\"Children\"]={\
- [1]={\
- [\"Name\"]=\"CustomMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Custom\",\
- },\
- [2]={\
- [\"Type\"]=\"MenuItem\",\
- [\"Name\"]=\"PresetMenuItem\",\
- [\"Text\"]=\"OneOS Icon\",\
- [\"SizeWidth\"]=4,\
- [\"SizeHeight\"]=3,\
- },\
- [3]={\
- [\"Type\"]=\"MenuItem\",\
- [\"Name\"]=\"PresetMenuItem\",\
- [\"Text\"]=\"Computer Screen\",\
- [\"SizeWidth\"]=51,\
- [\"SizeHeight\"]=19,\
- },\
- [4]={\
- [\"Type\"]=\"MenuItem\",\
- [\"Name\"]=\"PresetMenuItem\",\
- [\"Text\"]=\"Pocket Computer Screen\",\
- [\"SizeWidth\"]=26,\
- [\"SizeHeight\"]=19,\
- },\
- [5]={\
- [\"Type\"]=\"MenuItem\",\
- [\"Name\"]=\"PresetMenuItem\",\
- [\"Text\"]=\"Turtle Screen\",\
- [\"SizeWidth\"]=39,\
- [\"SizeHeight\"]=13,\
- },\
- },\
- }",["resizewindow.view"]="{\
- [\"Width\"]=20,\
- [\"Height\"]=13,\
- [\"BackgroundColour\"]=1,\
- [\"Children\"]={\
- [1]={\
- [\"Y\"]=2,\
- [\"X\"]=1,\
- [\"Width\"]=\"100%\",\
- [\"Align\"]=\"Center\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"Stretch/Shrink\"\
- },\
- \
- [2]={\
- [\"Y\"]=4,\
- [\"X\"]=4,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=32768,\
- [\"Text\"]=\"Width\"\
- },\
- [3]={\
- [\"Y\"]=4,\
- [\"X\"]=11,\
- [\"Name\"]=\"WidthNumberBox\",\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"NumberBox\",\
- [\"Value\"]=1,\
- },\
- [4]={\
- [\"Y\"]=6,\
- [\"X\"]=4,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=32768,\
- [\"Text\"]=\"Height\"\
- },\
- [5]={\
- [\"Y\"]=6,\
- [\"X\"]=11,\
- [\"Name\"]=\"HeightNumberBox\",\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"NumberBox\",\
- [\"Value\"]=1,\
- },\
- \
- [6]={\
- [\"Y\"]=8,\
- [\"X\"]=2,\
- [\"Width\"]=1,\
- [\"Name\"]=\"ProportionsButton\",\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"Button\",\
- [\"Toggle\"]=true,\
- [\"ActiveBackgroundColour\"]=2048,\
- [\"ActiveTextColour\"]=1,\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"x\",\
- },\
- [7]={\
- [\"Y\"]=8,\
- [\"X\"]=4,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=128,\
- [\"Text\"]=\"Lock Proportions\"\
- },\
- [8]={\
- [\"Y\"]=10,\
- [\"X\"]=2,\
- [\"Width\"]=1,\
- [\"Name\"]=\"TextDetailButton\",\
- [\"AutoWidth\"]=false,\
- [\"Type\"]=\"Button\",\
- [\"Toggle\"]=true,\
- [\"ActiveBackgroundColour\"]=2048,\
- [\"ActiveTextColour\"]=1,\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"x\",\
- },\
- [9]={\
- [\"Y\"]=10,\
- [\"X\"]=4,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=128,\
- [\"Text\"]=\"Keep Text Detail\"\
- },\
- \
- [10]={\
- [\"Y\"]=\"100%,-1\",\
- [\"X\"]=\"100%,-17\",\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"CancelButton\",\
- [\"Text\"]=\"Cancel\"\
- },\
- [11]={\
- [\"Y\"]=\"100%,-1\",\
- [\"X\"]=\"100%,-8\",\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ResizeButton\",\
- [\"Text\"]=\"Resize\"\
- },\
- },\
- }",["brushwindow.view"]="{\
- [\"Width\"]=13,\
- [\"Height\"]=9,\
- [\"BackgroundColour\"]=1,\
- [\"Children\"]={\
- [1]={\
- [\"Y\"]=2,\
- [\"X\"]=2,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"Size\"\
- },\
- [2]={\
- [\"Y\"]=2,\
- [\"X\"]=7,\
- [\"Width\"]=6,\
- [\"Type\"]=\"NumberBox\",\
- [\"TextColour\"]=128,\
- [\"Text\"]=\"2\",\
- },\
- [3]={\
- [\"Y\"]=4,\
- [\"X\"]=2,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=256,\
- [\"Text\"]=\"Shape\"\
- },\
- [4]={\
- [\"Y\"]=6,\
- [\"X\"]=3,\
- [\"Width\"]=3,\
- [\"Height\"]=3,\
- [\"Type\"]=\"ImageView\",\
- [\"Name\"]=\"SquareImageView\",\
- [\"Path\"]=\"Resources/square.nft\"\
- },\
- [5]={\
- [\"Y\"]=6,\
- [\"X\"]=9,\
- [\"Width\"]=3,\
- [\"Height\"]=3,\
- [\"Type\"]=\"ImageView\",\
- [\"Name\"]=\"CircleImageView\",\
- [\"Path\"]=\"Resources/circle.nft\"\
- },\
- },\
- }",["newdocumentwindow.view"]="{\
- [\"Width\"]=29,\
- [\"Height\"]=11,\
- [\"BackgroundColour\"]=1,\
- [\"Children\"]={\
- [1]={\
- [\"Y\"]=2,\
- [\"X\"]=1,\
- [\"Width\"]=15,\
- [\"Align\"]=\"Center\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=128,\
- [\"Text\"]=\"Size\"\
- },\
- [2]={\
- [\"Y\"]=4,\
- [\"X\"]=2,\
- [\"Width\"]=15,\
- [\"Name\"]=\"PresetButton\",\
- [\"Type\"]=\"Button\",\
- [\"Text\"]=\"Custom V\",\
- [\"Toggle\"]=false\
- },\
- [3]={\
- [\"Y\"]=6,\
- [\"X\"]=2,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=128,\
- [\"Text\"]=\"Width\"\
- },\
- [4]={\
- [\"Y\"]=6,\
- [\"X\"]=9,\
- [\"Width\"]=7,\
- [\"Name\"]=\"WidthNumberBox\",\
- [\"Type\"]=\"NumberBox\",\
- [\"Minimum\"]=1,\
- [\"Value\"]=15,\
- },\
- [5]={\
- [\"Y\"]=8,\
- [\"X\"]=2,\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=128,\
- [\"Text\"]=\"Height\"\
- },\
- [6]={\
- [\"Y\"]=8,\
- [\"X\"]=9,\
- [\"Width\"]=7,\
- [\"Name\"]=\"HeightNumberBox\",\
- [\"Type\"]=\"NumberBox\",\
- [\"Minimum\"]=1,\
- [\"Value\"]=10,\
- },\
- \
- [7]={\
- [\"Y\"]=1,\
- [\"X\"]=17,\
- [\"Height\"]=\"100%,-3\",\
- [\"Type\"]=\"Separator\",\
- [\"Minimum\"]=1,\
- [\"Value\"]=15,\
- },\
- \
- [8]={\
- [\"Y\"]=2,\
- [\"X\"]=19,\
- [\"Width\"]=10,\
- [\"Align\"]=\"Center\",\
- [\"Type\"]=\"Label\",\
- [\"TextColour\"]=128,\
- [\"Text\"]=\"Background\"\
- },\
- \
- \
- [9]={\
- [\"X\"]=19,\
- [\"Y\"]=4,\
- [\"Name\"]=\"CurrentColourButton\",\
- [\"Type\"]=\"ColourView\",\
- [\"Width\"]=3,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=0,\
- [\"ActiveBackgroundColour\"]=0\
- },\
- [10]={\
- [\"X\"]=23,\
- [\"Y\"]=4,\
- [\"Name\"]=\"NoneColourButton\",\
- [\"Type\"]=\"Button\",\
- [\"Height\"]=1,\
- [\"Text\"]=\"None\"\
- },\
- [11]={\
- [\"Y\"]=6,\
- [\"X\"]=20,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=1,\
- [\"ActiveBackgroundColour\"]=1\
- },\
- [12]={\
- [\"Y\"]=6,\
- [\"X\"]=21,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=16,\
- [\"ActiveBackgroundColour\"]=16\
- },\
- [13]={\
- [\"Y\"]=6,\
- [\"X\"]=22,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=2,\
- [\"ActiveBackgroundColour\"]=2\
- },\
- [14]={\
- [\"Y\"]=6,\
- [\"X\"]=23,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=16384,\
- [\"ActiveBackgroundColour\"]=16384\
- },\
- \
- [15]={\
- [\"Y\"]=6,\
- [\"X\"]=24,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=8192,\
- [\"ActiveBackgroundColour\"]=8192\
- },\
- [16]={\
- [\"Y\"]=6,\
- [\"X\"]=25,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=32,\
- [\"ActiveBackgroundColour\"]=32\
- },\
- [17]={\
- [\"Y\"]=6,\
- [\"X\"]=26,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=4,\
- [\"ActiveBackgroundColour\"]=4\
- },\
- [18]={\
- [\"Y\"]=6,\
- [\"X\"]=27,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=64,\
- [\"ActiveBackgroundColour\"]=64\
- },\
- \
- [19]={\
- [\"Y\"]=7,\
- [\"X\"]=20,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=1024,\
- [\"ActiveBackgroundColour\"]=1024\
- },\
- [20]={\
- [\"Y\"]=7,\
- [\"X\"]=21,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=2048,\
- [\"ActiveBackgroundColour\"]=2048\
- },\
- [21]={\
- [\"Y\"]=7,\
- [\"X\"]=22,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=512,\
- [\"ActiveBackgroundColour\"]=512\
- },\
- [22]={\
- [\"Y\"]=7,\
- [\"X\"]=23,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=8,\
- [\"ActiveBackgroundColour\"]=8\
- },\
- \
- [23]={\
- [\"Y\"]=7,\
- [\"X\"]=24,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=256,\
- [\"ActiveBackgroundColour\"]=256\
- },\
- [24]={\
- [\"Y\"]=7,\
- [\"X\"]=25,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=128,\
- [\"ActiveBackgroundColour\"]=128\
- },\
- [25]={\
- [\"Y\"]=7,\
- [\"X\"]=26,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=32768,\
- [\"ActiveBackgroundColour\"]=32768\
- },\
- [26]={\
- [\"Y\"]=7,\
- [\"X\"]=27,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"BackgroundColourButton\",\
- [\"Width\"]=1,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=4096,\
- [\"ActiveBackgroundColour\"]=4096\
- },\
- \
- \
- \
- [27]={\
- [\"Y\"]=\"100%,-1\",\
- [\"X\"]=\"100%,-13\",\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"CancelButton\",\
- [\"Text\"]=\"Cancel\"\
- },\
- [28]={\
- [\"Y\"]=\"100%,-1\",\
- [\"X\"]=\"100%,-4\",\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"OkButton\",\
- [\"Text\"]=\"Ok\"\
- },\
- },\
- }",["main.view"]="{\
- [\"Children\"]={\
- [1]={\
- [\"Y\"]=1,\
- [\"X\"]=1,\
- [\"Name\"]=\"Toolbar\",\
- [\"Type\"]=\"View\",\
- [\"InheritView\"]=\"toolbar\"\
- },\
- [2]={\
- [\"Y\"]=2,\
- [\"X\"]=\"100%,-2\",\
- [\"Type\"]=\"Sidebar\",\
- [\"InheritView\"]=\"sidebar\",\
- [\"Height\"]=\"100%,-1\",\
- [\"Width\"]=3\
- },\
- },\
- [\"BackgroundColour\"]=32768,\
- [\"ToolBarColour\"]=128,\
- [\"ToolBarTextColour\"]=1\
- }",["editmenu.view"]="{\
- [\"Type\"]=\"Menu\",\
- [\"Owner\"]=\"EditMenuButton\",\
- [\"HideTop\"]=true,\
- [\"Children\"]={\
- [1]={\
- [\"Name\"]=\"UndoMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Undo\",\
- [\"Shortcut\"]=\"#Z\"\
- },\
- [2]={\
- [\"Name\"]=\"RedoMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Redo\",\
- [\"Shortcut\"]=\"#Y\"\
- },\
- [3]={\
- [\"Name\"]=\"Separator\",\
- [\"Type\"]=\"Separator\"\
- },\
- [4]={\
- [\"Name\"]=\"CutMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Cut \",\
- [\"Shortcut\"]=\"#X\"\
- },\
- [5]={\
- [\"Name\"]=\"CopyMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Copy\",\
- [\"Shortcut\"]=\"#C\"\
- },\
- [6]={\
- [\"Name\"]=\"PasteMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Paste\",\
- [\"Shortcut\"]=\"#V\"\
- }\
- },\
- }",["filemenu.view"]="{\
- [\"Type\"]=\"Menu\",\
- [\"Owner\"]=\"FileMenuButton\",\
- [\"HideTop\"]=true,\
- [\"Children\"]={\
- [1]={\
- [\"Name\"]=\"NewMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"New...\",\
- [\"Shortcut\"]=\"#N\"\
- },\
- [2]={\
- [\"Name\"]=\"OpenMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Open...\",\
- [\"Shortcut\"]=\"#O\"\
- },\
- [3]={\
- [\"Name\"]=\"Separator\",\
- [\"Type\"]=\"Separator\"\
- },\
- [4]={\
- [\"Name\"]=\"SaveMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Save\",\
- [\"Shortcut\"]=\"#S\"\
- },\
- [5]={\
- [\"Name\"]=\"SaveAsMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Save As...\",\
- [\"Shortcut\"]=\"^#S\"\
- },\
- [6]={\
- [\"Name\"]=\"Separator\",\
- [\"Type\"]=\"Separator\"\
- },\
- [7]={\
- [\"Name\"]=\"QuitMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Quit\",\
- [\"Shortcut\"]=\"#Q\"\
- },\
- },\
- }",["colourswindow.view"]="{\
- [\"Width\"]=13,\
- [\"Height\"]=4,\
- [\"BackgroundColour\"]=1,\
- [\"Children\"]={\
- [1]={\
- [\"Y\"]=1,\
- [\"X\"]=1,\
- [\"Name\"]=\"PrimaryColourButton\",\
- [\"Type\"]=\"View\",\
- [\"Width\"]=5,\
- [\"Height\"]=2,\
- [\"BackgroundColour\"]=8,\
- [\"ActiveBackgroundColour\"]=8\
- },\
- [2]={\
- [\"Y\"]=3,\
- [\"X\"]=1,\
- [\"Name\"]=\"SecondaryColourButton\",\
- [\"Type\"]=\"View\",\
- [\"Width\"]=5,\
- [\"Height\"]=2,\
- [\"BackgroundColour\"]=4,\
- [\"ActiveBackgroundColour\"]=4\
- },\
- \
- [3]={\
- [\"Y\"]=1,\
- [\"X\"]=6,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=4096,\
- [\"ActiveBackgroundColour\"]=4096\
- },\
- [4]={\
- [\"Y\"]=1,\
- [\"X\"]=8,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=16,\
- [\"ActiveBackgroundColour\"]=16\
- },\
- [5]={\
- [\"Y\"]=1,\
- [\"X\"]=10,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=2,\
- [\"ActiveBackgroundColour\"]=2\
- },\
- [6]={\
- [\"Y\"]=1,\
- [\"X\"]=12,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=16384,\
- [\"ActiveBackgroundColour\"]=16384\
- },\
- \
- [7]={\
- [\"Y\"]=2,\
- [\"X\"]=6,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=8192,\
- [\"ActiveBackgroundColour\"]=8192\
- },\
- [8]={\
- [\"Y\"]=2,\
- [\"X\"]=8,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=32,\
- [\"ActiveBackgroundColour\"]=32\
- },\
- [9]={\
- [\"Y\"]=2,\
- [\"X\"]=10,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=4,\
- [\"ActiveBackgroundColour\"]=4\
- },\
- [10]={\
- [\"Y\"]=2,\
- [\"X\"]=12,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=64,\
- [\"ActiveBackgroundColour\"]=64\
- },\
- \
- [11]={\
- [\"Y\"]=3,\
- [\"X\"]=6,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=1024,\
- [\"ActiveBackgroundColour\"]=1024\
- },\
- [12]={\
- [\"Y\"]=3,\
- [\"X\"]=8,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=2048,\
- [\"ActiveBackgroundColour\"]=2048\
- },\
- [13]={\
- [\"Y\"]=3,\
- [\"X\"]=10,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=512,\
- [\"ActiveBackgroundColour\"]=512\
- },\
- [14]={\
- [\"Y\"]=3,\
- [\"X\"]=12,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=8,\
- [\"ActiveBackgroundColour\"]=8\
- },\
- \
- [15]={\
- [\"Y\"]=4,\
- [\"X\"]=6,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=256,\
- [\"ActiveBackgroundColour\"]=256\
- },\
- [16]={\
- [\"Y\"]=4,\
- [\"X\"]=8,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=128,\
- [\"ActiveBackgroundColour\"]=128\
- },\
- [17]={\
- [\"Y\"]=4,\
- [\"X\"]=10,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=32768,\
- [\"ActiveBackgroundColour\"]=32768\
- },\
- [18]={\
- [\"Y\"]=4,\
- [\"X\"]=12,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ColourButton\",\
- [\"Width\"]=2,\
- [\"Height\"]=1,\
- [\"BackgroundColour\"]=1,\
- [\"ActiveBackgroundColour\"]=1\
- },\
- },\
- }",["viewmenu.view"]="{\
- [\"Type\"]=\"Menu\",\
- [\"Owner\"]=\"ViewMenuButton\",\
- [\"HideTop\"]=true,\
- [\"Children\"]={\
- [1]={\
- [\"Name\"]=\"ZoomInMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Zoom In\",\
- [\"Shortcut\"]=\"#=\"\
- },\
- [2]={\
- [\"Name\"]=\"ZoomOutMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Zoom Out\",\
- [\"Shortcut\"]=\"#-\"\
- },\
- [3]={\
- [\"Name\"]=\"100%ZoomMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"100% Zoom\",\
- [\"Shortcut\"]=\"#1\"\
- },\
- [4]={\
- [\"Name\"]=\"Separator\",\
- [\"Type\"]=\"Separator\"\
- },\
- [5]={\
- [\"Name\"]=\"FilterMaskMenuItem\",\
- [\"Type\"]=\"MenuItem\",\
- [\"Text\"]=\"Show Filter Masks\",\
- [\"Shortcut\"]=\"#M\"\
- },\
- },\
- }",["toolswindow.view"]="{\
- [\"Width\"]=17,\
- [\"Height\"]=9,\
- [\"BackgroundColour\"]=1,\
- [\"Children\"]={\
- [1]={\
- [\"Y\"]=2,\
- [\"X\"]=2,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ToolButton\",\
- [\"Text\"]=\"Hand\",\
- [\"ToolName\"]=\"HandTool\",\
- },\
- [2]={\
- [\"Y\"]=2,\
- [\"X\"]=9,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ToolButton\",\
- [\"Text\"]=\"Pencil\",\
- [\"ToolName\"]=\"PencilTool\",\
- },\
- [3]={\
- [\"Y\"]=4,\
- [\"X\"]=2,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ToolButton\",\
- [\"Text\"]=\"Fill\",\
- [\"ToolName\"]=\"FillTool\",\
- },\
- [4]={\
- [\"Y\"]=4,\
- [\"X\"]=9,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ToolButton\",\
- [\"Text\"]=\"Eraser\",\
- [\"ToolName\"]=\"EraserTool\",\
- },\
- [5]={\
- [\"Y\"]=6,\
- [\"X\"]=2,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ToolButton\",\
- [\"Text\"]=\"Text\",\
- [\"ToolName\"]=\"TextTool\",\
- },\
- [6]={\
- [\"Y\"]=6,\
- [\"X\"]=9,\
- [\"Width\"]=8,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ToolButton\",\
- [\"Text\"]=\"Spray\",\
- [\"ToolName\"]=\"SprayTool\",\
- },\
- [7]={\
- [\"Y\"]=8,\
- [\"X\"]=2,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ToolButton\",\
- [\"Text\"]=\"Move\",\
- [\"ToolName\"]=\"MoveTool\",\
- },\
- [8]={\
- [\"Y\"]=8,\
- [\"X\"]=9,\
- [\"Type\"]=\"Button\",\
- [\"Name\"]=\"ToolButton\",\
- [\"Text\"]=\"Select\",\
- [\"ToolName\"]=\"SelectTool\",\
- },\
- },\
- }",},["Objects"]={["ToolsWindow.lua"]="Inherit = 'SnapWindow'\
- ContentViewName = 'toolswindow'\
- \
- Title = 'Tools'\
- \
- OnContentLoad = function(self)\
- local buttons = self:GetObjects('ToolButton')\
- for i, button in ipairs(buttons) do\
- button.OnClick = function(_self, event, side, x , y)\
- local artboard = self.Bedrock:GetObject('Artboard')\
- if artboard then\
- artboard:SetTool(getfenv()[button.ToolName])\
- end\
- end\
- end\
- end",["FilterPreview.lua"]="Inherit = 'View'\
- \
- BackgroundColour = colours.transparent\
- TextColour = colours.black\
- Height = 3\
- Image = nil\
- Enabled = true\
- \
- OnLoad = function(self)\
- self.Image = Drawing.LoadImage('Resources/filterPreview.nft')\
- \
- self:AddObject({\
- X = 6,\
- Y = 1,\
- Text = self.FilterName,\
- Type = 'Label',\
- BackgroundColour = colours.transparent,\
- TextColour = self.TextColour\
- })\
- end\
- \
- OnDraw = function(self, x, y)\
- if self.BackgroundColour then\
- Drawing.DrawBlankArea(x, y, self.Width, self.Height, self.BackgroundColour)\
- end\
- \
- local filter = Drawing.Filters[self.Filter]\
- if not filter then\
- filter = Drawing.Filters.None\
- end\
- \
- for _y = 1, #self.Image do\
- for _x = 1, #self.Image[_y] do\
- local bgColour = Drawing.FilterColour(self.Image[_y][_x], filter)\
- local textColour = Drawing.FilterColour(self.Image.textcol[_y][_x] or colours.white, filter)\
- local char = self.Image.text[_y][_x]\
- Drawing.WriteToBuffer(x+_x, y+_y-1, char, textColour, bgColour)\
- end\
- end\
- end\
- \
- OnClick = function(self, event, side, x, y)\
- if self.Enabled then\
- local artboard = self.Bedrock:GetObject('Artboard')\
- if artboard then\
- artboard:CreateLayer(self.FilterName .. ' Filter', colours.white, 'Filter:' .. self.Filter)\
- end\
- end\
- end",["LayerView.lua"]="Inherit = 'View'\
- \
- BackgroundColour = colours.transparent\
- ActiveBackgroundColour = colours.blue\
- ActiveTextColour = colours.white\
- Height = 3\
- DragStart = nil\
- DragTimer = nil\
- \
- \
- OnLoad = function(self)\
- self:AddObject({\
- X = 2,\
- Y = 1,\
- Width = 1,\
- AutoWidth = false,\
- Text = (self.Layer.Visible and '@' or '*'),\
- Type = 'Button',\
- Name = 'VisibleButton',\
- BackgroundColour = colours.transparent,\
- ActiveBackgroundColour = colours.transparent,\
- TextColour = colours.grey,\
- ActiveTextColour = colours.black,\
- Toggle = self.Layer.Visible,\
- OnClick = function(_self)\
- if _self.Toggle then\
- _self.Text = '@'\
- else\
- _self.Text = '*'\
- end\
- self.Layer.Layer.Visible = _self.Toggle\
- self.Layer.Visible = _self.Toggle\
- end\
- })\
- \
- self:AddObject({\
- X = 2,\
- Y = 2,\
- Width = 1,\
- AutoWidth = false,\
- Text = 'X',\
- Type = 'Button',\
- Name = 'DeleteButton',\
- BackgroundColour = colours.transparent,\
- ActiveBackgroundColour = colours.transparent,\
- TextColour = colours.red,\
- OnClick = function(_self)\
- self.Layer:DeleteLayer()\
- end\
- })\
- \
- self:AddObject({\
- X = 9,\
- Y = 1,\
- Text = self.Layer.Layer.Name,\
- Type = 'Label',\
- Name = 'LayerNameLabel',\
- BackgroundColour = colours.transparent,\
- TextColour = colours.black\
- })\
- end\
- \
- OnDraw = function(self, x, y)\
- local artboard = self.Bedrock:GetObject('Artboard')\
- \
- local isActive = (artboard and artboard:GetCurrentLayer() == self.Layer)\
- \
- if isActive then\
- Drawing.DrawBlankArea(x, y, self.Width, self.Height, self.ActiveBackgroundColour)\
- self:GetObject('VisibleButton').TextColour = colours.lightGrey\
- self:GetObject('VisibleButton').ActiveTextColour = colours.white\
- self:GetObject('DeleteButton').TextColour = colours.white\
- self:GetObject('LayerNameLabel').TextColour = colours.white\
- else\
- Drawing.DrawBlankArea(x, y, self.Width, self.Height, self.BackgroundColour)\
- self:GetObject('VisibleButton').TextColour = colours.grey\
- self:GetObject('VisibleButton').ActiveTextColour = colours.black\
- self:GetObject('DeleteButton').TextColour = colours.red\
- self:GetObject('LayerNameLabel').TextColour = colours.black\
- end\
- \
- local previewX = 3\
- local previewY = 0\
- for _x = 1, 3 do\
- local odd = (_x % 2) == 1\
- for _y = 1, 2 do\
- if odd then\
- Drawing.WriteToBuffer(previewX + x + _x - 1, previewY + y + _y - 1, \":\", colours.lightGrey, colours.white)\
- else\
- Drawing.WriteToBuffer(previewX + x + _x - 1, previewY + y + _y - 1, \":\", colours.white, colours.lightGrey)\
- end\
- odd = not odd\
- end\
- end\
- \
- for _x, col in ipairs(self.Layer:GetZoomPixels(3, 2)) do\
- for _y, pixel in ipairs(col) do\
- if pixel.Character ~= ' ' or pixel.BackgroundColour ~= colours.transparent then\
- Drawing.WriteToBuffer(previewX + x + _x - 1, previewY + y + _y - 1, pixel.Character, pixel.TextColour, pixel.BackgroundColour)\
- end\
- end\
- end\
- \
- local splitterColour = colours.lightGrey\
- \
- \
- Drawing.DrawArea(x, y + self.Height - 1, self.Width, 1, '-', (isActive and colours.white or colours.lightGrey), colours.transparent)\
- \
- end\
- \
- OnClick = function(self, event, side, x, y)\
- if side == 1 then\
- self.DragStart = y\
- \
- local artboard = self.Bedrock:GetObject('Artboard')\
- if artboard then\
- artboard:SetCurrentLayer(self.Layer)\
- end\
- elseif side == 2 then\
- if self:ToggleMenu('layermenu', x, y) then\
- local artboard = self.Bedrock:GetObject('Artboard')\
- if artboard then\
- self.Bedrock:GetObject('NewLayerMenuItem').OnClick = function()\
- artboard:NewLayer()\
- end\
- self.Bedrock:GetObject('RenameLayerMenuItem').OnClick = function()\
- self.Layer:RenameLayer()\
- end\
- self.Bedrock:GetObject('DeleteLayerMenuItem').OnClick = function()\
- self.Layer:DeleteLayer()\
- end\
- self.Bedrock:GetObject('DuplicateLayerMenuItem').OnClick = function()\
- artboard:DuplicateLayer(self.Layer.Layer)\
- end\
- self.Bedrock:GetObject('MergeDownLayerMenuItem').OnClick = function()\
- self.Layer:MergeDown()\
- end\
- end\
- end\
- end\
- end\
- \
- \
- OnDrag = function(self, event, side, x, y)\
- if self.DragStart then\
- local deltaY = y - self.DragStart\
- self.Y = self.Y + deltaY\
- self.Parent.Parent.Parent:Rearrange(self, y)\
- end\
- \
- self.DragTimer = self.Bedrock:StartTimer(function(_, timer)\
- if timer == self.DragTimer then\
- self.Parent.Parent.Parent:OrderLayers()\
- self.Parent.Parent.Parent:UpdateLayers()\
- self.DragStart = nil\
- self.DragTimer = nil\
- end\
- end, 1)\
- end",["NumberBox.lua"]="Inherit = 'View'\
- \
- Value = 1\
- Minimum = 1\
- Maximum = 99\
- BackgroundColour = colours.lightGrey\
- TextBoxTimer = nil\
- Width = 7\
- \
- OnLoad = function(self)\
- self:AddObject({\
- X = self.Width - 1,\
- Y = 1,\
- Width = 1,\
- AutoWidth = false,\
- Text = '-',\
- Type = 'Button',\
- Name = 'AddButton',\
- BackgroundColour = colours.transparent,\
- OnClick = function()\
- self:ShiftValue(-1)\
- end\
- })\
- \
- self:AddObject({\
- X = self.Width,\
- Y = 1,\
- Width = 1,\
- AutoWidth = false,\
- Text = '+',\
- Type = 'Button',\
- Name = 'SubButton',\
- BackgroundColour = colours.transparent,\
- OnClick = function()\
- self:ShiftValue(1)\
- end\
- })\
- \
- self:AddObject({\
- X = 1,\
- Y = 1,\
- Width = self.Width - 2,\
- Text = tostring(self.Value),\
- Align = 'Center',\
- Type = 'TextBox',\
- BackgroundColour = colours.transparent,\
- OnChange = function(_self, event, keychar)\
- if keychar == keys.enter then\
- self:SetValue(tonumber(_self.Text))\
- self.TextBoxTimer = nil\
- end\
- if self.TextBoxTimer then\
- self.Bedrock:StopTimer(self.TextBoxTimer)\
- end\
- \
- self.TextBoxTimer = self.Bedrock:StartTimer(function(_, timer)\
- if timer and timer == self.TextBoxTimer then\
- self:SetValue(tonumber(_self.Text))\
- self.TextBoxTimer = nil\
- end\
- end, 2)\
- end\
- })\
- end\
- \
- OnScroll = function(self, event, dir, x, y)\
- self:ShiftValue(-dir)\
- end\
- \
- ShiftValue = function(self, delta)\
- local val = tonumber(self:GetObject('TextBox').Text) or self.Minimum\
- self:SetValue(val + delta)\
- end\
- \
- SetValue = function(self, newValue)\
- newValue = newValue or 0\
- if self.Maximum and newValue > self.Maximum then\
- newValue = self.Maximum\
- elseif self.Minimum and newValue < self.Minimum then\
- newValue = self.Minimum\
- end\
- self.Value = newValue\
- if self.OnChange then\
- self:OnChange()\
- end\
- end\
- \
- OnUpdate = function(self, value)\
- if value == 'Value' then\
- local textbox = self:GetObject('TextBox')\
- if textbox then\
- textbox.Text = tostring(self.Value)\
- end\
- end\
- end",["LayersWindow.lua"]="Inherit = 'SnapWindow'\
- ContentViewName = 'layerswindow'\
- \
- Title = 'Layers'\
- \
- OnContentLoad = function(self)\
- self:UpdateLayers()\
- end\
- \
- UpdateLayers = function(self)\
- self:GetObject('ScrollView'):RemoveAllObjects()\
- local artboard = self.Bedrock:GetObject('Artboard')\
- if artboard then\
- for i, layer in ipairs(artboard.Children) do\
- self:GetObject('ScrollView'):AddObject({\
- Type = 'LayerView',\
- X = 1,\
- Y = 1 + (#artboard.Children - i) * LayerView.Height,\
- Width = '100%',\
- Layer = layer,\
- LayerIndex = i\
- })\
- end\
- local maxHeight = Drawing.Screen.Height - 4\
- local height = #artboard.Children * LayerView.Height\
- if height > maxHeight then\
- height = maxHeight\
- end\
- \
- self:GetObject('ContentView').Height = height\
- self:GetObject('ScrollView').Height = height\
- self:GetObject('ScrollView'):UpdateScroll()\
- self.Height = 1 + height\
- end\
- end\
- \
- OrderLayers = function(self)\
- local artboard = self.Bedrock:GetObject('Artboard')\
- if artboard then\
- local layers = {}\
- for i, v in ipairs(self:GetObject('ScrollView').Children) do\
- if v.Type == 'LayerView' then\
- table.insert(layers, v.Layer.Layer)\
- end\
- end\
- artboard.Layers = layers\
- artboard:PushState()\
- end\
- end\
- \
- Rearrange = function(self, dragging, y)\
- local artboard = self.Bedrock:GetObject('Artboard')\
- if artboard then\
- local children = self:GetObject('ScrollView').Children\
- \
- local scrollBar = self:GetObject('ScrollViewScrollBar')\
- \
- local newIndex = #children - (scrollBar and 1 or 0) - math.floor((dragging.Y + y - 2 ) / 4)\
- if newIndex > #children then\
- newIndex = #children\
- elseif newIndex < 1 then\
- newIndex = 1\
- end\
- local oldIndex = dragging.LayerIndex\
- \
- if newIndex ~= oldIndex then\
- local newChildren = {}\
- newChildren[newIndex] = dragging\
- dragging.LayerIndex = newIndex\
- \
- for i, layer in ipairs(children) do\
- if layer ~= dragging then\
- table.insert(newChildren, layer)\
- local index = #newChildren\
- if index == newIndex then\
- index = index - 1\
- end\
- layer.LayerIndex = index\
- layer.Y = 1 + (#children - layer.LayerIndex) * 4\
- end\
- end\
- self:GetObject('ScrollView').Children = newChildren\
- end\
- end\
- end",["Layer.lua"]="BackgroundColour = colours.transparent\
- DrawnPixels = nil\
- UpdateDrawBlacklist = {['DrawnPixels']=true}\
- Ready = false\
- CursorPos = nil\
- \
- OnLoad = function(self)\
- -- self.LayerName = self.Layer.Nae\
- -- self.Pixels = ParseNFT(self.Layer.Pixels)\
- self.BackgroundColour = self.Layer.BackgroundColour\
- self.Visible = self.Layer.Visible\
- self.Ready = true\
- end\
- \
- OnDraw = function(self, x, y)\
- if self.Layer.LayerType == 'Normal' or self.Parent.ShowFilterMask then\
- local drawnPixels = {}\
- for _x, col in ipairs(self:GetZoomPixels(self.Width, self.Height, true)) do\
- drawnPixels[_x] = {}\
- for _y, pixel in ipairs(col) do\
- if pixel.Character ~= ' ' or pixel.BackgroundColour ~= colours.transparent then\
- drawnPixels[_x][_y] = pixel\
- Drawing.WriteToBuffer(x + _x - 1, y + _y - 1, pixel.Character, pixel.TextColour, pixel.BackgroundColour)\
- end\
- end\
- end\
- self.DrawnPixels = drawnPixels\
- \
- if self.Bedrock:GetActiveObject() == self then\
- self.Bedrock.CursorPos = {x + self.CursorPos[1] - 1, y + self.CursorPos[2] - 1}\
- self.Bedrock.CursorColour = self.Parent.BrushColour\
- else\
- self.CursorPos = nil\
- end\
- elseif self.Layer.LayerType:sub(1, 7) == 'Filter:' then\
- local drawnPixels = {}\
- for _x, col in ipairs(self:GetZoomPixels(self.Width, self.Height)) do\
- drawnPixels[_x] = {}\
- for _y, pixel in ipairs(col) do\
- if pixel.BackgroundColour == colours.white then\
- local bgColour, txtColour, char = self.Parent:GetPixelBelowLayer(_x, _y, self.LayerIndex)\
- local filter = Drawing.Filters[self.Layer.LayerType:sub(8)]\
- if not filter then\
- filter = Drawing.Filters.None\
- end\
- \
- bgColour = Drawing.FilterColour(bgColour, filter)\
- txtColour = Drawing.FilterColour(txtColour, filter)\
- \
- if txtColour == colors.transparent then\
- txtColour = colours.black\
- char = ' '\
- end\
- drawnPixels[_x][_y] = {Character = char, TextColour = txtColour, BackgroundColour = bgColour}\
- Drawing.WriteToBuffer(x + _x - 1, y + _y - 1, char, txtColour, bgColour)\
- end\
- end\
- end\
- self.DrawnPixels = drawnPixels\
- end\
- end\
- \
- GetZoomPixels = function(self, width, height, preserveDetail)\
- local pixels = {}\
- local deltaX = #self.Layer.Pixels / width\
- local deltaY = #self.Layer.Pixels[1] / height\
- \
- if deltaX == 1 and deltaY == 1 then\
- return self.Layer.Pixels\
- end\
- \
- for _x = 1, width do\
- local x = self.Bedrock.Helpers.Round(1*deltaX + (_x - 1) * deltaX)\
- if not self.Layer.Pixels[x] then\
- if x < 1 then\
- x = 1\
- else\
- x = #self.Layer.Pixels\
- end\
- end\
- pixels[_x] = {}\
- for _y = 1, height do\
- local y = self.Bedrock.Helpers.Round(1*deltaY + (_y - 1) * deltaY)\
- if not self.Layer.Pixels[x][y] then\
- if y < 1 then\
- y = 1\
- else\
- y = #self.Layer.Pixels[x]\
- end\
- end\
- pixels[_x][_y] = self.Layer.Pixels[x][y]\
- if not preserveDetail and pixels[_x][_y].Character ~= ' ' then\
- pixels[_x][_y].Character = '-'\
- end\
- end\
- end\
- return pixels\
- end\
- \
- GetEffectedPixels = function(self, x, y, brushSize, brushShape, correctPixelRatio)\
- if brushSize == 1 then\
- return {\
- {x, y}\
- }\
- elseif brushShape == 'Square' then\
- local pixels = {}\
- local cornerX = math.ceil(x - brushSize/2)\
- local cornerY = math.ceil(y - brushSize/2)\
- for _x = 1, brushSize do\
- for _y = 1, brushSize do\
- if self.Layer.Pixels[cornerX + _x] and self.Layer.Pixels[cornerX + _x][cornerY + _y] then\
- table.insert(pixels, {cornerX + _x, cornerY + _y})\
- end\
- end\
- end\
- return pixels\
- elseif brushShape == 'Circle' then\
- \
- -- this circle algorithm looks terrible on odd values (try 5 and 3)\
- \
- local pixels = {{x, y}}\
- local rSquared = math.pow(brushSize/2, 2)\
- \
- local round = self.Bedrock.Helpers.Round\
- -- thanks to theoriginalbit for this (slightly modified) snippet\
- -- local radius = brushSize / 2\
- -- local radStep = 1/(1.5*radius)\
- -- for angle = 1 + radStep, math.pi+radStep, radStep do\
- -- local pX = math.cos( angle ) * radius * (correctPixelRatio and 1.5 or 1)\
- -- local pY = math.sin( angle ) * radius\
- \
- -- local centreOffset = 1 - (brushSize % 2)\
- \
- -- table.insert(pixels, {round(x + pX) + centreOffset, round(y + pY)})\
- -- table.insert(pixels, {round(x - pX), round(y + pY)})\
- \
- -- table.insert(pixels, {round(x + pX) + centreOffset, round(y - pY) + centreOffset})\
- -- table.insert(pixels, {round(x - pX), round(y - pY) + centreOffset})\
- -- end\
- \
- \
- -- local Ys = {}\
- -- for _y = 1, math.floor(brushSize/2) do\
- -- Ys[_y] = math.sqrt(rSquared - math.pow(_y-1, 2))\
- -- end\
- -- local round = self.Bedrock.Helpers.Round\
- \
- -- print(' ')\
- for _y = -brushSize/2, brushSize/2 do\
- _y = round(_y)\
- local _x = round(math.sqrt(math.abs(rSquared - math.pow(_y, 2))) * (correctPixelRatio and 1.5 or 1))\
- -- print(_x..', '.._y)\
- -- local xLeft = math.floor(x + (_x - 1))-- - 1 + (brushSize % 2))\
- -- local xLeft = round(x + -1 * (_x - 1))\
- -- local yTop = round(y + -1 * (_y - 1) )\
- -- local yBottom = round(y + (_y - 1) - 1 + (brushSize % 2))\
- local xLeft = x - _x\
- local xRight = x + _x\
- \
- for xPixel = xLeft, xRight do\
- table.insert(pixels, {xPixel, y + _y})\
- end\
- -- table.insert(pixels, {x - _x, y + _y})\
- \
- \
- -- for xPixel = xLeft, xRight do\
- -- table.insert(pixels, {xPixel, yBottom})\
- -- table.insert(pixels, {xPixel, yTop})\
- -- end\
- \
- -- table.insert(pixels, {xRight, })\
- -- table.insert(pixels, {xLeft, round(y + (_y - 1) + 1)})\
- \
- -- table.insert(pixels, {round(x + (_x - 1) + 1), round(y + -1*(_y - 1))})\
- -- table.insert(pixels, {round(x + -1*(_x - 1)), round(y + -1*(_y - 1))})\
- end\
- -- print('.')\
- \
- \
- -- for _y, _x in ipairs(Ys) do\
- -- local xRight = math.floor(x + (_x - 1))-- - 1 + (brushSize % 2))\
- -- local xLeft = round(x + -1 * (_x - 1))\
- -- local yTop = round(y + -1 * (_y - 1) )\
- -- local yBottom = round(y + (_y - 1) - 1 + (brushSize % 2))\
- \
- -- table.insert(pixels, {xLeft, yTop})\
- \
- \
- -- -- for xPixel = xLeft, xRight do\
- -- -- table.insert(pixels, {xPixel, yBottom})\
- -- -- table.insert(pixels, {xPixel, yTop})\
- -- -- end\
- \
- -- -- table.insert(pixels, {xRight, })\
- -- -- table.insert(pixels, {xLeft, round(y + (_y - 1) + 1)})\
- \
- -- -- table.insert(pixels, {round(x + (_x - 1) + 1), round(y + -1*(_y - 1))})\
- -- -- table.insert(pixels, {round(x + -1*(_x - 1)), round(y + -1*(_y - 1))})\
- -- end\
- \
- \
- -- for a = -1, 1 do\
- -- if a ~= 0 then\
- -- for b = -1, 1 do\
- -- if b ~= 0 then\
- -- for _y, _x in ipairs(Ys) do\
- -- table.insert(pixels, {round(x + a * (_x - 1)), round(y + b * (_y - 1))})\
- -- end\
- -- end\
- -- end \
- -- end\
- -- end\
- \
- -- -- thanks to theoriginalbit for this (slightly modified) snippet\
- -- local radius = brushSize / 2\
- -- local radStep = 1/(1.5*radius)\
- -- for angle = 1, math.pi+radStep, radStep do\
- -- local pX = math.cos( angle ) * radius-- * 1.5\
- -- local pY = math.sin( angle ) * radius\
- \
- -- print(pX .. '@'..pY)\
- -- sleep(0.5)\
- \
- -- for i=-1,1,2 do\
- -- for j=-1,1,2 do\
- -- -- for _x = 0, pX do\
- -- local _x = pX\
- -- table.insert(pixels, {round(x + i*_x), round(y + j*pY)})\
- -- -- end\
- -- end\
- -- end\
- -- end\
- \
- \
- return pixels\
- end\
- end\
- \
- SetPixel = function(self, x, y, backgroundColour, textColour, character)\
- if self.Layer.Pixels and self.Layer.Pixels[x] and self.Layer.Pixels[x][y] then\
- if backgroundColour then\
- self.Layer.Pixels[x][y].BackgroundColour = backgroundColour\
- end\
- if textColour then\
- self.Layer.Pixels[x][y].TextColour = textColour\
- end\
- if character then\
- self.Layer.Pixels[x][y].Character = character\
- end\
- self:ForceDraw()\
- self.Parent:DelayedPushState()\
- end\
- end\
- \
- DeleteLayer = function(self, force)\
- if #self.Parent.Layers > 1 then\
- local function delete()\
- for i, v in ipairs(self.Parent.Layers) do\
- if v == self.Layer then\
- table.remove(self.Parent.Layers, i)\
- self.Parent:SetCurrentLayer(nil)\
- self.Parent:OnDeleteLayer(v)\
- self.Parent:UpdateLayers()\
- local window = self.Bedrock:GetObject('LayersWindow')\
- if window then\
- window:UpdateLayers()\
- end\
- end\
- end\
- end\
- if force then\
- delete()\
- else\
- self.Bedrock:DisplayAlertWindow('Delete Layer?', \"Are you sure you want to delete the layer '\"..self.Layer.Name..\"'\", {'Delete', 'Cancel'}, function(button)\
- if button == 'Delete' then\
- delete()\
- end\
- end)\
- end\
- else\
- 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)\
- end\
- end\
- \
- GetSelectionBoundaries = function(self)\
- if self.Parent.Selection and self.Parent.Selection[1] and self.Parent.Selection[2] then\
- local selection = self.Parent.Selection\
- local left\
- local right\
- local top\
- local bottom\
- if selection[1].X > selection[2].X then\
- right = selection[1].X\
- left = selection[2].X\
- else\
- left = selection[1].X\
- right = selection[2].X\
- end\
- \
- if selection[1].Y > selection[2].Y then\
- bottom = selection[1].Y\
- top = selection[2].Y\
- else\
- top = selection[1].Y\
- bottom = selection[2].Y\
- end\
- return left, right, top, bottom\
- end\
- end\
- \
- GetSelectedPixels = function(self, cut)\
- local pixels = {}\
- local bg = self.Parent:GetBackgroundColour()\
- if self.Parent.Selection and self.Parent.Selection[1] and self.Parent.Selection[2] then\
- local left, right, top, bottom = self:GetSelectionBoundaries()\
- local x = 1\
- local y = 1\
- for x = left, right do\
- pixels[x] = {}\
- for y = top, bottom do\
- if self.Layer.Pixels[x] and self.Layer.Pixels[x][y] then\
- pixels[x][y] = self.Layer.Pixels[x][y]\
- if cut then\
- self.Layer.Pixels[x][y] = {\
- BackgroundColour = bg,\
- TextColour = colours.black,\
- Character = ' '\
- }\
- end\
- end\
- y = y + 1\
- end\
- x = x + 1\
- end\
- end\
- self.Parent:PushState()\
- return pixels\
- end\
- \
- Move = function(self, deltaX, deltaY)\
- local pixels = {}\
- local bg = self.Parent:GetBackgroundColour()\
- if self.Parent.Selection and self.Parent.Selection[1] and self.Parent.Selection[2] then\
- for x = 1, self.Width do\
- pixels[x] = {}\
- for y = 1, self.Height do\
- pixels[x][y] = self.Layer.Pixels[x][y]\
- end\
- end\
- \
- local left, right, top, bottom = self:GetSelectionBoundaries()\
- \
- for x = left, right do\
- for y = top, bottom do\
- if self.Layer.Pixels[x] and self.Layer.Pixels[x][y] and pixels[x] and pixels[x][y] then\
- pixels[x][y] = {\
- BackgroundColour = bg,\
- TextColour = colours.black,\
- Character = ' '\
- }\
- end\
- end\
- end\
- \
- for x = left, right do\
- for y = top, bottom do\
- if self.Layer.Pixels[x] and self.Layer.Pixels[x][y] and pixels[x + deltaX] and pixels[x + deltaX][y + deltaY] then\
- pixels[x + deltaX][y + deltaY] = self.Layer.Pixels[x][y]\
- end\
- end\
- end\
- \
- selection[1].X = selection[1].X + deltaX\
- selection[1].Y = selection[1].Y + deltaY\
- selection[2].X = selection[2].X + deltaX\
- selection[2].Y = selection[2].Y + deltaY\
- else\
- for x = 1, self.Width do\
- pixels[x] = {}\
- for y = 1, self.Height do\
- if self.Layer.Pixels[x - deltaX] and self.Layer.Pixels[x - deltaX][y - deltaY] then\
- pixels[x][y] = self.Layer.Pixels[x - deltaX][y - deltaY]\
- else\
- pixels[x][y] = {\
- BackgroundColour = bg,\
- TextColour = colours.black,\
- Character = ' '\
- }\
- end\
- end\
- end\
- end\
- self.Layer.Pixels = pixels\
- end\
- \
- MergeWith = function(self, other)\
- for x, col in pairs(other.DrawnPixels) do\
- for y, pixel in pairs(col) do\
- if pixel then\
- if pixel.BackgroundColour ~= colours.transparent then\
- self.Layer.Pixels[x][y].BackgroundColour = pixel.BackgroundColour\
- end\
- \
- if pixel.Character ~= ' ' then\
- self.Layer.Pixels[x][y].Character = pixel.Character\
- self.Layer.Pixels[x][y].TextColour = pixel.TextColour\
- end\
- end\
- end\
- end\
- other:DeleteLayer(true)\
- self.Parent:PushState()\
- end\
- \
- MergeDown = function(self)\
- if self.LayerIndex - 1 >= 1 then\
- local below = self.Parent.Children[self.LayerIndex - 1]\
- if self.Layer.LayerType == below.Layer.LayerType then\
- below:MergeWith(self)\
- else\
- self.Bedrock:DisplayAlertWindow('Cannot merge layer!', \"You can't merge layers of different types.\", {'Ok'}, function()end)\
- end\
- else\
- self.Bedrock:DisplayAlertWindow('Cannot merge layer!', \"There isn't a layer below this layer!\", {'Ok'}, function()end)\
- end\
- end\
- \
- RenameLayer = function(self)\
- self.Bedrock:DisplayTextBoxWindow('Rename Layer', \"Enter the new name for the layer '\"..self.Layer.Name..\"'\", function(success, newName)\
- if success then\
- self.Layer.Name = newName\
- self.Parent:UpdateLayers()\
- end\
- end, self.Layer.Name, #self.Layer.Name)\
- end\
- \
- OnUpdate = function(self, value)\
- if value == 'Visible' and self.Ready then\
- self.Layer.Visible = self.Visible\
- end\
- end\
- \
- OnKeyChar = function(self, event, keychar)\
- local function updateCharPos()\
- if self.CursorPos[1] > #self.Layer.Pixels then\
- self.CursorPos[1] = 1\
- self.CursorPos[2] = self.CursorPos[2] + 1\
- elseif self.CursorPos[1] < 1 then\
- self.CursorPos[1] = #self.Layer.Pixels \
- self.CursorPos[2] = self.CursorPos[2] - 1\
- end\
- \
- if self.CursorPos[2] > #self.Layer.Pixels[1] then\
- self.CursorPos = {1, 1}\
- elseif self.CursorPos[2] < 1 then\
- self.CursorPos = {#self.Layer.Pixels, #self.Layer.Pixels[1]}\
- end\
- end\
- if event == 'char' then\
- if keychar == 'nil' then\
- return\
- end\
- self.Layer.Pixels[self.CursorPos[1]][self.CursorPos[2]].Character = keychar\
- self.Layer.Pixels[self.CursorPos[1]][self.CursorPos[2]].TextColour = self.Parent.BrushColour\
- \
- self.CursorPos[1] = self.CursorPos[1] + 1\
- updateCharPos()\
- self:ForceDraw()\
- return false\
- elseif event == 'key' then\
- if keychar == keys.enter then\
- self.CursorPos[2] = self.CursorPos[2] + 1\
- elseif keychar == keys.left then\
- self.CursorPos[1] = self.CursorPos[1] - 1\
- elseif keychar == keys.right then\
- self.CursorPos[1] = self.CursorPos[1] + 1\
- elseif keychar == keys.up then\
- self.CursorPos[2] = self.CursorPos[2] - 1\
- elseif keychar == keys.down then\
- self.CursorPos[2] = self.CursorPos[2] + 1\
- elseif keychar == keys.backspace then\
- self.CursorPos[1] = self.CursorPos[1] - 1\
- updateCharPos()\
- self.Layer.Pixels[self.CursorPos[1]][self.CursorPos[2]].Character = ' '\
- self.Layer.Pixels[self.CursorPos[1]][self.CursorPos[2]].TextColour = colours.black\
- elseif keychar == keys.home then\
- self.CursorPos[1] = 1\
- elseif keychar == keys.delete then\
- self.Layer.Pixels[self.CursorPos[1]][self.CursorPos[2]].Character = ' '\
- self.Layer.Pixels[self.CursorPos[1]][self.CursorPos[2]].TextColour = colours.black\
- self.CursorPos[1] = self.CursorPos[1] + 1\
- elseif keychar == keys[\"end\"] then\
- self.CursorPos[1] = #self.Layer.Pixels\
- else\
- return false\
- end\
- updateCharPos()\
- self:ForceDraw()\
- end\
- end",["SidebarButton.lua"]="Inherit = 'Button'\
- \
- X = 1\
- Width = 3\
- Height = 1\
- AutoWidth = false\
- \
- TextColour = colours.white\
- ActiveTextColour = colours.lightGrey\
- \
- WindowDocked = false\
- Window = false\
- \
- OnDraw = function(self, x, y)\
- local text = self.Text\
- if self.WindowDocked then\
- text = ' > '\
- end\
- \
- local textColour = self.TextColour\
- if self.Toggle then\
- textColour = self.ActiveTextColour\
- end\
- if not self.Enabled then\
- textColour = self.DisabledTextColour\
- end\
- \
- Drawing.DrawCharacters(x, y, text, textColour, colours.transparent)\
- end\
- \
- \
- OnClick = function(self, event, side, x, y)\
- if event == 'mouse_click' then\
- if self.WindowName and not self.Window then\
- self.Window = self.Bedrock:AddObject({\
- [\"Y\"]=(self.Bedrock:GetAbsolutePosition(self)).Y,\
- [\"Type\"]=self.WindowName,\
- [\"Docked\"]=true,\
- OnDockChange = function(_self, state)\
- self.WindowDocked = state\
- if state then\
- _self.Y = (self.Bedrock:GetAbsolutePosition(self)).Y\
- _self.X = Drawing.Screen.Width - _self.Width - 2\
- self.Parent:OnDock()\
- end\
- end,\
- OnClose = function(_self)\
- self.Window = nil\
- self.WindowDocked = false\
- end\
- })\
- self.Window.X = Drawing.Screen.Width - self.Window.Width - 2\
- self.Parent:CloseDocked()\
- self.WindowDocked = true\
- else\
- self.Window:Close()\
- end\
- end\
- end",["FiltersWindow.lua"]="Inherit = 'SnapWindow'\
- ContentViewName = 'filterswindow'\
- \
- Title = 'Filters'\
- \
- OnContentLoad = function(self)\
- self:GetObject('ScrollView'):UpdateScroll()\
- end",["InfoWindow.lua"]="Inherit = 'SnapWindow'\
- ContentViewName = 'infowindow'\
- \
- Title = 'Info'\
- \
- OnContentLoad = function(self)\
- self:UpdateInfo()\
- end\
- \
- UpdateInfo = function(self)\
- local artboard = self.Bedrock:GetObject('Artboard')\
- local selection = (artboard == nil or artboard.Selection == nil or artboard.Selection[1] == nil or artboard.Selection[2] == nil)\
- self:GetObject(\"CanvasWidthLabel\").Text = (artboard == nil and '-' or tostring(#artboard:GetCurrentLayer().Layer.Pixels))\
- self:GetObject(\"CanvasHeightLabel\").Text = (artboard == nil and '-' or tostring(#artboard:GetCurrentLayer().Layer.Pixels[1]))\
- self:GetObject(\"SelectionWidthLabel\").Text = (selection and '-' or tostring(math.abs(artboard.Selection[1].X-artboard.Selection[2].X)))\
- self:GetObject(\"SelectionHeightLabel\").Text = (selection and '-' or tostring(math.abs(artboard.Selection[1].Y-artboard.Selection[2].Y)))\
- self:GetObject(\"SelectionX1Label\").Text = (selection and '-' or tostring(artboard.Selection[1].X))\
- self:GetObject(\"SelectionY1Label\").Text = (selection and '-' or tostring(artboard.Selection[1].Y))\
- self:GetObject(\"SelectionX2Label\").Text = (selection and '-' or tostring(artboard.Selection[2].X))\
- self:GetObject(\"SelectionY2Label\").Text = (selection and '-' or tostring(artboard.Selection[2].Y))\
- end",["ColourView.lua"]="OnDraw = function(self, x, y)\
- if self.BackgroundColour ~= colours.transparent then\
- Drawing.DrawBlankArea(x, y, self.Width, self.Height, self.BackgroundColour)\
- else\
- for _x = 1, self.Width do\
- local odd = (_x % 2) == 0\
- for _y = 1, self.Height do\
- if odd then\
- Drawing.WriteToBuffer(x + _x - 1, y + _y - 1, \":\", colours.lightGrey, colours.white)\
- else\
- Drawing.WriteToBuffer(x + _x - 1, y + _y - 1, \":\", colours.white, colours.lightGrey)\
- end\
- odd = not odd\
- end\
- end\
- end\
- end",["BrushWindow.lua"]="Inherit = 'SnapWindow'\
- ContentViewName = 'brushwindow'\
- \
- Title = 'Brush'\
- \
- OnContentLoad = function(self)\
- self:GetObject('SquareImageView').OnClick = function(_self, event, side, x, y)\
- local artboard = self.Bedrock:GetObject('Artboard')\
- if artboard then\
- artboard.BrushShape = 'Square'\
- end\
- end\
- \
- self:GetObject('CircleImageView').OnClick = function(_self, event, side, x, y)\
- local artboard = self.Bedrock:GetObject('Artboard')\
- if artboard then\
- artboard.BrushShape = 'Circle'\
- end\
- end\
- \
- local artboard = self.Bedrock:GetObject('Artboard')\
- if artboard then\
- self:GetObject('NumberBox').Value = artboard.BrushSize\
- end\
- \
- self:GetObject('NumberBox').OnChange = function(_self)\
- local artboard = self.Bedrock:GetObject('Artboard')\
- if artboard then\
- artboard.BrushSize = _self.Value\
- end\
- end\
- end",["ColoursWindow.lua"]="Inherit = 'SnapWindow'\
- ContentViewName = 'colourswindow'\
- \
- Title = 'Colours'\
- \
- OnContentLoad = function(self)\
- local artboard = self.Bedrock:GetObject('Artboard')\
- if artboard then\
- self:GetObject('PrimaryColourButton').BackgroundColour = artboard.BrushColour\
- self:GetObject('SecondaryColourButton').BackgroundColour = artboard.SecondaryBrushColour\
- else\
- self:GetObject('PrimaryColourButton').BackgroundColour = colours.lightBlue\
- self:GetObject('SecondaryColourButton').BackgroundColour = colours.magenta\
- end\
- \
- local buttons = self:GetObjects('ColourButton')\
- for i, button in ipairs(buttons) do\
- button.OnClick = function(_self, event, side, x , y)\
- local artboard = self.Bedrock:GetObject('Artboard')\
- if artboard then\
- if side == 1 then\
- artboard:SetBrushColour(button.BackgroundColour)\
- self:GetObject('PrimaryColourButton').BackgroundColour = button.BackgroundColour\
- elseif side == 2 then\
- artboard:SetSecondaryBrushColour(button.BackgroundColour)\
- self:GetObject('SecondaryColourButton').BackgroundColour = button.BackgroundColour\
- end\
- end\
- end\
- end\
- end",["SnapWindow.lua"]="Inherit = 'View'\
- BackgroundColour = colours.white\
- ToolBarColour = colours.grey\
- ToolBarTextColour = colours.white\
- ShadowColour = colours.grey\
- Title = ''\
- CanClose = true\
- DragX = nil\
- Z = 50\
- \
- OnLoad = function(self)\
- self:BringToFront()\
- self:AddObject({\
- X = 1, \
- Y = 1, \
- Width = 1, \
- Height = 1, \
- Type = 'Button', \
- BackgroundColour = colours.transparent,\
- TextColour = colours.lightGrey, \
- Text = 'x', \
- Name = 'CloseButton', \
- OnClick = function(btn)\
- if self.OnCloseButton then\
- self:OnCloseButton()\
- end\
- self:Close()\
- end\
- })\
- \
- local view = self:AddObject({\
- X = 1,\
- Y = 2,\
- InheritView = self.ContentViewName,\
- Type = 'View',\
- Name = 'ContentView'\
- })\
- \
- if self.OnContentLoad then\
- self:OnContentLoad()\
- end\
- \
- self.Width = view.Width\
- self.Height = view.Height + 1\
- \
- if self.Y + self.Height > Drawing.Screen.Height then\
- self.Y = Drawing.Screen.Height - self.Height + 1\
- end\
- end\
- \
- OnWindowDrag = function(self, x, y)\
- local old = self.Docked\
- if x >= Drawing.Screen.Width - 2 then\
- self.Docked = true\
- self.Bedrock.DragWindow = nil\
- else\
- self.Docked = false\
- end\
- \
- if old ~= self.Docked and self.OnDockChange then\
- self:OnDockChange(self.Docked)\
- if self.Y + self.Height > Drawing.Screen.Height then\
- self.Y = Drawing.Screen.Height - self.Height + 1\
- end\
- end\
- end\
- \
- OnDraw = function(self, x, y)\
- Drawing.DrawBlankArea(x, y, self.Width, 1, self.ToolBarColour)\
- local title = self.Bedrock.Helpers.TruncateString(self.Title, self.Width - 2)\
- Drawing.DrawCharactersCenter(self.X, self.Y, self.Width, 1, title, self.ToolBarTextColour, self.ToolBarColour)\
- Drawing.IgnoreConstraint = true\
- Drawing.DrawBlankArea(x + 1, y + 1, self.Width, self.Height, self.ShadowColour)\
- Drawing.IgnoreConstraint = false\
- end\
- \
- BringToFront = function(self)\
- for i = #self.Bedrock.View.Children, 1, -1 do\
- local child = self.Bedrock.View.Children[i]\
- \
- if child.OnWindowDrag then\
- self.Z = child.Z + 1\
- break\
- end\
- end\
- self.Bedrock:ReorderObjects()\
- end\
- \
- Click = function(self, event, side, x, y, z)\
- if self.Visible and not self.IgnoreClick then\
- self:BringToFront()\
- for i = #self.Children, 1, -1 do --children are ordered from smallest Z to highest, so this is done in reverse\
- local child = self.Children[i]\
- if self:DoClick(child, event, side, x, y) then\
- if self.OnChildClick then\
- self:OnChildClick(child, event, side, x, y)\
- end\
- return true\
- end\
- end\
- if event == 'mouse_click' and self.OnClick and self:OnClick(event, side, x, y) ~= false then\
- return true\
- elseif event == 'mouse_drag' and self.OnDrag and self:OnDrag(event, side, x, y) ~= false then\
- return true\
- elseif event == 'mouse_scroll' and self.OnScroll and self:OnScroll(event, side, x, y) ~= false then\
- return true\
- else\
- return false\
- end\
- else\
- return false\
- end\
- end\
- \
- OnClick = function(self, event, side, x, y)\
- if x ~= 1 and y == 1 then\
- self.DragX = x\
- self.Bedrock.DragWindow = self\
- return true\
- end\
- return false\
- end\
- \
- Close = function(self)\
- self.Bedrock:RemoveObject(self)\
- if self.OnClose then\
- self:OnClose()\
- end\
- end\
- \
- OnUpdate = function(self, value)\
- if value == 'Children' and self:GetObject('ContentView') then\
- self.Width = self:GetObject('ContentView').Width\
- self.Height = self:GetObject('ContentView').Height + 1\
- end\
- end",["Artboard.lua"]="Inherit = 'View'\
- X = 2\
- Y = 3\
- Tool = nil\
- BrushSize = 1\
- BrushColour = nil\
- SecondaryBrushColour = nil\
- BrushShape = 'Circle'\
- CorrectPixelRatio = false\
- \
- DragStart = nil\
- DragTimer = nil\
- Zoom = 1\
- CurrentLayer = nil\
- ShowFilterMasks = false\
- History = {}\
- HistoryPosition = 0\
- SavedState = nil\
- PushStateDelay = nil\
- Selection = {}\
- SelectionIsBlack = false\
- SelectionTimer = nil\
- UpdateDrawBlacklist = {['SelectionTimer']=true}\
- \
- OnDraw = function(self, x, y)\
- Drawing.IgnoreConstraint = true\
- Drawing.DrawBlankArea(x + 1, y + 1, self.Width, self.Height, colours.grey)\
- Drawing.IgnoreConstraint = false\
- \
- for _x = 1, self.Width do\
- local odd = (_x % 2) == 1\
- for _y = 1, self.Height do\
- if odd then\
- Drawing.WriteToBuffer(x + _x - 1, y + _y - 1, \":\", colours.lightGrey, colours.white)\
- else\
- Drawing.WriteToBuffer(x + _x - 1, y + _y - 1, \":\", colours.white, colours.lightGrey)\
- end\
- odd = not odd\
- end\
- end\
- end\
- \
- OnPostChildrenDraw = function(self, x, y)\
- if self.Selection and self.Selection[1] and self.Selection[2] then\
- local point1 = {\
- X = self.Selection[1].X * self.Zoom,\
- Y = self.Selection[1].Y * self.Zoom\
- }\
- local point2 = {\
- X = self.Selection[2].X * self.Zoom,\
- Y = self.Selection[2].Y * self.Zoom\
- }\
- \
- local size = {\
- X = point2.X - point1.X,\
- Y = point2.Y - point1.Y\
- }\
- \
- local isBlack = self.SelectionIsBlack\
- \
- local function c()\
- local c = colours.white\
- if isBlack then\
- c = colours.black\
- end\
- isBlack = not isBlack\
- return c\
- end\
- \
- function horizontal(y)\
- Drawing.WriteToBuffer(self.X - 1 + point1.X, self.Y - 1 + y, '+', c(), colours.transparent)\
- if size.X > 0 then\
- for i = 1, size.X - 1 do\
- Drawing.WriteToBuffer(self.X - 1 + point1.X + i, self.Y - 1 + y, '-', c(), colours.transparent)\
- end\
- else\
- for i = 1, (-1 * size.X) - 1 do\
- Drawing.WriteToBuffer(self.X - 1 + point1.X - i, self.Y - 1 + y, '-', c(), colours.transparent)\
- end\
- end\
- \
- Drawing.WriteToBuffer(self.X - 1 + point1.X + size.X, self.Y - 1 + y, '+', c(), colours.transparent)\
- end\
- \
- function vertical(x)\
- if size.Y < 0 then\
- for i = 1, (-1 * size.Y) - 1 do\
- Drawing.WriteToBuffer(self.X - 1 + x, self.Y - 1 + point1.Y - i, '|', c(), colours.transparent)\
- end\
- else\
- for i = 1, size.Y - 1 do\
- Drawing.WriteToBuffer(self.X - 1 + x, self.Y - 1 + point1.Y + i, '|', c(), colours.transparent)\
- end\
- end\
- end\
- \
- horizontal(point1.Y)\
- vertical(point1.X)\
- horizontal(point1.Y + size.Y)\
- vertical(point1.X + size.X)\
- \
- self.SelectionTimer = self.Bedrock:StartTimer(function(_, timer)\
- if timer == self.SelectionTimer then\
- self.SelectionIsBlack = not self.SelectionIsBlack\
- end\
- end, 0.5)\
- end\
- end\
- \
- CreateLayer = function(self, name, backgroundColour, _type, pixels, visible)\
- if not pixels then\
- self:PushState()\
- pixels = {}\
- \
- for x = 1, self.Width do\
- pixels[x] = {}\
- for y = 1, self.Height do\
- pixels[x][y] = {\
- BackgroundColour = backgroundColour,\
- TextColour = colours.black,\
- Character = ' '\
- }\
- end\
- end\
- elseif #pixels ~= self.Width or #pixels[1] ~= self.Height then\
- for x = 1, self.Width do\
- if not pixels[x] then\
- pixels[x] = {}\
- end\
- for y = 1, self.Height do\
- if not pixels[x][y] then\
- pixels[x][y] = {\
- BackgroundColour = backgroundColour,\
- TextColour = colours.black,\
- Character = ' '\
- }\
- end\
- end\
- end\
- end\
- \
- local layer = {\
- Name = name,\
- Pixels = pixels,\
- BackgroundColour = backgroundColour or colours.transparent,\
- Visible = (visible ~= nil and visible or true),\
- Index = #self.Layers + 1,\
- LayerType = _type or 'Normal'\
- }\
- table.insert(self.Layers, layer)\
- \
- self:UpdateLayers()\
- self:PushState()\
- return layer\
- end\
- \
- \
- -- copied from SO\
- local function recursive_compare(t1,t2)\
- if t1==t2 then return true end\
- if (type(t1)~=\"table\") then return false end\
- local mt1 = getmetatable(t1)\
- local mt2 = getmetatable(t2)\
- if( not recursive_compare(mt1,mt2) ) then return false end\
- for k1,v1 in pairs(t1) do\
- if not t2[k1] then return false end\
- local v2 = t2[k1]\
- if( not recursive_compare(v1,v2) ) then return false end\
- end\
- for k2,v2 in pairs(t2) do\
- if not t1[k2] then return false end\
- local v1 = t1[k2]\
- if( not recursive_compare(v1,v2) ) then return false end\
- end\
- return true \
- end\
- \
- StatesEqual = function(self, one, two)\
- return recursive_compare(one, two)\
- end\
- \
- -- copied from Lua docs\
- local function deepcopy(orig)\
- local orig_type = type(orig)\
- local copy\
- if orig_type == 'table' then\
- copy = {}\
- for orig_key, orig_value in next, orig, nil do\
- copy[deepcopy(orig_key)] = deepcopy(orig_value)\
- end\
- setmetatable(copy, deepcopy(getmetatable(orig)))\
- else\
- copy = orig\
- end\
- return copy\
- end\
- \
- PushState = function(self)\
- if #self.History == 0 or not self:StatesEqual(self.History[self.HistoryPosition], self.Layers) then\
- self.PushStateDelay = nil\
- table.insert(self.History, self.HistoryPosition + 1, deepcopy(self.Layers))\
- self.HistoryPosition = self.HistoryPosition + 1\
- self:UpdateUndoRedoMenuItems()\
- end\
- end\
- \
- DelayedPushState = function(self)\
- if not self.PushStateDelay then\
- self.PushStateDelay = self.Bedrock:StartTimer(function()\
- self:PushState()\
- end, 1)\
- end\
- end\
- \
- GoToHistoryPosition = function(self, position)\
- if position ~= self.HistoryPosition and position >= 1 and position <= #self.History then\
- self.HistoryPosition = position\
- self.Layers = deepcopy(self.History[self.HistoryPosition])\
- self:SetZoom(self.Zoom)\
- self:UpdateLayers()\
- self:ForceDraw()\
- self:UpdateUndoRedoMenuItems()\
- end\
- end\
- \
- Undo = function(self)\
- self:GoToHistoryPosition(self.HistoryPosition - 1)\
- end\
- \
- Redo = function(self)\
- self:GoToHistoryPosition(self.HistoryPosition + 1)\
- end\
- \
- EraseSelection = function(self)\
- return (self:GetCurrentLayer():GetSelectedPixels(true) ~= nil)\
- end\
- \
- Copy = function(self)\
- Clipboard.Copy(deepcopy(self:GetCurrentLayer():GetSelectedPixels()), 'sketchpixels')\
- self.Selection = nil\
- self:UpdateSelectionMenuItems()\
- self:UpdateClipboardMenuItems()\
- end\
- \
- Cut = function(self)\
- Clipboard.Cut(deepcopy(self:GetCurrentLayer():GetSelectedPixels(true)), 'sketchpixels')\
- self.Selection = nil\
- self:UpdateSelectionMenuItems()\
- self:UpdateClipboardMenuItems()\
- end\
- \
- Paste = function(self)\
- local pixels, t = Clipboard.Paste()\
- if pixels and t == 'sketchpixels' then\
- self:SetCurrentLayer(nil)\
- self:CreateLayer('Pasted Content', colours.transparent, 'Normal', pixels)\
- -- self:UpdateLayers()\
- end\
- self:UpdateClipboardMenuItems()\
- end\
- \
- DuplicateLayer = function(self, layer)\
- local newLayer = deepcopy(layer)\
- newLayer.Name = newLayer.Name .. ' Copy'\
- table.insert(self.Layers, newLayer)\
- self:UpdateLayers()\
- self:PushState()\
- end\
- \
- UpdateUndoRedoMenuItems = function(self)\
- self.Bedrock:GetObject('RedoMenuItem').Enabled = self.HistoryPosition < #self.History\
- self.Bedrock:GetObject('UndoMenuItem').Enabled = self.HistoryPosition > 1\
- end\
- \
- UpdateSelectionMenuItems = function(self)\
- local selection = (self.Selection ~= nil and self.Selection[1] ~= nil and self.Selection[2] ~= nil)\
- self.Bedrock:GetObject('CutMenuItem').Enabled = selection\
- self.Bedrock:GetObject('CopyMenuItem').Enabled = selection\
- self.Bedrock:GetObject('CropMenuItem').Enabled = selection\
- self.Bedrock:GetObject('EraseMenuItem').Enabled = selection\
- local window = self.Bedrock:GetObject('InfoWindow')\
- if window then\
- window:UpdateInfo()\
- end\
- end\
- \
- UpdateClipboardMenuItems = function(self)\
- self.Bedrock:GetObject('PasteMenuItem').Enabled = (Clipboard.Content ~= nil and Clipboard.Type == 'sketchpixels')\
- end\
- \
- Modified = function(self, layers)\
- return not self:StatesEqual(self.History[self.HistoryPosition], self.SavedState)\
- end\
- \
- SetBrushColour = function(self, value)\
- self.BrushColour = value\
- self.Bedrock:GetObject('PrimaryColourView').BackgroundColour = self.BrushColour\
- self:PushState()\
- end\
- \
- SetSecondaryBrushColour = function(self, value)\
- self.SecondaryBrushColour = value\
- self.Bedrock:GetObject('SecondaryColourView').BackgroundColour = self.SecondaryBrushColour\
- self:PushState()\
- end\
- \
- SetTool = function(self, value)\
- if not value.OnSelect or value.OnSelect(self) then\
- if self.Tool and self.Tool.OnStopUse then\
- self.Tool.OnStopUse(self)\
- end\
- \
- self.Tool = value\
- self.Bedrock:GetObject('CurrentToolLabel').Text = self.Tool.Name\
- self:PushState()\
- end\
- end\
- \
- SetZoom = function(self, value)\
- if value > 0 and value <= 4 then\
- self.Zoom = value\
- local pixels = self:GetCurrentLayer().Layer.Pixels\
- local width = self.Bedrock.Helpers.Round(self.Zoom * #pixels)\
- local height = self.Bedrock.Helpers.Round(self.Zoom * #pixels[1])\
- if width < 1 then\
- width = 1\
- end\
- if height < 1 then\
- height = 1\
- end\
- \
- self.X = self.Bedrock.Helpers.Round(self.X + (self.Width - width)/2)\
- self.Y = self.Bedrock.Helpers.Round(self.Y + (self.Height - height)/2)\
- \
- self.Width = width\
- self.Height = height\
- end\
- end\
- \
- UpdateLayers = function(self)\
- self.CurrentLayer = nil\
- self:RemoveAllObjects()\
- \
- for i, v in ipairs(self.Layers) do\
- self:AddObject({\
- Type = \"Layer\",\
- Layer = v,\
- Width = self.Width,\
- Height = self.Height,\
- LayerIndex = i\
- })\
- end\
- self:GetCurrentLayer()\
- \
- local window = self.Bedrock:GetObject('LayersWindow')\
- if window then\
- window:UpdateLayers()\
- end\
- end\
- \
- GetPixelBelowLayer = function(self, x, y, layerIndex)\
- local bgColour = colours.transparent\
- local txtColour = colours.transparent\
- local char = ' '\
- \
- for i = 1, layerIndex - 1 do\
- if self.Children[i].Visible then\
- local p = self.Children[i].DrawnPixels[x][y]\
- if p then\
- if p.BackgroundColour ~= colours.transparent then\
- bgColour = p.BackgroundColour\
- end\
- \
- if p.TextColour ~= colours.transparent and p.Character ~= ' ' then\
- txtColour = p.TextColour\
- char = p.Character\
- end\
- end\
- end\
- end\
- return bgColour, txtColour, char\
- end\
- \
- GetBackgroundColour = function(self)\
- for i = #self.Layers, 1, -1 do --children are ordered from smallest Z to highest, so this is done in reverse\
- if self.Layers[i].BackgroundColour ~= colours.transparent then\
- return self.Layers[i].BackgroundColour\
- end\
- end\
- return colours.transparent\
- end\
- \
- GetFlattenedPixels = function(self)\
- local pixels = {}\
- for x = 1, self.Width do\
- pixels[x] = {}\
- for y = 1, self.Height do\
- pixels[x][y] = {\
- BackgroundColour = self:GetBackgroundColour(),\
- TextColour = colours.black,\
- Character = ' '\
- }\
- end\
- end\
- \
- self:Draw()\
- for i, v in ipairs(self.Children) do\
- for x, col in pairs(v.DrawnPixels) do\
- for y, pixel in pairs(col) do\
- if pixel then\
- if pixel.BackgroundColour ~= colours.transparent then\
- pixels[x][y].BackgroundColour = pixel.BackgroundColour\
- end\
- \
- if pixel.Character ~= ' ' then\
- pixels[x][y].Character = pixel.Character\
- pixels[x][y].TextColour = pixel.TextColour\
- end\
- end\
- end\
- end\
- end\
- return pixels\
- end\
- \
- FlattenImage = function(self)\
- local pixels = self:GetFlattenedPixels()\
- self.Layers = {}\
- self:CreateLayer('Background', self:GetBackgroundColour(), 'Normal', pixels)\
- self:PushState()\
- end\
- \
- Resize = function(self, width, height, keepTextDetail)\
- for i, layer in ipairs(self.Layers) do\
- self.Layers[i].Pixels = self.Children[i]:GetZoomPixels(width, height, keepTextDetail)\
- end\
- self.Width = width\
- self.Height = height\
- self.X = self.Bedrock.Helpers.Round((Drawing.Screen.Width - self.Width - 3) / 2)\
- self.Y = self.Bedrock.Helpers.Round((Drawing.Screen.Height - self.Height) / 2)\
- self:PushState()\
- self:UpdateLayers()\
- self:ForceDraw()\
- end\
- \
- ChangeCanvasSize = function(self, width, height, anchor, top, bottom, left, right)\
- top = top or 0\
- bottom = bottom or 0\
- left = left or 0\
- right = right or 0\
- \
- if anchor then\
- if anchor == 2 or anchor == 5 or anchor == 8 then\
- left = math.floor((width - self.Width) / 2)\
- right = math.ceil((width - self.Width) / 2)\
- elseif anchor == 1 or anchor == 4 or anchor == 7 then\
- right = width - self.Width\
- elseif anchor == 3 or anchor == 6 or anchor == 9 then\
- left = width - self.Width\
- end\
- \
- if anchor / 3 <= 1 then\
- bottom = height - self.Height\
- elseif anchor / 3 <= 2 then\
- top = math.floor((height - self.Height) / 2)\
- bottom = math.ceil((height - self.Height) / 2)\
- else\
- top = height - self.Height\
- end\
- end\
- \
- for i, layer in ipairs(self.Layers) do\
- if left < 0 then\
- for x = 1, -left do\
- table.remove(layer.Pixels, 1)\
- end\
- end\
- \
- if right < 0 then\
- for x = 1, -right do\
- table.remove(layer.Pixels, #layer.Pixels)\
- end\
- end\
- \
- if top < 0 then\
- for y = 1, -top do\
- for x = 1, self.Width do\
- if layer.Pixels[x] then\
- table.remove(layer.Pixels[x], 1)\
- end\
- end\
- end\
- end\
- \
- if bottom < 0 then\
- for y = 1, -bottom do\
- for x = 1, self.Width do\
- if layer.Pixels[x] then\
- table.remove(layer.Pixels[x], #layer.Pixels[x])\
- end\
- end\
- end\
- end\
- \
- for x = 1, left do\
- table.insert(layer.Pixels, 1, {})\
- for y = 1, height do\
- layer.Pixels[1][y] = {BackgroundColour = layer.BackgroundColour, TextColour = colours.black, Character = ' '}\
- end\
- end\
- \
- for x = 1, right do\
- table.insert(layer.Pixels, {})\
- for y = 1, height do\
- layer.Pixels[#layer.Pixels][y] = {BackgroundColour = layer.BackgroundColour, TextColour = colours.black, Character = ' '}\
- end\
- end\
- \
- for y = 1, top do\
- for x = 1, width do\
- table.insert(layer.Pixels[x], 1, {})\
- layer.Pixels[x][1] = {BackgroundColour = layer.BackgroundColour, TextColour = colours.black, Character = ' '}\
- end\
- end\
- \
- for y = 1, bottom do\
- for x = 1, width do\
- table.insert(layer.Pixels[x], {})\
- layer.Pixels[x][#layer.Pixels[x]] = {BackgroundColour = layer.BackgroundColour, TextColour = colours.black, Character = ' '}\
- end\
- end\
- end\
- \
- self.Width = width\
- self.Height = height\
- self.X = self.Bedrock.Helpers.Round((Drawing.Screen.Width - self.Width - 3) / 2)\
- self.Y = self.Bedrock.Helpers.Round((Drawing.Screen.Height - self.Height) / 2)\
- self:PushState()\
- self:UpdateLayers()\
- self:ForceDraw()\
- end\
- \
- Crop = function(self)\
- if self.Selection and self.Selection[1] and self.Selection[2] then\
- local top = 0\
- local left = 0\
- local bottom = 0\
- local right = 0\
- if self.Selection[1].X < self.Selection[2].X then\
- left = self.Selection[1].X - 1\
- right = self.Width - self.Selection[2].X\
- else\
- left = self.Selection[2].X - 1\
- right = self.Width - self.Selection[1].X\
- end\
- if self.Selection[1].Y < self.Selection[2].Y then\
- top = self.Selection[1].Y - 1\
- bottom = self.Height - self.Selection[2].Y\
- else\
- top = self.Selection[2].Y - 1\
- bottom = self.Height - self.Selection[1].Y\
- end\
- self:ChangeCanvasSize(self.Width - left - right, self.Height - top - bottom, nil, -top, -bottom, -left, -right)\
- self.Selection = {}\
- end\
- end\
- \
- SetSavedState = function(self)\
- self.SavedState = deepcopy(self.History[self.HistoryPosition])\
- end\
- \
- OnLoad = function(self)\
- self:UpdateLayers()\
- self:SetTool(PencilTool)\
- self:SetBrushColour(colours.lightBlue)\
- self:SetSecondaryBrushColour(colours.magenta)\
- self.BrushSize = 1\
- \
- self:PushState()\
- self:SetSavedState()\
- \
- self.Bedrock.OnArtboardOpen(self)\
- self:UpdateUndoRedoMenuItems()\
- self:UpdateSelectionMenuItems()\
- self:UpdateClipboardMenuItems()\
- end\
- \
- OnDeleteLayer = function(self, layer)\
- if layer == self.CurrentLayer then\
- self.CurrentLayer = self.Children[#self.Children]\
- end\
- self:PushState()\
- end\
- \
- GetCurrentLayer = function(self)\
- if not self.CurrentLayer then\
- self:SetCurrentLayer(self.Children[#self.Children])\
- end\
- return self.CurrentLayer\
- end\
- \
- SetCurrentLayer = function(self, layer)\
- self.CurrentLayer = layer\
- \
- local window = self.Bedrock:GetObject('LayersWindow')\
- if window then\
- window:UpdateLayers()\
- end\
- end\
- \
- OnUpdate = function(self, value)\
- if value == 'Layers' or value == 'Width' or value == 'Height' then\
- self:UpdateLayers()\
- elseif value == 'Selection' then\
- self:UpdateSelectionMenuItems()\
- end\
- end\
- \
- OnClick = function(self, event, side, x, y)\
- if self.Tool then\
- self.Tool.OnUse(self, event, side, x, y)\
- end\
- end\
- \
- OnRemove = function(self)\
- self.Bedrock.OnArtboardClose(self)\
- end\
- \
- OnDrag = OnClick\
- \
- NewLayer = function(self)\
- self.Bedrock:DisplayTextBoxWindow('New Layer', \"Enter the name for the new layer.\", function(success, name)\
- if success then\
- self:CreateLayer(name, colours.transparent)\
- end\
- end)\
- end",["Sidebar.lua"]="Inherit = 'View'\
- \
- BackgroundColour = colours.grey\
- FlashingColour = colours.lightBlue\
- Z = 101\
- Flashing = false\
- \
- OnDraw = function(self, x, y)\
- local bgColour = self.BackgroundColour\
- if self.Flashing then\
- bgColour = self.FlashingColour\
- end\
- Drawing.DrawBlankArea(x, y, self.Width, self.Height, bgColour)\
- end\
- \
- UpdateButtons = function(self, enabled)\
- for i, v in ipairs(self.Children) do\
- v.Enabled = enabled\
- end\
- end\
- \
- CloseDocked = function(self)\
- for i, v in ipairs(self.Children) do\
- if v.WindowDocked then\
- v.Window:Close()\
- end\
- end\
- end\
- \
- OnDock = function(self)\
- self.Flashing = true\
- self.Bedrock:StartTimer(function()\
- self.Flashing = false\
- end, 0.2)\
- end",},}
- local function run(tArgs)
- local fnFile, err = loadstring(files['startup'], 'startup')
- if err then
- error(err)
- end
- local function split(str, pat)
- local t = {}
- local fpat = "(.-)" .. pat
- local last_end = 1
- local s, e, cap = str:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(t,cap)
- end
- last_end = e+1
- s, e, cap = str:find(fpat, last_end)
- end
- if last_end <= #str then
- cap = str:sub(last_end)
- table.insert(t, cap)
- end
- return t
- end
- local function resolveTreeForPath(path, single)
- local _files = files
- local parts = split(path, '/')
- if parts then
- for i, v in ipairs(parts) do
- if #v > 0 then
- if _files[v] then
- _files = _files[v]
- else
- _files = nil
- break
- end
- end
- end
- elseif #path > 0 and path ~= '/' then
- _files = _files[path]
- end
- if not single or type(_files) == 'string' then
- return _files
- end
- end
- local oldFs = fs
- local env
- env = {
- fs = {
- list = function(path)
- local list = {}
- if fs.exists(path) then
- list = fs.list(path)
- end
- for k, v in pairs(resolveTreeForPath(path)) do
- if not fs.exists(path .. '/' ..k) then
- table.insert(list, k)
- end
- end
- return list
- end,
- exists = function(path)
- if fs.exists(path) then
- return true
- elseif resolveTreeForPath(path) then
- return true
- else
- return false
- end
- end,
- isDir = function(path)
- if fs.isDir(path) then
- return true
- else
- local tree = resolveTreeForPath(path)
- if tree and type(tree) == 'table' then
- return true
- else
- return false
- end
- end
- end,
- isReadOnly = function(path)
- if not fs.isReadOnly(path) then
- return false
- else
- return true
- end
- end,
- getName = fs.getName,
- getSize = fs.getSize,
- getFreespace = fs.getFreespace,
- makeDir = fs.makeDir,
- move = fs.move,
- copy = fs.copy,
- delete = fs.delete,
- combine = fs.combine,
- open = function(path, mode)
- if fs.exists(path) then
- return fs.open(path, mode)
- elseif type(resolveTreeForPath(path)) == 'string' then
- local handle = {close = function()end}
- if mode == 'r' then
- local content = resolveTreeForPath(path)
- handle.readAll = function()
- return content
- end
- local line = 1
- local lines = split(content, '\n')
- handle.readLine = function()
- if line > #lines then
- return nil
- else
- return lines[line]
- end
- line = line + 1
- end
- return handle
- else
- error('Cannot write to read-only file (compilr archived).')
- end
- else
- return fs.open(path, mode)
- end
- end
- },
- io = {
- input = io.input,
- output = io.output,
- type = io.type,
- close = io.close,
- write = io.write,
- flush = io.flush,
- lines = io.lines,
- read = io.read,
- open = function(path, mode)
- if fs.exists(path) then
- return io.open(path, mode)
- elseif type(resolveTreeForPath(path)) == 'string' then
- local content = resolveTreeForPath(path)
- local f = fs.open(path, 'w')
- f.write(content)
- f.close()
- if mode == 'r' then
- return io.open(path, mode)
- else
- error('Cannot write to read-only file (compilr archived).')
- end
- else
- return io.open(path, mode)
- end
- end
- },
- loadfile = function( _sFile )
- local file = env.fs.open( _sFile, "r" )
- if file then
- local func, err = loadstring( file.readAll(), fs.getName( _sFile ) )
- file.close()
- return func, err
- end
- return nil, "File not found: ".._sFile
- end,
- dofile = function( _sFile )
- local fnFile, e = env.loadfile( _sFile )
- if fnFile then
- setfenv( fnFile, getfenv(2) )
- return fnFile()
- else
- error( e, 2 )
- end
- end
- }
- setmetatable( env, { __index = _G } )
- local tAPIsLoading = {}
- env.os.loadAPI = function( _sPath )
- local sName = fs.getName( _sPath )
- if tAPIsLoading[sName] == true then
- printError( "API "..sName.." is already being loaded" )
- return false
- end
- tAPIsLoading[sName] = true
- local tEnv = {}
- setmetatable( tEnv, { __index = env } )
- local fnAPI, err = env.loadfile( _sPath )
- if fnAPI then
- setfenv( fnAPI, tEnv )
- fnAPI()
- else
- printError( err )
- tAPIsLoading[sName] = nil
- return false
- end
- local tAPI = {}
- for k,v in pairs( tEnv ) do
- tAPI[k] = v
- end
- env[sName] = tAPI
- tAPIsLoading[sName] = nil
- return true
- end
- env.shell = shell
- setfenv( fnFile, env )
- fnFile(unpack(tArgs))
- end
- local function extract()
- local function node(path, tree)
- if type(tree) == 'table' then
- fs.makeDir(path)
- for k, v in pairs(tree) do
- node(path .. '/' .. k, v)
- end
- else
- local f = fs.open(path, 'w')
- if f then
- f.write(tree)
- f.close()
- end
- end
- end
- node('', files)
- end
- local tArgs = {...}
- if #tArgs == 1 and tArgs[1] == '--extract' then
- extract()
- else
- run(tArgs)
- end
Add Comment
Please, Sign In to add comment