-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
59 lines (51 loc) · 1.99 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
-- local patchy = require "patchy"
local slicy = require "slicy"
local SCALE = 4
local CANVASW = 160
local CANVASH = 120
local WINDOWW = CANVASW * SCALE
local WINDOWH = CANVASH * SCALE
local SPEED = 30
local pane
local width, height
local canvas
local lipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
local keys = {
right = function(dt) width = width + SPEED * dt end,
left = function(dt) width = width - SPEED * dt end,
up = function(dt) height = height - SPEED * dt end,
down = function(dt) height = height + SPEED * dt end
}
function love.load()
love.graphics.setDefaultFilter("nearest", "nearest")
love.window.setMode(WINDOWW, WINDOWH, {})
-- pane = patchy.load("Pane.9.png")
pane = slicy.load("Pane.9.png")
canvas = love.graphics.newCanvas(CANVASW, CANVASH)
width = 100
height = 100
end
function love.update(dt)
for key, f in pairs(keys) do
if love.keyboard.isDown(key) then
f(dt)
end
end
pane:resize(math.floor(width), math.floor(height))
end
function love.keypressed(k)
if k == "space" then
slicy.setDebug{draw = not slicy.isDebugDrawing()}
end
end
function love.draw()
love.graphics.setCanvas(canvas)
love.graphics.clear()
pane:draw(10, 10)
local cx, cy, cw, ch = pane:getContentWindow()
love.graphics.setScissor(cx, cy, cw, ch)
love.graphics.printf(lipsum, cx, cy, cw, "justify")
love.graphics.setScissor()
love.graphics.setCanvas()
love.graphics.draw(canvas, 0, 0, 0, SCALE, SCALE)
end