Transferring PictureEdit to windowed mode

This commit is contained in:
Igor Timofeev 2019-01-24 17:46:26 +03:00
parent 0110fef7e8
commit f2fb95c0d2
10 changed files with 307 additions and 239 deletions

View File

@ -32,6 +32,8 @@ local tool
--------------------------------------------------------------------
local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 125, 34, 0x1E1E1E))
local function saveConfig()
filesystem.writeTable(configPath, config)
end
@ -74,31 +76,44 @@ end
loadConfig()
local workspace = GUI.workspace()
workspace.menu = workspace:addChild(GUI.menu(1, 1, workspace.width, 0xE1E1E1, 0x5A5A5A, 0x3366CC, 0xFFFFFF, nil))
local function addTitle(container, text)
local titleContainer = container:addChild(GUI.container(1, 1, container.width, 1))
titleContainer:addChild(GUI.panel(1, 1, titleContainer.width, 1, 0x2D2D2D))
titleContainer:addChild(GUI.panel(1, 1, titleContainer.width, 1, 0x1E1E1E))
titleContainer:addChild(GUI.text(2, 1, 0xD2D2D2, text))
return titleContainer
end
local pizdaWidth = 28
workspace.sidebarPanel = workspace:addChild(GUI.panel(workspace.width - pizdaWidth + 1, 2, pizdaWidth, workspace.height - 1, 0x3C3C3C))
workspace.sidebarLayout = workspace:addChild(GUI.layout(workspace.sidebarPanel.localX, 2, workspace.sidebarPanel.width, workspace.sidebarPanel.height, 1, 1))
workspace.sidebarLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
window.sidebarPanel = window:addChild(GUI.panel(1, 1, 28, 1, 0x2D2D2D))
window.sidebarLayout = window:addChild(GUI.layout(1, 1, window.sidebarPanel.width, 1, 1, 1))
window.sidebarLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
addTitle(workspace.sidebarLayout, "Recent colors")
window.sidebarLayout.eventHandler = function(workspace, object, e1, e2, e3, e4, e5)
if e1 == "scroll" then
local h, v = window.sidebarLayout:getMargin(1, 1)
local from = 0
local to = -window.sidebarLayout.cells[1][1].childrenHeight + 2
local recentColorsContainer = workspace.sidebarLayout:addChild(GUI.container(1, 1, workspace.sidebarLayout.width - 2, 4))
v = v + (e5 > 0 and 2 or -2)
if v > from then
v = from
elseif v < to then
v = to
end
window.sidebarLayout:setMargin(1, 1, h, v)
workspace:draw()
end
end
addTitle(window.sidebarLayout, "Recent colors")
local recentColorsContainer = window.sidebarLayout:addChild(GUI.container(1, 1, window.sidebarLayout.width - 2, 4))
local x, y = 1, 1
for i = 1, #config.recentColors do
local button = recentColorsContainer:addChild(GUI.button(x, y, 2, 1, 0x0, 0x0, 0x0, 0x0, " "))
button.onTouch = function()
workspace.primaryColorSelector.color = config.recentColors[i]
window.primaryColorSelector.color = config.recentColors[i]
workspace:draw()
end
@ -108,37 +123,40 @@ for i = 1, #config.recentColors do
end
end
local currentToolTitle = addTitle(workspace.sidebarLayout, "Tool properties")
local currentToolTitle = addTitle(window.sidebarLayout, "Tool properties")
workspace.currentToolLayout = workspace.sidebarLayout:addChild(GUI.layout(1, 1, workspace.sidebarLayout.width, 1, 1, 1))
workspace.currentToolLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
workspace.currentToolLayout:setFitting(1, 1, true, false, 2, 0)
window.currentToolLayout = window.sidebarLayout:addChild(GUI.layout(1, 1, window.sidebarLayout.width, 1, 1, 1))
window.currentToolLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
window.currentToolLayout:setFitting(1, 1, true, false, 2, 0)
local aboutToolTitle = addTitle(window.sidebarLayout, "About tool")
local aboutToolTextBox = window.sidebarLayout:addChild(GUI.textBox(1, 1, window.sidebarLayout.width - 2, 1, nil, 0x787878, {}, 1, 0, 0))
window.toolsList = window:addChild(GUI.list(1, 1, 7, 1, 3, 0, 0x2D2D2D, 0x787878, 0x2D2D2D, 0x787878, 0x3C3C3C, 0xE1E1E1))
window.toolsList:setMargin(0, 3)
window.image = window:addChild(GUI.object(1, 1, 1, 1))
window.image.data = {}
local aboutToolTitle = addTitle(workspace.sidebarLayout, "About tool")
local aboutToolTextBox = workspace.sidebarLayout:addChild(GUI.textBox(1, 1, workspace.sidebarLayout.width - 2, 1, nil, 0x787878, {}, 1, 0, 0))
workspace.toolsList = workspace:addChild(GUI.list(1, 2, 6, workspace.height - 1, 3, 0, 0x3C3C3C, 0xD2D2D2, 0x3C3C3C, 0xD2D2D2, 0x2D2D2D, 0xD2D2D2))
workspace.backgroundPanel = workspace:addChild(GUI.panel(workspace.toolsList.width + 1, 2, workspace.width - workspace.toolsList.width - workspace.sidebarPanel.width, workspace.height - 1, 0x1E1E1E))
workspace.image = workspace:addChild(GUI.object(1, 1, 1, 1))
workspace.image.data = {}
local function onToolTouch(index)
tool = workspace.toolsList:getItem(index).tool
tool = window.toolsList:getItem(index).tool
workspace.toolsList.selectedItem = index
workspace.currentToolOverlay:removeChildren()
workspace.currentToolLayout:removeChildren()
window.toolsList.selectedItem = index
window.currentToolOverlay:removeChildren()
window.currentToolLayout:removeChildren()
currentToolTitle.hidden = not tool.onSelection
workspace.currentToolLayout.hidden = currentToolTitle.hidden
window.currentToolLayout.hidden = currentToolTitle.hidden
window.sidebarLayout:setMargin(1, 1, 0, 0)
if tool.onSelection then
local result, reason = pcall(tool.onSelection, workspace)
local result, reason = pcall(tool.onSelection)
if result then
workspace.currentToolLayout:update()
local lastChild = workspace.currentToolLayout.children[#workspace.currentToolLayout.children]
window.currentToolLayout:update()
local lastChild = window.currentToolLayout.children[#window.currentToolLayout.children]
if lastChild then
workspace.currentToolLayout.height = lastChild.localY + lastChild.height - 1
window.currentToolLayout.height = lastChild.localY + lastChild.height - 1
end
else
GUI.alert(reason)
@ -156,28 +174,28 @@ local function onToolTouch(index)
workspace:draw()
end
local modules = filesystem.list(toolsPath)
for i = 1, #modules do
if filesystem.extension(modules[i]) == ".lua" then
local result, reason = loadfile(toolsPath .. modules[i])
local tools = filesystem.list(toolsPath)
for i = 1, #tools do
if filesystem.extension(tools[i]) == ".lua" then
local result, reason = loadfile(toolsPath .. tools[i])
if result then
result, reason = pcall(result)
result, reason = pcall(result, workspace, window, menu)
if result then
local item = workspace.toolsList:addItem(reason.shortcut)
local item = window.toolsList:addItem(reason.shortcut)
item.tool = reason
item.onTouch = function()
onToolTouch(i)
end
else
error("Failed to perform pcall() on module " .. modules[i] .. ": " .. reason)
error("Failed to perform pcall() on tool " .. tools[i] .. ": " .. reason)
end
else
error("Failed to perform loadfile() on module " .. modules[i] .. ": " .. reason)
error("Failed to perform loadfile() on tool " .. tools[i] .. ": " .. reason)
end
end
end
workspace.image.draw = function(object)
window.image.draw = function(object)
GUI.drawShadow(object.x, object.y, object.width, object.height, nil, true)
local y, text = object.y + object.height + 1, "Size: " .. object.width .. "x" .. object.height
@ -188,25 +206,25 @@ workspace.image.draw = function(object)
screen.drawText(math.floor(object.x + object.width / 2 - unicode.len(text) / 2), y + 1, 0x5A5A5A, text)
end
local x, y, step, notStep, background, foreground, symbol = object.x, object.y, false, workspace.image.width % 2
for i = 3, #workspace.image.data, 4 do
if workspace.image.data[i + 2] == 0 then
background = workspace.image.data[i]
foreground = workspace.image.data[i + 1]
symbol = workspace.image.data[i + 3]
elseif workspace.image.data[i + 2] < 1 then
background = color.blend(config.transparencyBackground, workspace.image.data[i], workspace.image.data[i + 2])
foreground = workspace.image.data[i + 1]
symbol = workspace.image.data[i + 3]
local x, y, step, notStep, background, foreground, symbol = object.x, object.y, false, window.image.width % 2
for i = 3, #window.image.data, 4 do
if window.image.data[i + 2] == 0 then
background = window.image.data[i]
foreground = window.image.data[i + 1]
symbol = window.image.data[i + 3]
elseif window.image.data[i + 2] < 1 then
background = color.blend(config.transparencyBackground, window.image.data[i], window.image.data[i + 2])
foreground = window.image.data[i + 1]
symbol = window.image.data[i + 3]
else
if workspace.image.data[i + 3] == " " then
if window.image.data[i + 3] == " " then
background = config.transparencyBackground
foreground = config.transparencyForeground
symbol = step and "" or ""
else
background = config.transparencyBackground
foreground = workspace.image.data[i + 1]
symbol = workspace.image.data[i + 3]
foreground = window.image.data[i + 1]
symbol = window.image.data[i + 3]
end
end
@ -230,7 +248,7 @@ local function updateRecentColorsButtons()
end
local function swapColors()
workspace.primaryColorSelector.color, workspace.secondaryColorSelector.color = workspace.secondaryColorSelector.color, workspace.primaryColorSelector.color
window.primaryColorSelector.color, window.secondaryColorSelector.color = window.secondaryColorSelector.color, window.primaryColorSelector.color
workspace:draw()
end
@ -242,24 +260,25 @@ local function colorSelectorDraw(object)
end
end
workspace.secondaryColorSelector = workspace:addChild(GUI.colorSelector(2, workspace.toolsList.height - 3, 5, 2, 0xFFFFFF, " "))
workspace.primaryColorSelector = workspace:addChild(GUI.colorSelector(1, workspace.toolsList.height - 4, 5, 2, 0x880000, " "))
workspace.secondaryColorSelector.draw, workspace.primaryColorSelector.draw = colorSelectorDraw, colorSelectorDraw
window.secondaryColorSelector = window:addChild(GUI.colorSelector(3, 1, 5, 2, 0xFFFFFF, " "))
window.primaryColorSelector = window:addChild(GUI.colorSelector(2, 1, 5, 2, 0x000000, " "))
window.secondaryColorSelector.draw, window.primaryColorSelector.draw = colorSelectorDraw, colorSelectorDraw
workspace:addChild(GUI.adaptiveButton(3, workspace.secondaryColorSelector.localY + workspace.secondaryColorSelector.height + 1, 0, 0, nil, 0xD2D2D2, nil, 0xA5A5A5, "<>")).onTouch = swapColors
window.swapColorsButton = window:addChild(GUI.adaptiveButton(3, 1, 0, 0, nil, 0xD2D2D2, nil, 0xA5A5A5, "<>"))
window.swapColorsButton.onTouch = swapColors
workspace.image.eventHandler = function(workspace, object, e1, e2, e3, e4, ...)
window.image.eventHandler = function(workspace, object, e1, e2, e3, e4, ...)
if e1 == "key_down" then
-- D
if e4 == 32 then
workspace.primaryColorSelector.color, workspace.secondaryColorSelector.color = 0x0, 0xFFFFFF
window.primaryColorSelector.color, window.secondaryColorSelector.color = 0x0, 0xFFFFFF
workspace:draw()
-- X
elseif e4 == 45 then
swapColors()
else
for i = 1, workspace.toolsList:count() do
if e4 == workspace.toolsList:getItem(i).tool.keyCode then
for i = 1, window.toolsList:count() do
if e4 == window.toolsList:getItem(i).tool.keyCode then
onToolTouch(i)
return
end
@ -273,26 +292,25 @@ workspace.image.eventHandler = function(workspace, object, e1, e2, e3, e4, ...)
end
end
workspace.image.reposition = function()
workspace.image.width, workspace.image.height = workspace.image.data[1], workspace.image.data[2]
if workspace.image.width <= workspace.backgroundPanel.width then
workspace.image.localX = math.floor(workspace.backgroundPanel.x + workspace.backgroundPanel.width / 2 - workspace.image.width / 2)
workspace.image.localY = math.floor(workspace.backgroundPanel.y + workspace.backgroundPanel.height / 2 - workspace.image.height / 2)
window.image.reposition = function()
window.image.width, window.image.height = window.image.data[1], window.image.data[2]
if window.image.width <= window.backgroundPanel.width then
window.image.localX = math.floor(window.backgroundPanel.localX + window.backgroundPanel.width / 2 - window.image.width / 2)
window.image.localY = math.floor(window.backgroundPanel.localY + window.backgroundPanel.height / 2 - window.image.height / 2)
else
workspace.image.localX, workspace.image.localY = 9, 3
window.image.localX, window.image.localY = window.backgroundPanel.localX, window.backgroundPanel.localY
end
end
local function newNoGUI(width, height)
savePath, saveItem.disabled = nil, true
workspace.image.data = {width, height}
workspace.image.reposition()
window.image.data = {width, height}
for i = 1, width * height do
table.insert(workspace.image.data, 0x0)
table.insert(workspace.image.data, 0x0)
table.insert(workspace.image.data, 1)
table.insert(workspace.image.data, " ")
table.insert(window.image.data, 0x0)
table.insert(window.image.data, 0x0)
table.insert(window.image.data, 1)
table.insert(window.image.data, " ")
end
end
@ -310,6 +328,8 @@ local function new()
container.panel.eventHandler = function(workspace, object, e1)
if e1 == "touch" then
newNoGUI(tonumber(widthInput.text), tonumber(heightInput.text))
window.image.reposition()
container:remove()
workspace:draw()
end
@ -330,8 +350,7 @@ local function loadImage(path)
if result then
savePath, saveItem.disabled = path, false
addRecentFile(path)
workspace.image.data = result
workspace.image.reposition()
window.image.data = result
else
GUI.alert(reason)
end
@ -339,7 +358,7 @@ end
local function saveImage(path)
if filesystem.extension(path) == ".pic" then
local result, reason = image.save(path, workspace.image.data, 6)
local result, reason = image.save(path, window.image.data, 6)
if result then
savePath, saveItem.disabled = path, false
@ -350,19 +369,17 @@ local function saveImage(path)
else
savePath, saveItem.disabled = path, false
filesystem.write(path, image.toString(workspace.image.data))
filesystem.write(path, image.toString(window.image.data))
end
end
workspace.menu:addItem("PE", 0x00B6FF)
local fileItem = workspace.menu:addContextMenuItem("File")
local fileItem = menu:addContextMenuItem("File")
fileItem:addItem("New").onTouch = new
fileItem:addSeparator()
fileItem:addItem("Open").onTouch = function()
local filesystemDialog = GUI.addFilesystemDialog(workspace, true, 50, math.floor(workspace.height * 0.8), "Open", "Cancel", "File name", "/")
local filesystemDialog = GUI.addFilesystemDialog(workspace, true, 50, math.floor(window.height * 0.8), "Open", "Cancel", "File name", "/")
filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE)
filesystemDialog:addExtensionFilter(".pic")
filesystemDialog:addExtensionFilter(".rawpic")
@ -371,6 +388,8 @@ fileItem:addItem("Open").onTouch = function()
filesystemDialog.onSubmit = function(path)
loadImage(path)
window.image.reposition()
workspace:draw()
end
end
@ -379,6 +398,8 @@ local fileItemSubMenu = fileItem:addSubMenuItem("Open recent", #config.recentFil
for i = 1, #config.recentFiles do
fileItemSubMenu:addItem(text.limit(config.recentFiles[i], 32, "left")).onTouch = function()
loadImage(config.recentFiles[i])
window.image.reposition()
workspace:draw()
end
end
@ -400,6 +421,8 @@ fileItem:addItem("Open from URL").onTouch = function()
if result then
loadImage(temporaryPath)
window.image.reposition()
filesystem.remove(temporaryPath)
savePath, saveItem.disabled = nil, true
else
@ -421,7 +444,7 @@ saveItem.onTouch = function()
end
fileItem:addItem("Save as").onTouch = function()
local filesystemDialog = GUI.addFilesystemDialog(workspace, true, 50, math.floor(workspace.height * 0.8), "Save", "Cancel", "File name", "/")
local filesystemDialog = GUI.addFilesystemDialog(workspace, true, 50, math.floor(window.height * 0.8), "Save", "Cancel", "File name", "/")
filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE)
filesystemDialog:addExtensionFilter(".pic")
filesystemDialog:addExtensionFilter(".ocifstring")
@ -437,10 +460,10 @@ end
fileItem:addSeparator()
fileItem:addItem("Exit").onTouch = function()
workspace:stop()
window:remove()
end
workspace.menu:addItem("View").onTouch = function()
menu:addItem("View").onTouch = function()
local container = GUI.addBackgroundContainer(workspace, true, true, "View")
local colorSelector1 = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.transparencyBackground, "Transparency background"))
@ -459,7 +482,7 @@ workspace.menu:addItem("View").onTouch = function()
workspace:draw()
end
workspace.menu:addItem("Hotkeys").onTouch = function()
menu:addItem("Hotkeys").onTouch = function()
local container = GUI.addBackgroundContainer(workspace, true, true, "Hotkeys")
local lines = {
"There are some hotkeys that works exactly like in real Photoshop:",
@ -482,20 +505,43 @@ workspace.menu:addItem("Hotkeys").onTouch = function()
workspace:draw()
end
workspace.currentToolOverlay = workspace:addChild(GUI.container(1, 1, workspace.width, workspace.height))
window.currentToolOverlay = window:addChild(GUI.container(1, 1, 1, 1))
window.onResize = function(width, height)
window.backgroundPanel.localX = window.toolsList.width + 1
window.backgroundPanel.width = width - window.sidebarLayout.width - window.toolsList.width
window.backgroundPanel.height = height
window.currentToolOverlay.width = width
window.currentToolOverlay.height = height
window.sidebarPanel.localX = window.width - window.sidebarPanel.width + 1
window.sidebarPanel.height = height
window.sidebarLayout.localX = window.sidebarPanel.localX
window.sidebarLayout.height = height
window.toolsList.height = height
window.secondaryColorSelector.localY = height - 4
window.primaryColorSelector.localY = height - 5
window.swapColorsButton.localY = height - 1
window.image.reposition()
end
----------------------------------------------------------------
workspace.image:moveToBack()
workspace.backgroundPanel:moveToBack()
window.actionButtons:moveToFront()
updateRecentColorsButtons()
if options.o or options.open and args[1] and filesystem.exists(args[1]) then
if (options.o or options.open) and args[1] and filesystem.exists(args[1]) then
loadImage(args[1])
else
newNoGUI(51, 19)
end
window:resize(window.width, window.height)
onToolTouch(5)
workspace:start()

View File

@ -1,12 +1,14 @@
local GUI = require("GUI")
local screen = require("screen")
local image = require("image")
local tool = {}
local screen = require("Screen")
local image = require("Image")
------------------------------------------------------
tool.shortcut = "Se"
local workspace, window, menu = select(1, ...), select(2, ...), select(3, ...)
local tool = {}
tool.shortcut = "Slc"
tool.keyCode = 50
tool.about = "Selection tool allows you to select preferred area on image and to perform some operations on it. Green dots mean start and end points (for example, it needs to line rasterization)"
@ -19,117 +21,118 @@ local rasterizeEllipseButton = GUI.roundedButton(1, 1, 36, 1, 0xE1E1E1, 0x2D2D2D
local clearButton = GUI.roundedButton(1, 1, 36, 1, 0x696969, 0xE1E1E1, 0x2D2D2D, 0xE1E1E1, "Clear")
local cropButton = GUI.roundedButton(1, 1, 36, 1, 0x696969, 0xE1E1E1, 0x2D2D2D, 0xE1E1E1, "Crop")
local function repositionSelector(workspace)
local function repositionSelector()
if dragX - touchX >= 0 then
selector.localX, selector.width = touchX, dragX - touchX + 1
selector.localX, selector.width = touchX - window.x + 1, dragX - touchX + 1
else
selector.localX, selector.width = dragX, touchX - dragX + 1
selector.localX, selector.width = dragX - window.x + 1, touchX - dragX + 1
end
if dragY - touchY >= 0 then
selector.localY, selector.height = touchY, dragY - touchY + 1
selector.localY, selector.height = touchY - window.y + 1, dragY - touchY + 1
else
selector.localY, selector.height = dragY, touchY - dragY + 1
selector.localY, selector.height = dragY - window.y + 1, touchY - dragY + 1
end
workspace:draw()
end
local function fitSelector(workspace)
touchX, touchY, dragX, dragY = workspace.image.localX, workspace.image.localY, workspace.image.localX + workspace.image.width - 1, workspace.image.localY + workspace.image.height - 1
repositionSelector(workspace)
local function fitSelector()
touchX, touchY, dragX, dragY = window.image.x, window.image.y, window.image.x + window.image.width - 1, window.image.y + window.image.height - 1
repositionSelector()
end
tool.onSelection = function(workspace)
workspace.currentToolLayout:addChild(fillButton).onTouch = function()
tool.onSelection = function()
window.currentToolLayout:addChild(fillButton).onTouch = function()
for j = selector.y, selector.y + selector.height - 1 do
for i = selector.x, selector.x + selector.width - 1 do
image.set(workspace.image.data, i - workspace.image.x + 1, j - workspace.image.y + 1, workspace.primaryColorSelector.color, 0x0, 0, " ")
image.set(window.image.data, i - window.image.x + 1, j - window.image.y + 1, window.primaryColorSelector.color, 0x0, 0, " ")
end
end
workspace:draw()
end
workspace.currentToolLayout:addChild(outlineButton).onTouch = function()
local x1, y1 = selector.x - workspace.image.x + 1, selector.y - workspace.image.y + 1
window.currentToolLayout:addChild(outlineButton).onTouch = function()
local x1, y1 = selector.x - window.image.x + 1, selector.y - window.image.y + 1
local x2, y2 = x1 + selector.width - 1, y1 + selector.height - 1
for x = x1, x2 do
image.set(workspace.image.data, x, y1, workspace.primaryColorSelector.color, 0x0, 0, " ")
image.set(workspace.image.data, x, y2, workspace.primaryColorSelector.color, 0x0, 0, " ")
image.set(window.image.data, x, y1, window.primaryColorSelector.color, 0x0, 0, " ")
image.set(window.image.data, x, y2, window.primaryColorSelector.color, 0x0, 0, " ")
end
for y = y1 + 1, y2 - 1 do
image.set(workspace.image.data, x1, y, workspace.primaryColorSelector.color, 0x0, 0, " ")
image.set(workspace.image.data, x2, y, workspace.primaryColorSelector.color, 0x0, 0, " ")
image.set(window.image.data, x1, y, window.primaryColorSelector.color, 0x0, 0, " ")
image.set(window.image.data, x2, y, window.primaryColorSelector.color, 0x0, 0, " ")
end
workspace:draw()
end
workspace.currentToolLayout:addChild(rasterizeLineButton).onTouch = function()
window.currentToolLayout:addChild(rasterizeLineButton).onTouch = function()
screen.rasterizeLine(
touchX - workspace.image.x + 1,
touchY - workspace.image.y + 1,
dragX - workspace.image.x + 1,
dragY - workspace.image.y + 1,
touchX - window.image.x + 1,
touchY - window.image.y + 1,
dragX - window.image.x + 1,
dragY - window.image.y + 1,
function(x, y)
image.set(workspace.image.data, x, y, workspace.primaryColorSelector.color, 0x0, 0, " ")
image.set(window.image.data, x, y, window.primaryColorSelector.color, 0x0, 0, " ")
end
)
workspace:draw()
end
workspace.currentToolLayout:addChild(rasterizeEllipseButton).onTouch = function()
window.currentToolLayout:addChild(rasterizeEllipseButton).onTouch = function()
local minX, minY, maxX, maxY = math.min(touchX, dragX), math.min(touchY, dragY), math.max(touchX, dragX), math.max(touchY, dragY)
local centerX, centerY = math.ceil(minX + (maxX - minX) / 2), math.ceil(minY + (maxY - minY) / 2)
screen.rasterizeEllipse(
centerX - workspace.image.x + 1,
centerY - workspace.image.y + 1,
centerX - window.image.x + 1,
centerY - window.image.y + 1,
maxX - centerX,
maxY - centerY,
function(x, y)
image.set(workspace.image.data, x, y, workspace.primaryColorSelector.color, 0x0, 0, " ")
image.set(window.image.data, x, y, window.primaryColorSelector.color, 0x0, 0, " ")
end
)
workspace:draw()
end
workspace.currentToolLayout:addChild(clearButton).onTouch = function()
window.currentToolLayout:addChild(clearButton).onTouch = function()
for j = selector.y, selector.y + selector.height - 1 do
for i = selector.x, selector.x + selector.width - 1 do
image.set(workspace.image.data, i - workspace.image.x + 1, j - workspace.image.y + 1, 0x0, 0x0, 1, " ")
image.set(window.image.data, i - window.image.x + 1, j - window.image.y + 1, 0x0, 0x0, 1, " ")
end
end
workspace:draw()
end
workspace.currentToolLayout:addChild(cropButton).onTouch = function()
workspace.image.data = image.crop(workspace.image.data, selector.x - workspace.image.x + 1, selector.y - workspace.image.y + 1, selector.width, selector.height)
workspace.image.reposition()
fitSelector(workspace)
window.currentToolLayout:addChild(cropButton).onTouch = function()
window.image.data = image.crop(window.image.data, selector.x - window.image.x + 1, selector.y - window.image.y + 1, selector.width, selector.height)
window.image.reposition()
fitSelector()
end
workspace.currentToolOverlay:addChild(selector)
fitSelector(workspace)
window.currentToolOverlay:addChild(selector)
fitSelector()
end
tool.eventHandler = function(workspace, object, e1, e2, e3, e4)
if e1 == "touch" then
touchX, touchY, dragX, dragY = e3, e4, e3, e4
repositionSelector(workspace)
repositionSelector()
elseif e1 == "drag" then
dragX, dragY = e3, e4
repositionSelector(workspace)
repositionSelector()
end
end
selector.eventHandler = tool.eventHandler
selector.draw = function()
local step = true
for x = selector.x + 1, selector.x + selector.width - 2 do

View File

@ -1,10 +1,12 @@
local image = require("image")
local tool = {}
local image = require("Image")
------------------------------------------------------
tool.shortcut = "Mv"
local workspace, window, menu = select(1, ...), select(2, ...), select(3, ...)
local tool = {}
tool.shortcut = "Mov"
tool.keyCode = 47
tool.about = "Move tool allows you to move image as you wish. But be careful: large images will take a time to shift and redraw. Hello, shitty GPUs!"
@ -13,8 +15,8 @@ tool.eventHandler = function(workspace, object, e1, e2, e3, e4)
if e1 == "touch" then
xOld, yOld = e3, e4
elseif e1 == "drag" and xOld and yOld then
workspace.image.localX = workspace.image.localX + (e3 - xOld)
workspace.image.localY = workspace.image.localY + (e4 - yOld)
window.image.localX = window.image.localX + (e3 - xOld)
window.image.localY = window.image.localY + (e4 - yOld)
xOld, yOld = e3, e4
workspace:draw()

View File

@ -1,11 +1,13 @@
local GUI = require("GUI")
local image = require("image")
local tool = {}
local image = require("Image")
------------------------------------------------------
tool.shortcut = "Re"
local workspace, window, menu = select(1, ...), select(2, ...), select(3, ...)
local tool = {}
tool.shortcut = "Rsz"
tool.keyCode = 46
tool.about = "Resizer tool allows to change picture size in real time. You can specify preffered direction, input width and height modifiers and smart script will do the rest."
@ -16,8 +18,8 @@ local buttonsLayout = GUI.layout(1, 1, buttonsContainer.width, buttonsContainer.
buttonsLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
buttonsLayout:addChild(buttonsContainer)
local widthInput = GUI.input(1, 1, 1, 1, 0x2D2D2D, 0xC3C3C3, 0x5A5A5A, 0x2D2D2D, 0xD2D2D2, "", "Width")
local heightInput = GUI.input(1, 1, 1, 1, 0x2D2D2D, 0xC3C3C3, 0x5A5A5A, 0x2D2D2D, 0xD2D2D2, "", "Height")
local widthInput = GUI.input(1, 1, 1, 1, 0x1E1E1E, 0xC3C3C3, 0x5A5A5A, 0x1E1E1E, 0xD2D2D2, "", "Width")
local heightInput = GUI.input(1, 1, 1, 1, 0x1E1E1E, 0xC3C3C3, 0x5A5A5A, 0x1E1E1E, 0xD2D2D2, "", "Height")
local expandButton = GUI.roundedButton(1, 1, 36, 1, 0x696969, 0xE1E1E1, 0x2D2D2D, 0xE1E1E1, "Expand")
local cropButton = GUI.roundedButton(1, 1, 36, 1, 0x696969, 0xE1E1E1, 0x2D2D2D, 0xE1E1E1, "Crop")
@ -52,7 +54,7 @@ end
for j = 1, buttonCount do
buttons[j] = {}
for i = 1, buttonCount do
buttons[j][i] = buttonsContainer:addChild(GUI.button(x, y, buttonWidth, buttonHeight, 0x2D2D2D, 0xB4B4B4, 0x696969, 0xD2D2D2, " "))
buttons[j][i] = buttonsContainer:addChild(GUI.button(x, y, buttonWidth, buttonHeight, 0x3C3C3C, 0xB4B4B4, 0x696969, 0xD2D2D2, " "))
buttons[j][i].onTouch = function()
set(i, j)
buttons[j][i].firstParent:draw()
@ -66,12 +68,12 @@ end
set(2, 2)
tool.onSelection = function(workspace)
workspace.currentToolLayout:addChild(buttonsLayout)
workspace.currentToolLayout:addChild(widthInput)
workspace.currentToolLayout:addChild(heightInput)
workspace.currentToolLayout:addChild(expandButton)
workspace.currentToolLayout:addChild(cropButton)
tool.onSelection = function()
window.currentToolLayout:addChild(buttonsLayout)
window.currentToolLayout:addChild(widthInput)
window.currentToolLayout:addChild(heightInput)
window.currentToolLayout:addChild(expandButton)
window.currentToolLayout:addChild(cropButton)
widthInput.onInputFinished = function()
expandButton.disabled = not widthInput.text:match("^%d+$") or not heightInput.text:match("^%d+$")
@ -85,28 +87,28 @@ tool.onSelection = function(workspace)
expandButton.onTouch = function()
local width, height = tonumber(widthInput.text), tonumber(heightInput.text)
workspace.image.data = image.expand(workspace.image.data,
window.image.data = image.expand(window.image.data,
currentY > 1 and height or 0,
currentY < 3 and height or 0,
currentX > 1 and width or 0,
currentX < 3 and width or 0,
0x0, 0x0, 1, " ")
workspace.image.reposition()
window.image.reposition()
workspace:draw()
end
cropButton.onTouch = function()
local width, height = tonumber(widthInput.text), tonumber(heightInput.text)
workspace.image.data = image.crop(workspace.image.data,
window.image.data = image.crop(window.image.data,
currentX == 1 and 1 or width + 1,
currentY == 1 and 1 or height + 1,
(currentX == 1 or currentX == 3) and workspace.image.width - width or workspace.image.width - width * 2,
(currentY == 1 or currentY == 3) and workspace.image.height - height or workspace.image.height - height * 2
(currentX == 1 or currentX == 3) and window.image.width - width or window.image.width - width * 2,
(currentY == 1 or currentY == 3) and window.image.height - height or window.image.height - height * 2
)
workspace.image.reposition()
window.image.reposition()
workspace:draw()
end
end

View File

@ -1,34 +1,36 @@
local image = require("image")
local image = require("Image")
local GUI = require("GUI")
local tool = {}
------------------------------------------------------
tool.shortcut = "Pi"
local workspace, window, menu = select(1, ...), select(2, ...), select(3, ...)
local tool = {}
tool.shortcut = "Pck"
tool.keyCode = 56
tool.about = "Picker tool allows to select interested data from image as primary or secondary color. You can configure of what colors to pick."
local pickBackgroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Pick background:", true)
local pickForegroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Pick foreground:", true)
local pickBackgroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Pick background:", true)
local pickForegroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Pick foreground:", true)
tool.onSelection = function(workspace)
workspace.currentToolLayout:addChild(pickBackgroundSwitch)
workspace.currentToolLayout:addChild(pickForegroundSwitch)
tool.onSelection = function()
window.currentToolLayout:addChild(pickBackgroundSwitch)
window.currentToolLayout:addChild(pickForegroundSwitch)
end
tool.eventHandler = function(workspace, object, e1, e2, e3, e4)
if e1 == "touch" or e1 == "drag" then
local x, y = e3 - workspace.image.x + 1, e4 - workspace.image.y + 1
local x, y = e3 - window.image.x + 1, e4 - window.image.y + 1
local background, foreground = image.get(workspace.image.data, x, y)
local background, foreground = image.get(window.image.data, x, y)
if pickBackgroundSwitch.switch.state then
workspace.secondaryColorSelector.color = background
window.secondaryColorSelector.color = background
end
if pickForegroundSwitch.switch.state then
workspace.primaryColorSelector.color = foreground
window.primaryColorSelector.color = foreground
end
workspace:draw()

View File

@ -1,51 +1,56 @@
local image = require("image")
local image = require("Image")
local GUI = require("GUI")
local keyboard = require("keyboard")
local tool = {}
local keyboard = require("Keyboard")
------------------------------------------------------
tool.shortcut = "Bs"
local workspace, window, menu = select(1, ...), select(2, ...), select(3, ...)
local tool = {}
tool.shortcut = "Brs"
tool.keyCode = 48
tool.about = "Classic brush tool to perform drawing with specified radius and transparency. You can configure of what data will be drawn. Also you can specify preferred symbol to draw with, otherwise whitespace will be used."
local backgroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Draw background:", true)
local foregroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Draw foreground:", true)
local alphaSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Draw alpha:", true)
local symbolSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Draw symbol:", true)
local symbolInput = GUI.input(1, 1, width, 1, 0x2D2D2D, 0xC3C3C3, 0x5A5A5A, 0x2D2D2D, 0xD2D2D2, "", "Symbol to draw with")
local backgroundSwitch = GUI.switchAndLabel(1, 1, 1, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Draw background:", true)
local foregroundSwitch = GUI.switchAndLabel(1, 1, 1, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Draw foreground:", true)
local alphaSwitch = GUI.switchAndLabel(1, 1, 1, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Draw alpha:", true)
local symbolSwitch = GUI.switchAndLabel(1, 1, 1, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Draw symbol:", true)
local symbolInput = GUI.input(1, 1, 1, 1, 0x1E1E1E, 0xC3C3C3, 0x5A5A5A, 0x1E1E1E, 0xD2D2D2, "", "Symbol to draw with")
symbolInput.onInputFinished = function()
symbolInput.text = unicode.sub(symbolInput.text, 1, 1)
end
local alphaSlider = GUI.slider(1, 1, width, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 0, 255, 0, false, "Alpha value: ", "")
local alphaSlider = GUI.slider(1, 1, 1, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, 0, 255, 0, false, "Alpha value: ", "")
alphaSlider.roundValues = true
local radiusSlider = GUI.slider(1, 1, width, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 1, 8, 1, false, "Radius: ", " px")
local radiusSlider = GUI.slider(1, 1, 1, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, 1, 8, 1, false, "Radius: ", " px")
radiusSlider.height = 2
radiusSlider.roundValues = true
tool.onSelection = function(workspace)
workspace.currentToolLayout:addChild(backgroundSwitch)
workspace.currentToolLayout:addChild(foregroundSwitch)
workspace.currentToolLayout:addChild(alphaSwitch)
workspace.currentToolLayout:addChild(symbolSwitch)
workspace.currentToolLayout:addChild(symbolInput)
workspace.currentToolLayout:addChild(alphaSlider)
workspace.currentToolLayout:addChild(radiusSlider)
tool.onSelection = function()
window.currentToolLayout:addChild(backgroundSwitch)
window.currentToolLayout:addChild(foregroundSwitch)
window.currentToolLayout:addChild(alphaSwitch)
window.currentToolLayout:addChild(symbolSwitch)
window.currentToolLayout:addChild(symbolInput)
window.currentToolLayout:addChild(alphaSlider)
window.currentToolLayout:addChild(radiusSlider)
end
tool.eventHandler = function(workspace, object, e1, e2, e3, e4)
if e1 == "touch" or e1 == "drag" then
local x, y = e3 - workspace.image.x + 1, e4 - workspace.image.y + 1
local x, y = e3 - window.image.x + 1, e4 - window.image.y + 1
local meow = math.floor(radiusSlider.value)
for j = y - meow + 1, y + meow - 1 do
for i = x - meow + 1, x + meow - 1 do
if i >= 1 and i <= workspace.image.width and j >= 1 and j <= workspace.image.height then
local background, foreground, alpha, symbol = image.get(workspace.image.data, i, j)
image.set(workspace.image.data, i, j,
backgroundSwitch.switch.state and workspace.primaryColorSelector.color or background,
foregroundSwitch.switch.state and workspace.secondaryColorSelector.color or foreground,
if i >= 1 and i <= window.image.width and j >= 1 and j <= window.image.height then
local background, foreground, alpha, symbol = image.get(window.image.data, i, j)
image.set(window.image.data, i, j,
backgroundSwitch.switch.state and window.primaryColorSelector.color or background,
foregroundSwitch.switch.state and window.secondaryColorSelector.color or foreground,
alphaSwitch.switch.state and alphaSlider.value / 255 or alpha,
symbolSwitch.switch.state and (symbolInput.text == "" and " " or symbolInput.text) or symbol
)

View File

@ -1,40 +1,42 @@
local GUI = require("GUI")
local image = require("image")
local tool = {}
local image = require("Image")
------------------------------------------------------
tool.shortcut = "Er"
local workspace, window, menu = select(1, ...), select(2, ...), select(3, ...)
local tool = {}
tool.shortcut = "Ers"
tool.keyCode = 18
tool.about = "Eraser tool will cleanup pixels just like brush tool. You can configure of what data is need to be erased"
local backgroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Erase background:", true)
local foregroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Erase foreground:", true)
local alphaSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Erase alpha:", true)
local symbolSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Erase symbol:", true)
local radiusSlider = GUI.slider(1, 1, 1, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 1, 8, 1, false, "Radius: ", " px")
local backgroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Erase background:", true)
local foregroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Erase foreground:", true)
local alphaSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Erase alpha:", true)
local symbolSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, "Erase symbol:", true)
local radiusSlider = GUI.slider(1, 1, 1, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x878787, 1, 8, 1, false, "Radius: ", " px")
radiusSlider.height = 2
radiusSlider.roundValues = true
tool.onSelection = function(workspace)
workspace.currentToolLayout:addChild(backgroundSwitch)
workspace.currentToolLayout:addChild(foregroundSwitch)
workspace.currentToolLayout:addChild(alphaSwitch)
workspace.currentToolLayout:addChild(symbolSwitch)
workspace.currentToolLayout:addChild(radiusSlider)
tool.onSelection = function()
window.currentToolLayout:addChild(backgroundSwitch)
window.currentToolLayout:addChild(foregroundSwitch)
window.currentToolLayout:addChild(alphaSwitch)
window.currentToolLayout:addChild(symbolSwitch)
window.currentToolLayout:addChild(radiusSlider)
end
tool.eventHandler = function(workspace, object, e1, e2, e3, e4)
if e1 == "touch" or e1 == "drag" then
local x, y = e3 - workspace.image.x + 1, e4 - workspace.image.y + 1
local x, y = e3 - window.image.x + 1, e4 - window.image.y + 1
local meow = math.floor(radiusSlider.value)
for j = y - meow + 1, y + meow - 1 do
for i = x - meow + 1, x + meow - 1 do
if i >= 1 and i <= workspace.image.width and j >= 1 and j <= workspace.image.height then
local background, foreground, alpha, symbol = image.get(workspace.image.data, i, j)
image.set(workspace.image.data, i, j,
if i >= 1 and i <= window.image.width and j >= 1 and j <= window.image.height then
local background, foreground, alpha, symbol = image.get(window.image.data, i, j)
image.set(window.image.data, i, j,
backgroundSwitch.switch.state and 0x0 or background,
foregroundSwitch.switch.state and 0x0 or foreground,
alphaSwitch.switch.state and 1 or alpha,

View File

@ -1,11 +1,13 @@
local image = require("image")
local image = require("Image")
local GUI = require("GUI")
local tool = {}
------------------------------------------------------
tool.shortcut = "Tx"
local workspace, window, menu = select(1, ...), select(2, ...), select(3, ...)
local tool = {}
tool.shortcut = "Txt"
tool.keyCode = 20
tool.about = "Text tool allows you to type some text data with selected primary color right on your image! It's time to say \"ur mom gay\" to everyone <3"
@ -14,23 +16,23 @@ tool.eventHandler = function(workspace, object, e1, e2, e3, e4)
local input = workspace:addChild(GUI.input(
e3 - 1,
e4,
workspace.image.x + workspace.image.width - e3 + 2,
window.image.x + window.image.width - e3 + 2,
1,
nil,
workspace.primaryColorSelector.color,
workspace.primaryColorSelector.color,
window.primaryColorSelector.color,
window.primaryColorSelector.color,
nil,
workspace.primaryColorSelector.color,
window.primaryColorSelector.color,
""
))
input.onInputFinished = function()
if #input.text > 0 then
local x, y = e3 - workspace.image.x + 1, e4 - workspace.image.y + 1
local x, y = e3 - window.image.x + 1, e4 - window.image.y + 1
for i = 1, unicode.len(input.text) do
if x <= workspace.image.width then
local background, foreground, alpha = image.get(workspace.image.data, x, y)
image.set(workspace.image.data, x, y, background, workspace.primaryColorSelector.color, alpha, unicode.sub(input.text, i, i))
if x <= window.image.width then
local background, foreground, alpha = image.get(window.image.data, x, y)
image.set(window.image.data, x, y, background, window.primaryColorSelector.color, alpha, unicode.sub(input.text, i, i))
x = x + 1
else
break

View File

@ -1,10 +1,12 @@
local image = require("image")
local tool = {}
local image = require("Image")
------------------------------------------------------
tool.shortcut = "Fl"
local workspace, window, menu = select(1, ...), select(2, ...), select(3, ...)
local tool = {}
tool.shortcut = "Fil"
tool.keyCode = 34
tool.about = "Fill tool allows you to automatically fill areas with selected primary color just like in Paint. Oh God, where is my RAM...?"
@ -31,9 +33,9 @@ end
tool.eventHandler = function(workspace, object, e1, e2, e3, e4)
if e1 == "touch" then
local x, y = e3 - workspace.image.x + 1, e4 - workspace.image.y + 1
local sourceB, sourceF, sourceA, sourceS = image.get(workspace.image.data, x, y)
pizda(x, y, workspace.image.data, sourceB, sourceF, sourceA, sourceS, workspace.primaryColorSelector.color, 0x0, 0, " ")
local x, y = e3 - window.image.x + 1, e4 - window.image.y + 1
local sourceB, sourceF, sourceA, sourceS = image.get(window.image.data, x, y)
pizda(x, y, window.image.data, sourceB, sourceF, sourceA, sourceS, window.primaryColorSelector.color, 0x0, 0, " ")
workspace:draw()
end

View File

@ -1,12 +1,14 @@
local image = require("image")
local image = require("Image")
local GUI = require("GUI")
local text = require("text")
local tool = {}
local text = require("Text")
------------------------------------------------------
tool.shortcut = "Br"
local workspace, window, menu = select(1, ...), select(2, ...), select(3, ...)
local tool = {}
tool.shortcut = "Bra"
tool.keyCode = 33
tool.about = "Braille tool allows you to draw pixels with Braille symbols on your image. Select preferred mini-pixels via menu above, configure transparency affecting and \"Let's go fellas!\""
@ -33,19 +35,19 @@ end
local backgroundSwitch = GUI.switchAndLabel(1, 1, 1, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Draw background:", false)
tool.onSelection = function(workspace)
workspace.currentToolLayout:addChild(layout)
workspace.currentToolLayout:addChild(backgroundSwitch)
tool.onSelection = function()
window.currentToolLayout:addChild(layout)
window.currentToolLayout:addChild(backgroundSwitch)
end
tool.eventHandler = function(workspace, object, e1, e2, e3, e4)
if e1 == "touch" or e1 == "drag" then
local x, y = e3 - workspace.image.x + 1, e4 - workspace.image.y + 1
local background, foreground, alpha, symbol = image.get(workspace.image.data, x, y)
local x, y = e3 - window.image.x + 1, e4 - window.image.y + 1
local background, foreground, alpha, symbol = image.get(window.image.data, x, y)
image.set(workspace.image.data, x, y,
backgroundSwitch.switch.state and workspace.secondaryColorSelector.color or background,
workspace.primaryColorSelector.color,
image.set(window.image.data, x, y,
backgroundSwitch.switch.state and window.secondaryColorSelector.color or background,
window.primaryColorSelector.color,
backgroundSwitch.switch.state and 0 or alpha,
char
)