geom
import "github.com/tangoui/tango/ui/geom"本页由
site/tools/apigen从源码注释生成(按 darwin 构建标签选文件),请勿手改。
Package geom holds the small geometry vocabulary shared by every layer of the Tango self-drawn UI (layout, paint, text, input). All values are in logical pixels unless a doc comment says otherwise; renderers multiply by the window scale factor at the very end.
变量
var Inf = float32(math.Inf(1))Inf is a convenient "unbounded" length.
函数
func IsInf
func IsInf(v float32) boolIsInf reports whether v is +Inf.
类型
Affine
type Affine struct{ A, B, C, D, E, F float32 }Affine is a 2-D affine transform in the usual
| A C E |
| B D F |
| 0 0 1 |
layout: a point (x, y) maps to (A·x + C·y + E, B·x + D·y + F). The zero value is degenerate; start from Identity or one of the constructors. Angles are radians, positive turns clockwise (y grows downwards).
func Identity
func Identity() AffineIdentity is the transform that changes nothing.
func Rotate
func Rotate(angle float64) AffineRotate rotates by angle radians (clockwise on screen) about the origin.
func RotateAround
func RotateAround(angle float64, c Point) AffineRotateAround rotates by angle radians about c.
func Scale
func Scale(sx, sy float32) AffineScale scales about the origin.
func ScaleAround
func ScaleAround(sx, sy float32, c Point) AffineScaleAround scales by (sx, sy) keeping c fixed.
func Skew
func Skew(ax, ay float64) AffineSkew shears by the given angles (radians): x' = x + tan(ax)·y and y' = y + tan(ay)·x, like CSS skew().
func Translate
func Translate(dx, dy float32) AffineTranslate moves by (dx, dy).
func (Affine) Apply
func (m Affine) Apply(p Point) PointApply maps p.
func (Affine) AxisAligned
func (m Affine) AxisAligned() boolAxisAligned reports whether m only scales (by positive factors) and translates, so rectangles stay rectangles with the same orientation.
func (Affine) Bounds
func (m Affine) Bounds(r Rect) RectBounds returns the axis-aligned bounding box of r after m.
func (Affine) Det
func (m Affine) Det() float32Det is the determinant (area scale factor, negative when mirrored).
func (Affine) Invert
func (m Affine) Invert() (Affine, bool)Invert returns the inverse transform; ok is false when m is singular.
func (Affine) IsIdentity
func (m Affine) IsIdentity() boolIsIdentity reports whether m changes nothing.
func (Affine) MaxScale
func (m Affine) MaxScale() float32MaxScale is the largest factor by which m stretches a length.
func (Affine) Mul
func (m Affine) Mul(n Affine) AffineMul returns the matrix product m·n: the result applies n first, then m.
func (Affine) Then
func (m Affine) Then(n Affine) AffineThen returns the transform that applies m first, then n.
Insets
type Insets struct{ Top, Right, Bottom, Left float32 }Insets are per-edge distances, CSS order.
func All
func All(v float32) InsetsAll returns equal insets on every edge.
func VH
func VH(v, h float32) InsetsVH returns CSS two-value insets: vertical, horizontal.
func (Insets) Add
func (i Insets) Add(o Insets) InsetsAdd sums two insets.
func (Insets) Horizontal
func (i Insets) Horizontal() float32Horizontal returns Left+Right.
func (Insets) Vertical
func (i Insets) Vertical() float32Vertical returns Top+Bottom.
Point
type Point struct{ X, Y float32 }Point is a position in logical pixels.
func Pt
func Pt(x, y float32) PointPt is shorthand for Point{x, y}.
func (Point) Add
func (p Point) Add(q Point) PointAdd returns p+q.
func (Point) Sub
func (p Point) Sub(q Point) PointSub returns p-q.
Radii
type Radii struct{ TL, TR, BR, BL float32 }Radii are per-corner radii: top-left, top-right, bottom-right, bottom-left.
func Rad
func Rad(r float32) RadiiRad returns equal radii.
func (Radii) Clamp
func (r Radii) Clamp(w, h float32) RadiiClamp limits each radius so it fits in a w×h box.
func (Radii) Grow
func (r Radii) Grow(d float32) RadiiGrow adds d to every non-negative radius (used for outlines/shadows).
func (Radii) IsZero
func (r Radii) IsZero() boolIsZero reports whether all radii are zero.
Rect
type Rect struct{ X, Y, W, H float32 }Rect is an axis-aligned rectangle given by origin and size.
func R
func R(x, y, w, h float32) RectR is shorthand for Rect{x, y, w, h}.
func (Rect) Bottom
func (r Rect) Bottom() float32Bottom returns Y+H.
func (Rect) Center
func (r Rect) Center() PointCenter returns the center point.
func (Rect) Contains
func (r Rect) Contains(p Point) boolContains reports whether p lies inside r (half-open on the far edges).
func (Rect) Empty
func (r Rect) Empty() boolEmpty reports whether the rectangle has no area.
func (Rect) Expand
func (r Rect) Expand(d float32) RectExpand grows r by d on every side (negative d shrinks).
func (Rect) Inset
func (r Rect) Inset(in Insets) RectInset shrinks r by the insets. The result never has negative size.
func (Rect) Intersect
func (r Rect) Intersect(s Rect) RectIntersect returns the overlap of r and s (zero Rect when disjoint).
func (Rect) Min
func (r Rect) Min() PointMin returns the top-left corner.
func (Rect) Offset
func (r Rect) Offset(dx, dy float32) RectOffset translates r.
func (Rect) Right
func (r Rect) Right() float32Right returns X+W.
func (Rect) Size
func (r Rect) Size() SizeSize returns the rectangle size.
func (Rect) Union
func (r Rect) Union(s Rect) RectUnion returns the smallest rectangle containing r and s. Empty operands are ignored.
Size
type Size struct{ W, H float32 }Size is a width/height pair.