This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFloatRect.go
69 lines (55 loc) · 1.48 KB
/
FloatRect.go
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
60
61
62
63
64
65
66
67
68
69
package hebiten
import (
"github.com/hajimehoshi/ebiten"
)
type TFloatRect struct {
X, Y, W, H float64
}
func (this *TFloatRect) GetLT() BigFloat2 {
return BigFloat2{this.X, this.Y}
}
func (this *TFloatRect) SetLeftTopPoint(a BigFloat2) {
this.X = a.X
this.Y = a.Y
}
func (this *TFloatRect) GetRT() BigFloat2 {
return BigFloat2{this.GetRight(), this.Y}
}
func (this *TFloatRect) GetLB() BigFloat2 {
return BigFloat2{this.X, this.GetBottom()}
}
func (this *TFloatRect) GetRB() BigFloat2 {
return BigFloat2{this.GetRight(), this.GetBottom()}
}
func (this *TFloatRect) GetPoints() BigFloat2s {
return []BigFloat2{this.GetLT(), this.GetRT(), this.GetLB(), this.GetRB()}
}
func (this *TFloatRect) GetRight() float64 {
return this.X + this.W
}
func (this *TFloatRect) GetBottom() float64 {
return this.Y + this.H
}
func (this *TFloatRect) CheckContainsPoint(point BigFloat2) bool {
return this.X < point.X && point.X < this.GetRight() &&
this.Y < point.Y && point.Y < this.GetBottom()
}
func (this *TFloatRect) LoadImage(image *ebiten.Image) *TFloatRect {
this.X = 0
this.Y = 0
var w, h = image.Size()
this.W = float64(w)
this.H = float64(h)
return this
}
func (this *TFloatRect) GetEnlarged(delta float64) TFloatRect {
return TFloatRect{
X: this.X - delta,
Y: this.Y - delta,
W: this.W + 2*delta,
H: this.H + 2*delta,
}
}
func (this *TFloatRect) GetSize() BigFloat2 {
return BigFloat2{X: this.W, Y: this.H}
}