PixelGrid
A themed grid background for canvases and artboards.
Loading the live example…
import (
"github.com/egoist/mygo/ui"
"github.com/oneo-me/onevra/source/components"
)
type canvas struct{}
func (canvas) View(c *ui.Context) {
t := c.Theme()
components.PixelGrid(c, components.PixelGridOptions{Spacing: 20, MajorEvery: 5}).Fill().Children(func() {
ui.Column(c).Fill().Center().Gap(t.Space(2)).Children(func() {
ui.Column(c).Padding(t.Space(4)).Gap(t.Space(1)).Radius(t.Radius*1.5).
Background(t.Surface).Border(1, t.Border).Children(func() {
components.Text(c, "Artboard").Bold()
components.Text(c, "Children draw above the grid.").TextColor(t.TextMuted)
})
})
})
}PixelGrid draws one-point lines in the theme's colors, with every few lines emphasized. Children draw above it and are clipped to its bounds. It takes no input.
API
PixelGrid
func PixelGrid(c *ui.Context, options PixelGridOptions) ui.ElementPixelGrid creates a themed, noninteractive square-line background container. Set its size with the returned element's layout methods. Children render above the grid and are clipped to its bounds. Background can override the canvas color; grid lines use the frame theme and are one DIP wide. Lines coinciding with the top or left edge are omitted so the grid has no leading border.
pkg.go.devPixelGridOptions
PixelGridOptions configures a canvas grid in device-independent pixels. The grid origin is fixed at the container's top-left corner; changing Spacing changes the cell size without transforming children.
Prop
Type