类型 Rect

API 文档由 Go 源码生成,内容为英文。

type Rect struct {
	X      float32
	Y      float32
	Width  float32
	Height float32
}

Rect is a logical-pixel rectangle measured from the top-left.

方法

Bottom#

func (r Rect) Bottom() float32

Bottom returns the y coordinate of the rectangle's bottom edge.

Centered#

func (r Rect) Centered(width, height float32) Rect

Centered returns a rectangle of the given size centered in r. A size larger than r overflows evenly on both sides.

CutBottom#

func (r Rect) CutBottom(height float32) (strip, rest Rect)

CutBottom splits r into a strip of the given height along its bottom edge and the rest above it.

CutLeft#

func (r Rect) CutLeft(width float32) (strip, rest Rect)

CutLeft splits r into a strip of the given width along its left edge and the rest to its right.

CutRight#

func (r Rect) CutRight(width float32) (strip, rest Rect)

CutRight splits r into a strip of the given width along its right edge and the rest to its left.

CutTop#

func (r Rect) CutTop(height float32) (strip, rest Rect)

CutTop splits r into a strip of the given height along its top edge and the rest below it. A height past r's own is clamped, so the strip never leaves r and the rest is empty rather than negative.

header, body := bounds.CutTop(48)
body = body.Inset(ui.All(16))

Inset#

func (r Rect) Inset(insets Insets) Rect

Inset shrinks the rectangle by the insets on each edge.

Offset#

func (r Rect) Offset(dx, dy float32) Rect

Offset moves the rectangle by dx and dy without changing its size.

Right#

func (r Rect) Right() float32

Right returns the x coordinate of the rectangle's right edge.