Documentation
¶
Overview ¶
Package client is the client library for writing looking-glass WASM modules.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arc ¶
type Arc struct {
XMLName xml.Name `xml:"arc"`
Cx float32 `xml:"cx,attr"`
Cy float32 `xml:"cy,attr"`
Radius float32 `xml:"radius,attr"`
StartAngle float32 `xml:"startAngle,attr"` // degrees; 0 = right, clockwise
SweepAngle float32 `xml:"sweepAngle,attr"` // degrees; clockwise positive
StrokeWidth float32 `xml:"strokeWidth,attr"`
Color string `xml:"color,attr"`
}
Arc draws a circular arc stroke.
type Canvas ¶
type Canvas struct {
XMLName xml.Name `xml:"canvas"`
Width float32 `xml:"-"`
Height float32 `xml:"-"`
Ops []DrawOp `xml:"-"`
}
Canvas renders draw operations within a fixed-size logical viewport scaled to fit the allocated space.
func NewCanvas ¶
NewCanvas returns a Canvas widget with the given logical size and ordered draw list.
func (*Canvas) Equals ¶
Equals checks the logical equality of two Canvas widgets, ignoring differences that don't affect rendering such as the order of draw operations with identical parameters.
func (*Canvas) MarshalXML ¶
MarshalXML implements xml.Marshaler.
func (*Canvas) UnmarshalXML ¶
UnmarshalXML decodes the Canvas element, its width/height attributes, and DrawOp children.
type Column ¶
type Column struct {
XMLName xml.Name `xml:"column"`
MinWidth float32 `xml:"minWidth,attr,omitempty"`
Child Widget `xml:"-"`
}
Column is a cell within a Row, holding a single child widget.
func (*Column) MarshalXML ¶
MarshalXML implements xml.Marshaler.
func (*Column) UnmarshalXML ¶
UnmarshalXML decodes the Column element, its minWidth attribute, and its single Widget child.
type DrawOp ¶
type DrawOp interface {
// contains filtered or unexported methods
}
DrawOp is a drawing command within a Canvas.
type HStack ¶
HStack lays out children horizontally, left to right.
func (*HStack) MarshalXML ¶
MarshalXML implements xml.Marshaler.
func (*HStack) UnmarshalXML ¶
UnmarshalXML decodes the HStack element and its Widget children.
type Label ¶
type Label struct {
XMLName xml.Name `xml:"label"`
X float32 `xml:"x,attr"`
Y float32 `xml:"y,attr"`
Align string `xml:"align,attr,omitempty"` // "start", "middle", or "end"
Runs []*TextRun `xml:"run"`
}
Label draws baseline-aligned multi-run text at a canvas position.
type Path ¶
type Path struct {
XMLName xml.Name `xml:"path"`
X float32 `xml:"x,attr,omitempty"`
Y float32 `xml:"y,attr,omitempty"`
Scale float32 `xml:"scale,attr,omitempty"`
D string `xml:"d,attr"`
Fill string `xml:"fill,attr,omitempty"`
}
Path draws an SVG path d-string at an offset with optional uniform scale.
type Rect ¶
type Rect struct {
XMLName xml.Name `xml:"rect"`
X float32 `xml:"x,attr"`
Y float32 `xml:"y,attr"`
W float32 `xml:"w,attr"`
H float32 `xml:"h,attr"`
CornerRadius float32 `xml:"cornerRadius,attr,omitempty"`
Fill string `xml:"fill,attr,omitempty"`
Stroke string `xml:"stroke,attr,omitempty"`
StrokeWidth float32 `xml:"strokeWidth,attr,omitempty"`
}
Rect draws a filled and/or stroked rectangle.
func NewRect ¶
func NewRect(x, y, w, h float32, opts ...RectOption) *Rect
NewRect returns a Rect draw operation.
type RectOption ¶
type RectOption func(*Rect)
RectOption configures a Rect draw operation.
func WithCornerRadius ¶
func WithCornerRadius(cr float32) RectOption
WithCornerRadius sets the corner radius for a rounded rectangle.
func WithStroke ¶
func WithStroke(c string, w float32) RectOption
WithStroke sets the rectangle stroke colour and width.
type Row ¶
Row is a horizontal sequence of Column cells within a Table.
func (*Row) MarshalXML ¶
MarshalXML implements xml.Marshaler.
func (*Row) UnmarshalXML ¶
UnmarshalXML decodes the Row element and its Column children.
type RunOption ¶
type RunOption func(*TextRun)
RunOption configures a TextRun within a Label.
func WithRunBaselineShift ¶
WithRunBaselineShift shifts the run down from the shared baseline in canvas units.
func WithRunColor ¶
WithRunColor sets the run text colour as an HTML hex string.
func WithRunFontSize ¶
WithRunFontSize sets the run font size in canvas units.
type Spacer ¶
Spacer inserts flexible empty space inside a stack.
func NewSpacer ¶
func NewSpacer(opts ...SpacerOption) *Spacer
NewSpacer returns a Spacer that expands to fill available space with a default minimum size of 8 dp.
type SpacerOption ¶
type SpacerOption func(*Spacer)
SpacerOption configures a Spacer widget.
func WithMinSize ¶
func WithMinSize(minSize float32) SpacerOption
WithMinSize sets the minimum size in dp that the spacer occupies along its primary axis.
type Table ¶
type Table struct {
XMLName xml.Name `xml:"table"`
RowSpacing float32 `xml:"rowSpacing,attr,omitempty"`
Rows []*Row `xml:"-"`
}
Table lays out Row children vertically, automatically sizing each column to the widest natural width across all rows.
func NewTable ¶
func NewTable(rows []*Row, opts ...TableOption) *Table
NewTable returns a Table containing the given Row children.
func (*Table) MarshalXML ¶
MarshalXML implements xml.Marshaler.
func (*Table) UnmarshalXML ¶
UnmarshalXML decodes the Table element and its Row children.
type TableOption ¶
type TableOption func(*Table)
TableOption configures a Table widget.
func WithRowSpacing ¶
func WithRowSpacing(dp float32) TableOption
WithRowSpacing sets the vertical gap in dp between rows.
type Text ¶
type Text struct {
XMLName xml.Name `xml:"text"`
Content string `xml:",chardata"`
Color string `xml:"color,attr,omitempty"`
FontSize float32 `xml:"fontSize,attr,omitempty"`
Condensed bool `xml:"condensed,attr,omitempty"`
Light bool `xml:"light,attr,omitempty"`
Bold bool `xml:"bold,attr,omitempty"`
Italic bool `xml:"italic,attr,omitempty"`
Align string `xml:"align,attr,omitempty"`
}
Text renders a single styled line of text.
func NewText ¶
func NewText(content string, opts ...TextOption) *Text
NewText returns a Text widget with the given content and optional style options.
type TextOption ¶
type TextOption func(*Text)
TextOption configures a Text widget.
func WithAlign ¶
func WithAlign(a string) TextOption
WithAlign sets the text alignment: "left", "center", or "right".
func WithColor ¶
func WithColor(c string) TextOption
WithColor sets the text colour as an HTML hex string, e.g. "#ffffff".
func WithCondensed ¶
func WithCondensed() TextOption
WithCondensed selects the Roboto Condensed typeface variant.
type TextRun ¶
type TextRun struct {
XMLName xml.Name `xml:"run"`
Content string `xml:",chardata"`
FontSize float32 `xml:"fontSize,attr,omitempty"`
BaselineShift float32 `xml:"baselineShift,attr,omitempty"`
Color string `xml:"color,attr,omitempty"`
}
TextRun is a single styled text segment within a Label.
type VStack ¶
VStack lays out children vertically, top to bottom.
func (*VStack) MarshalXML ¶
MarshalXML implements xml.Marshaler.
func (*VStack) UnmarshalXML ¶
UnmarshalXML decodes the VStack element and its Widget children.
type Widget ¶
type Widget interface {
// contains filtered or unexported methods
}
Widget is a node in a widget tree passed to Module.Content.
func DecodeWidget ¶
DecodeWidget decodes an XML-encoded Widget from b. The root element tag determines the concrete Widget type. Unknown root tags return an error; unknown child tags are silently skipped.