blob: 895688d1681618ec6a6c5c080bf59095ee6700f8 (
plain) (
blame)
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
|
package gui
// TODO: add font-size-relative units once a text rendering package is added.
// Length allows distance or size to be expressed in absolute or relative units.
type Length interface {
// Px resolves the Length to pixels for the given parent Env's size in pixels.
Px(parent int) int
}
// Px is a Length expressed in pixels.
type Px int
// Px implements the Length interface.
func (p Px) Px(parent int) int { return int(p) }
// Relative is a Length relative to the width or height of the parent Env.
//
// Relative(0.10) <=> 10%.
type Relative float64
// Px implements the Length interface.
func (r Relative) Px(parent int) int {
return int(float64(r) * float64(parent))
}
|