Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require('component')
- local event = require('event')
- local gpu = component.gpu
- local color = 0xFF0000
- local tSize = {gpu.getResolution()}
- local function line(x0, y0, x1, y1)
- local dx = x1 - x0
- local dy = y1 - y0
- local d = 2 * dy - dx
- set_pixel(x0, y0)
- y = y0
- for x = x0, x1 do
- if d > 0 then
- y = y + 1
- set_pixel(x, y)
- d = d + (2 * dy - 2 * dx)
- else
- set_pixel(x, y)
- d = d + (2 * dy)
- end
- end
- end
- local function circle(x0, y0, radius)
- local x = radius
- local y = 0
- local d = 1 - x
- while x >= y do
- set_pixel(x + x0, y + y0)
- set_pixel(y + x0, x + y0)
- set_pixel(-x + x0, y + y0)
- set_pixel(-y + x0, x + y0)
- set_pixel(-x + x0, -y + y0)
- set_pixel(-y + x0, -x + y0)
- set_pixel(x + x0, -y + y0)
- set_pixel(y + x0, -x + y0)
- y = y + 1
- if d <= 0 then
- d = 2 * y + 1
- else
- x = x - 1
- d = 2 * (y - x) + 1
- end
- end
- end
- local function box(x0, y0, x1, y1)
- for x = x0, x1 do
- for y = y0, y1 do
- set_pixel(x, y)
- end
- end
- end
- local function clear()
- gpu.setBackground(0x000000)
- gpu.setForeground(0x000000)
- gpu.fill(1, 1, tSize[1], tSize[2], ' ')
- end
- local function fill_1()
- local fg, bg = 0x000000, 0x222222
- for x = 1, tSize[1], 2 do
- for y = 1, tSize[2] do
- gpu.setBackground(bg)
- gpu.setForeground(fg)
- gpu.set(x, y, '▄')
- gpu.setBackground(fg)
- gpu.setForeground(bg)
- gpu.set(x+1, y, '▄')
- end
- end
- end
- clear()
- while 1 do
- local e = {event.pull()}
- if e[1] == 'touch' or e[1] == 'drag' or e[1] == 'drop' then
- local pixel = {gpu.get(e[3], e[4])}
- if e[5] == 0 then
- gpu.setForeground(color)
- gpu.setBackground(pixel[3])
- gpu.set(e[3], e[4], '▄')
- elseif e[5] == 1 then
- gpu.setForeground(pixel[2])
- gpu.setBackground(color)
- gpu.set(e[3], e[4], '▄')
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement