类型 IconTransform

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

type IconTransform struct {
	// Rotate turns the icon clockwise, in radians, about the center of its box.
	Rotate float32
	// Scale grows the glyph, stroke included, about the center of its box. Zero
	// is 1; a negative value mirrors it.
	Scale float32
	// Offset moves the icon in logical pixels after the rotation and scale: x to
	// the right and y down.
	Offset Point
	// Parts move single contours of the glyph before the transform above, so a
	// part's offset travels with the glyph when it grows. Listing a part that
	// does not move costs nothing: the glyph is drawn whole until one of them
	// does.
	//
	// A part is what one contour of the source is — a lock's shackle, a
	// keyboard's keys — so parts allow a glyph's pieces to move relative to each
	// other while it stays one icon in the layout.
	Parts []IconPart
	// Reveal writes the glyph on from its right edge instead of painting it
	// whole: Reveal is the fraction written so far, one being all of it, and the
	// rest is clipped away. Zero is the whole glyph, like the zero of every other
	// field here, so a motion that writes a glyph on runs from just above zero to
	// one and ends on the still icon.
	//
	// The cut is made at the icon's box, on whole device pixels, so a glyph that
	// turns or grows out of that box is clipped with it.
	Reveal float32
}

IconTransform moves a painted icon away from the box it was laid out in: scale and rotation about the center of that box, then an offset. The zero value is the icon exactly where the layout put it, so a still frame and the end of a motion paint the same pixels.

The glyph is drawn on whole device pixels (see DrawIcon), so a rotation that does not finish on a right angle leaves it off that grid: motion that turns an icon should end at the still icon, and only a glyph that is symmetric under the angle it turns through stays crisp while it turns.