forked from signintech/gopdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rect.go
37 lines (30 loc) · 836 Bytes
/
rect.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
package gopdf
type Rect struct {
W float64
H float64
unitOverride int
}
// PointsToUnits converts the rectanlges width and height to Units. When this is called it is assumed the values of the rectangle are in Points
func (rect *Rect) PointsToUnits(t int) (r *Rect) {
if rect == nil {
return
}
if rect.unitOverride != Unit_Unset {
t = rect.unitOverride
}
r = &Rect{W: rect.W, H: rect.H}
PointsToUnitsVar(t, &r.W, &r.H)
return
}
// UnitsToPoints converts the rectanlges width and height to Points. When this is called it is assumed the values of the rectangle are in Units
func (rect *Rect) UnitsToPoints(t int) (r *Rect) {
if rect == nil {
return
}
if rect.unitOverride != Unit_Unset {
t = rect.unitOverride
}
r = &Rect{W: rect.W, H: rect.H}
UnitsToPointsVar(t, &r.W, &r.H)
return
}