forked from signintech/gopdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
box.go
46 lines (39 loc) · 955 Bytes
/
box.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
package gopdf
type Box struct {
Left, Top, Right, Bottom float64
unitOverride defaultUnitConfig
}
// UnitsToPoints converts the box coordinates to Points. When this is called it is assumed the values of the box are in Units
func (box *Box) UnitsToPoints(t int) (b *Box) {
if box == nil {
return
}
unitCfg := defaultUnitConfig{Unit: t}
if box.unitOverride.getUnit() != UnitUnset {
unitCfg = box.unitOverride
}
b = &Box{
Left: box.Left,
Top: box.Top,
Right: box.Right,
Bottom: box.Bottom,
}
unitsToPointsVar(unitCfg, &b.Left, &b.Top, &b.Right, &b.Bottom)
return
}
func (box *Box) unitsToPoints(unitCfg unitConfigurator) (b *Box) {
if box == nil {
return
}
if box.unitOverride.getUnit() != UnitUnset {
unitCfg = box.unitOverride
}
b = &Box{
Left: box.Left,
Top: box.Top,
Right: box.Right,
Bottom: box.Bottom,
}
unitsToPointsVar(unitCfg, &b.Left, &b.Top, &b.Right, &b.Bottom)
return
}