-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathintersect.lua
More file actions
36 lines (29 loc) · 766 Bytes
/
intersect.lua
File metadata and controls
36 lines (29 loc) · 766 Bytes
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
local soluna = require "soluna"
local quad = require "soluna.material.quad"
local args = ...
local batch = args.batch
local callback = {}
local mx = 0
local my = 0
function callback.mouse_move(x, y)
mx, my = x, y
end
function callback.frame(count)
local rad = count * math.pi / 180
-- scale x2, move to the center of screen
batch:layer(2, args.width / 2, args.height / 2)
-- rotate canvas
batch:layer(rad)
-- use (-50, -50) , center of quad (100,100) as original point
batch:layer(-50, -50)
local x, y = batch:point(mx, my)
local color = 0xffffff
if x >=0 and x < 100 and y >=0 and y < 100 then
color = 0xff0000
end
batch:add(quad.quad(100,100,color))
batch:layer()
batch:layer()
batch:layer()
end
return callback