Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function lerp(a, b, t)
- return a + (b-a)*t
- end
- width, height = term.getSize()
- midw = math.floor(width/2)
- midh = math.floor(height/2)
- p0 = vector.new(1, 1, 0)
- p2 = vector.new(width, height, 0)
- function quad_bezier(p0, p1, p2, step)
- local oldx = p0.x
- local oldy = p0.y
- for t=0, 1, step do
- local x1 = lerp(p0.x, p1.x, t)
- local y1 = lerp(p0.y, p1.y, t)
- local x2 = lerp(p1.x, p2.x, t)
- local y2 = lerp(p1.y, p2.y, t)
- local x = lerp(x1, x2, t)
- local y = lerp(y1, y2, t)
- paintutils.drawLine(oldx, oldy, x, y, colors.white)
- oldx = x
- oldy = y
- end
- end
- while true do
- local p1 = vector.new(1, height, 0)
- local event, button, x, y = os.pullEvent("mouse_drag")
- term.setBackgroundColor(colors.black)
- term.clear()
- p1.x, p1.y = x, y
- quad_bezier(p0, p1, p2, 0.2)
- end
- -- paintutils.drawLine(p0.x, p0.y, p1.x, p1.y, colors.white)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement