Documentation
¶
Overview ¶
Package ninepatch implements 9-Patch image rendering in Gio. https://developer.android.com/guide/topics/graphics/drawables#nine-patch
Index ¶
Constants ¶
const DefaultScale = 1 / float32(160.0/72.0)
DefaultScale is a standard 72 DPI. Inverse of `widget.Image`, shrink as the screen becomes _less_ dense.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type D ¶
type D = layout.Dimensions
type Grid ¶
type Grid struct { // Size specifies the total dimensions including static and stretch regions. Size image.Point // X1 is the distance in pixels before the stretchable region along the X axis. // X2 is the distance in pixels after the stretchable region along the X axis. X1, X2 int // Y1 is the distance in pixels before the stretchable region along the Y axis. // Y2 is the distance in pixels after the stretchable region along the Y axis. Y1, Y2 int }
Grid describes the stretchable regions of a 9-Patch as 3x3 grid divided by 4 lines.
type NinePatch ¶
type NinePatch struct { // Image is the backing image of the 9-Patch. image.Image // Grid describes the stretchable regions of the 9-Patch. Grid Grid // Inset describes content insets defined by the black lines on the bottom // and right of the 9-Patch image. Content PxInset // contains filtered or unexported fields }
NinePatch can lay out a 9-Patch image as the background for another widget.
Note: create a new instance per 9-Patch image. Changing the image.Image after the first layout will have no effect because the paint.ImageOp is cached.
func DecodeNinePatch ¶
DecodeNinePatch from source image.
Note: Any colored pixel around the border will be considered a 9-Patch marker.
type PxInset ¶
type PxInset struct {
Top, Bottom, Left, Right int
}
PxInset describes an inset in pixels.