Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Paint by Laine_prikol
- local component = require("component")
- local event = require("event")
- local term = require("term")
- local gpu = component.gpu
- local gpic = require("gpic")
- local computer = require("computer")
- local filesystem = require("filesystem")
- local args = {...}
- fillscroll = 1
- color = 0
- fill = "█"
- timer = 5
- colorcustom = 0
- function redrawAll()
- term.clear()
- term.setCursor(1,1)
- print("[S] [C] [+] FILL [-] [+] Color [-] [O] [N]")
- end
- redrawAll()
- -- Таймер
- function offtext()
- timer = timer - 1
- if timer == 1 then
- gpu.set(1,25, " ") -- Не понял как сделать очистку строки (term.clearLine() не работает)
- end
- if timer == 0 then
- timer = 0
- end
- end
- function fillswitch(zalivka, scroll, filltypetext)
- if fillscroll == scroll then
- fill = zalivka
- gpu.set(1, 25, filltypetext)
- timer = 5
- end
- end
- function colorswitch(colornum, colorscroll, colortext)
- if color == colorscroll then -- White
- gpu.setForeground(colornum)
- gpu.set(63, 1, colortext)
- end
- end
- function checkFill()
- gpu.set(1, 1, "[S] [C] [+] FILL [-] [+] Color [-] [O] [N]")
- gpu.set(1, 25, "Fill type: Standard ")
- timer = 5
- fillswitch("█", 1, "Fill type: Standard ")
- fillswitch("#", 2, "Fill type: Hash ")
- fillswitch("@", 3, "Fill type: Circle1 ")
- fillswitch(".", 4, "Fill type: Dot ")
- fillswitch(":", 5, "Fill type: Dots ")
- fillswitch(" ", 6, "Fill type: Eraser ")
- fillswitch("●", 7, "Fill type: Circle2 ")
- fillswitch("░", 8, "Fill type: Semi-Transparent ")
- if fillscroll == 9 then
- local file = io.open("customFills.cfg", "r")
- fill = file:read("*a")
- gpu.set(1, 25, "Fill type: Custom (create file customFills.cfg) ")
- timer = 5
- file:close()
- end
- if fillscroll == 10 then
- local file1 = io.open("customFills1.cfg", "r")
- fill = file1:read("*a")
- gpu.set(1, 25, "Fill type: Custom1 (create file customFills1.cfg) ")
- timer = 5
- file1:close()
- end
- end
- function checkColor()
- gpu.setForeground(0xffffff)
- gpu.set(1, 1, "[S] [C] [+] FILL [-] [+] Color [-] [O] [N]")
- colorswitch(0xffffff, 0, "Color: whilte ")
- colorswitch(0xff0000, 1, "Color: Red ")
- colorswitch(0x2fff00, 2, "Color: Green ")
- colorswitch(0x0011ff, 3, "Color: Blue ")
- colorswitch(0xf0ff00, 4, "Color: Yellow ")
- colorswitch(0x898989, 5, "Color: Grey ")
- colorswitch(0xff9191, 6, "Color: Light red ")
- colorswitch(0xfd00ff, 7, "Color: Purple ")
- colorswitch(0xFF1493, 8, "Color: Pink ")
- colorswitch(0x0b6503, 9, "Color: Dark green ")
- colorswitch(0x0b6503, 10, "Color: Turquoise ")
- colorswitch(0x00dfff, 11, "Color: Light blue ")
- if color == 12 then -- Custom 1
- local file2 = io.open("colors1.cfg", "r")
- colorcustom = file2:read("*a")
- gpu.setForeground(colorcustom)
- gpu.set(63, 1, "Color: Custom(Create colors1.cfg) ")
- file2:close()
- end
- if color == 13 then -- Custom 2
- local file3 = io.open("colors2.cfg", "r")
- colorcustom = file3:read("*a")
- gpu.setForeground(colorcustom)
- gpu.set(63, 1, "Color: Custom(Create colors2.cfg) ")
- file3:close()
- end
- if color == 14 then -- Custom 3
- local file4 = io.open("colors3.cfg", "r")
- colorcustom = file4:read("*a")
- gpu.setForeground(colorcustom)
- gpu.set(63, 1, "Color: Custom(Create colors3.cfg) ")
- file4:close()
- end
- end
- while true do
- -- Чтение пикселей
- local id, _, x, y = event.pullMultiple("touch", "drag")
- if id == "touch" then
- gpu.set(x, y, fill)
- checkColor()
- offtext()
- end
- if id == "drag" then
- gpu.set(x, y, fill)
- checkColor()
- offtext()
- end
- if x == 6 and y == 1 then -- Выход
- term.clear()
- os.exit()
- end
- if x == 10 and y == 1 then -- Прогрутка типов заливки
- fillscroll = fillscroll + 1
- checkFill()
- if fillscroll == 8 then
- fillscroll = 8 -- Это чтобы переменная не ушла сильно в плюс (Не понял как сделать по-другому)
- checkFill()
- end
- end
- if x == 19 and y == 1 then -- Прогрутка типов заливки
- fillscroll = fillscroll - 1
- checkFill()
- if fillscroll == 0 then
- fillscroll = 1 -- Это чтобы переменная не ушла в минус (Не понял как сделать по-другому)
- checkFill()
- end
- end
- if x == 2 and y == 1 then -- Сохранение
- local picture = gpic.new(1, 2, args[2], args[3])
- gpic.write(picture,args[1])
- computer.beep(880, 0.5)
- end
- if x == 37 and y == 1 then -- Загрузка
- local image = gpic.read(args[1])
- gpic.draw(1, 2, image)
- computer.beep(500, 0.5)
- end
- if x == 23 and y == 1 then -- Прогрутка цветов
- color = color + 1
- checkColor()
- if color == 14 then
- color = 14 -- Это чтобы переменная не ушла сильно в плюс (Не понял как сделать по-другому)
- checkFill()
- end
- end
- if x == 33 and y == 1 then -- Прогрутка цветов
- color = color - 1
- checkFill()
- if color == 0 then
- color = 0 -- Это чтобы переменная не ушла в минус (Не понял как сделать по-другому)
- checkColor()
- end
- end
- if x == 41 and y == 1 then -- Новый файл
- term.clear()
- redrawAll()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement