blob: e7f29c6e06d703a566f17429155a3f12ef6ffd2e (
plain)
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
|
local Rect = GameLab.GlobalClass("GameLab.Engine.Math.Rect")
Rect.Ctor = function(self, x, y, width, height)
self.x = x or 0
self.y = y or 0
self.width = width or 0
self.height = height or 0
end
Rect.Set = function(self, rect)
if rect._type and rect._type.fullName == "GameLab.Engine.Math.Rect" then
self.x = rect.x or rect.x
self.y = rect.y or rect.y
self.width = rect.z or rect.width
self.height = rect.w or rect.height
else
self.x = rect.x or rect[1]
self.y = rect.y or rect[2]
self.width = rect.z or rect[3]
self.height = rect.w or rect[4]
end
end
Rect.GetPosition = function(self)
local v = GameLab.Engine.Math.Vector2(self.x, self.y)
return v
end
Rect.GetSize = function(self)
local v = GameLab.Engine.Math.Vector2(self.width, self.height)
return v
end
Rect.CopyFrom = function(self, rect)
self.x = rect.x
self.y = rect.y
self.width = rect.width
self.height = rect.height
end
Rect.Contains = function(self, point)
return point.x >= self.x and point.x <= self.x + self.width
and point.y >= self.y and point.y <= self.y + self.height
end
return Rect
|