-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example_-_image copy.lua
45 lines (41 loc) · 1.15 KB
/
Example_-_image copy.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
-- Image Copy
-- Use this function to perform your initial setup
function setup()
print("Hello World!")
-- create a global image
im = image(100,100)
-- set to draw into image
setContext(im)
-- fill and stroke color
fill(145)
stroke(236, 197, 6)
-- draw a rectangle bottom left in image
rect(1,1,10,10)
-- create a local image and copy left bottom from image im
local ti = im:copy(1,1,10,10)
-- the origin of a sprite(image) is bottom left.
spriteMode(CORNER)
-- draw our local image into our global image
for y=0,100,10 do
for x=0,100,10 do
sprite(ti,x,y)
end
end
-- restore context so we draw to the main canvas
setContext()
-- restore spritemode to draw as center as origin
spriteMode(CENTER)
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(40, 40, 50)
-- This sets the line thickness
strokeWidth(5)
-- draw our global image im to the center of the screen scaled
pushMatrix()
translate(WIDTH/2,HEIGHT/2)
scale(2.5,2.5)
sprite(im,0,0)
popMatrix()
end