-
Notifications
You must be signed in to change notification settings - Fork 0
/
dimension.go
65 lines (54 loc) · 1.46 KB
/
dimension.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
package callisto
type Dimension interface {
GetDimension() (width float64, height float64)
GetWidth() float64
GetHeight() float64
SetHeight(height float64)
SetWidth(width float64)
SetDimension(width float64, height float64)
SetDimensionDelta(width float64, height float64)
GetWeight() float64
SetWeight(weight float64)
CalculationDimension(parent Element)
}
type ElementDimension struct {
Width float64
Height float64
Weight float64
ParentRelativeScaleWidth float64
ParentRelativeScaleHeight float64
ParentRelativeDeltaWidth float64
ParentRelativeDeltaHeight float64
UserParentRelative bool
}
func (e *ElementDimension) GetWeight() float64 {
return e.Weight
}
func (e *ElementDimension) SetWeight(weight float64) {
e.Weight = weight
}
func (e *ElementDimension) GetDimension() (float64, float64) {
return e.Width, e.Height
}
func (e *ElementDimension) GetWidth() float64 {
width, _ := e.GetDimension()
return width
}
func (e *ElementDimension) GetHeight() float64 {
_, height := e.GetDimension()
return height
}
func (e *ElementDimension) SetHeight(height float64) {
e.Height = height
}
func (e *ElementDimension) SetWidth(width float64) {
e.Width = width
}
func (e *ElementDimension) SetDimension(width float64, height float64) {
e.SetWidth(width)
e.SetHeight(height)
}
func (e *ElementDimension) SetDimensionDelta(width float64, height float64) {
e.Width += width
e.Height += height
}