layout

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 4 Imported by: 0

README

layout

CI Go Version

layout is a simple, backend-agnostic graphical layout framework for Go.

Module path: github.com/dmundt/layout

It provides:

  • Core layout data structures (Document, Page, Element)
  • Primitive elements (Box, Line, Text, Image)
  • Reusable elements (Group, Repeat, TemplateInstance) for repeatable structures
  • Template parameters with defaults and required keys
  • Page sections (Header, Footer) and automatic pagination text
  • Layout helper APIs (GridPositions, Align, AlignCenterInRect)
  • Styling primitives (FillStyle, StrokeStyle, colors)
  • Capability probing (layout.Supports(renderer, feature))
  • Multiple rendering backends:
    • HTML (SVG-based)
    • SVG
    • Canvas (HTML5 Canvas + JavaScript)
    • PDF
    • PNG

Directory Structure

.
├── README.md
├── LICENSE.md
├── .gitignore
├── go.mod
├── *.go                 # Core library types and rendering interface
├── backend
│   ├── html
│   │   └── renderer.go
│   ├── svg
│   │   └── renderer.go
│   ├── canvas
│   │   └── renderer.go
│   ├── pdf
│   │   └── renderer.go
│   └── png
│       └── renderer.go
├── cmd
│   └── layoutdemo
│       └── main.go
└── examples
    ├── common
    │   └── documents.go
    ├── html
    │   └── main.go
    ├── svg
    │   └── main.go
    ├── canvas
    │   └── main.go
    ├── labels
    │   └── main.go
    ├── png
    │   └── main.go
    └── pdf
        └── main.go

Install

go get github.com/dmundt/layout

Quick Start

package main

import (
    "fmt"
    "os"

    htmlbackend "github.com/dmundt/layout/backend/html"
    "github.com/dmundt/layout"
)

func main() {
    page := layout.Page{Size: layout.Size{Width: 600, Height: 400}}

    box := layout.NewBox("box-1", layout.Rect{X: 40, Y: 40, Width: 220, Height: 120})
    box.Style.Fill.Color = layout.ColorBlue
    box.Style.Stroke.Color = layout.ColorBlack
    box.Style.Stroke.Width = 2
    box.Style.CornerRadius = 8

    line := layout.NewLine("line-1", layout.Point{X: 40, Y: 40}, layout.Point{X: 260, Y: 160})
    line.Style.Stroke.Color = layout.ColorRed
    line.Style.Stroke.Width = 3
    line.Style.Stroke.Dash = []float64{10, 5}

    page.AddElement(box)
    page.AddElement(line)

    doc := layout.NewDocument()
    doc.AddPage(page)

    output, err := layout.Render(doc, htmlbackend.New())
    if err != nil {
        panic(err)
    }

    if err := os.WriteFile("layout.html", output, 0o644); err != nil {
        panic(err)
    }

    fmt.Println("wrote layout.html")
}

Backends

Use a backend-specific renderer with layout.Render:

  • html.New() from github.com/dmundt/layout/backend/html — render an HTML document containing SVG per page.
  • svg.New() from github.com/dmundt/layout/backend/svg — render raw SVG document bytes.
  • canvas.New() from github.com/dmundt/layout/backend/canvas — render an HTML document containing <canvas> and draw scripts.
  • pdf.New() from github.com/dmundt/layout/backend/pdf — render raw PDF bytes.
  • png.New() from github.com/dmundt/layout/backend/png — render PNG image bytes (multi-page docs are stacked vertically).

Example:

renderer := htmlbackend.New()
if layout.Supports(renderer, layout.FeatureDash) {
    // Use dashed strokes.
}

Use feature constants such as FeatureBox, FeatureLine, FeatureText, FeatureImage, FeatureInsets, FeatureBorder, FeatureDash, FeatureCornerRadius, FeatureTemplates, and FeatureDeterministicIDs.

Demo CLI

Example:

go run ./cmd/layoutdemo -backend svg -scenario labels
go run ./cmd/layoutdemo -backend pdf -scenario labels -out out/labels.pdf

Examples

Runnable examples are provided in:

  • examples/canvas
  • examples/html
  • examples/labels
  • examples/pdf
  • examples/png
  • examples/svg

Examples are consolidated via shared builders in examples/common to keep each main.go minimal.

Example:

go run ./examples/html

Run all examples:

go run ./examples/canvas
go run ./examples/html
go run ./examples/labels
go run ./examples/pdf
go run ./examples/png
go run ./examples/svg

Each example writes output into the project root:

  • example-canvas.html
  • example.html
  • example-labels.html
  • example.pdf
  • example.png
  • example.svg

Example:

page := layout.Page{Size: layout.Size{Width: 600, Height: 400}}
page.AddHeaderElement(layout.NewText("hdr", layout.Point{X: 20, Y: 20}, "Report {{page}}/{{total}}"))
page.AddFooterElement(layout.NewText("ftr", layout.Point{X: 20, Y: 390}, "Confidential"))

page.Pagination = layout.DefaultPagination()
page.Pagination.Enabled = true
page.Pagination.Position = layout.Point{X: 580, Y: 390}
page.Pagination.Style.Align = layout.TextAlignRight

The placeholders {{page}} and {{total}} are resolved per page during render expansion.

Testing

Example:

go test ./...

Golden snapshots and benchmarks:

go test ./... -run TestGoldenOutputs
go test ./... -run TestGoldenOutputs -update
go test ./... -bench .

Notes

  • Use Render to validate the document before backend rendering.
  • Use reusable Group, Repeat, and TemplateInstance elements to expand structures before backend rendering.
  • Use TemplateInstance with layout.Parameters for {{key}} placeholder substitution.
  • Use Template.WithDefaults(...) and Template.WithRequired(...) to define parameter behavior.
  • Use typed layout.Parameters values (map[string]any); string substitution uses fmt.Sprint.
  • Use layout.RenderWithOptions(..., layout.RenderOptions{DeterministicIDs: true}) for stable auto IDs.
  • Use backend-agnostic floating point values for all dimensions.
  • Use points (pt) as the unit for PDF output.

License

This project is licensed under the MIT License. See LICENSE.md.

Documentation

Overview

Package layout provides a backend-agnostic graphical layout framework.

The package models layout data as a Document composed of Pages and Elements, and renders them via pluggable backends.

Supported element primitives include:

  • Box
  • Line
  • Text
  • Image

Reusable layout structures are supported via:

  • Group
  • Repeat
  • TemplateInstance (with {{key}} parameter substitution)

Template defaults and required parameters are supported through:

  • Template.WithDefaults(...)
  • Template.WithRequired(...)

Render via Render or RenderWithOptions using a backend renderer, for example html, svg, canvas, pdf, or png implementations in backend/*.

Example:

output, err := layout.RenderWithOptions(doc, renderer, layout.RenderOptions{DeterministicIDs: true})
_ = output
_ = err

Index

Constants

This section is empty.

Variables

View Source
var (
	// ColorBlack is opaque black.
	ColorBlack = Color{R: 0, G: 0, B: 0, A: 255}
	// ColorWhite is opaque white.
	ColorWhite = Color{R: 255, G: 255, B: 255, A: 255}
	// ColorRed is opaque red.
	ColorRed = Color{R: 255, G: 0, B: 0, A: 255}
	// ColorGreen is opaque green.
	ColorGreen = Color{R: 0, G: 255, B: 0, A: 255}
	// ColorBlue is opaque blue.
	ColorBlue = Color{R: 0, G: 0, B: 255, A: 255}
)

Functions

func ApplyParameters

func ApplyParameters(text string, parameters Parameters) string

ApplyParameters replaces placeholders in text with parameter values.

Example:

text := layout.ApplyParameters("Hello {{name}}", layout.Parameters{"name": "Ada"})
// text == "Hello Ada"

func Render

func Render(doc Document, renderer Renderer) ([]byte, error)

Render validates and renders a document with the given renderer.

It is equivalent to RenderWithOptions(doc, renderer, RenderOptions{}).

func RenderWithOptions

func RenderWithOptions(doc Document, renderer Renderer, options RenderOptions) ([]byte, error)

RenderWithOptions validates and renders a document with explicit render options.

Reusable elements are expanded before backend rendering. Header/footer/pagination sections are merged into the page element stream during expansion.

func ResourceKey

func ResourceKey(image Image) string

ResourceKey returns a stable key for image/resource deduplication.

If image.ID is set, the key is "<id>:<mime>". Otherwise the key is based on a SHA-1 hash of image bytes and MIME type.

Example:

key := layout.ResourceKey(image)

func Supports

func Supports(renderer Renderer, feature Feature) bool

Supports reports whether a renderer supports a feature.

Example:

renderer := htmlbackend.New()
if layout.Supports(renderer, layout.FeatureDash) {
	// configure dashed strokes
}

Types

type Backend

type Backend string

Backend identifies a rendering backend.

const (
	BackendPDF    Backend = "pdf"
	BackendHTML   Backend = "html"
	BackendCanvas Backend = "canvas"
	BackendPNG    Backend = "png"
	BackendSVG    Backend = "svg"
)

type Box

type Box struct {
	ID    string
	Rect  Rect
	Style BoxStyle
}

Box represents a rectangular layout primitive.

func NewBox

func NewBox(id string, rect Rect) Box

NewBox creates a Box with DefaultBoxStyle.

Example:

box := layout.NewBox("hero", layout.Rect{X: 20, Y: 20, Width: 300, Height: 160})
box.Style.CornerRadius = 8

func (Box) InnerRect

func (b Box) InnerRect() Rect

InnerRect returns the rectangle after applying the box insets.

func (Box) Type

func (b Box) Type() ElementType

Type returns the element type.

func (Box) Validate

func (b Box) Validate() error

Validate validates the box.

type BoxStyle

type BoxStyle struct {
	Fill         FillStyle
	Stroke       StrokeStyle
	Insets       Insets
	CornerRadius float64
}

BoxStyle configures visual style for a Box.

func DefaultBoxStyle

func DefaultBoxStyle() BoxStyle

DefaultBoxStyle returns the default style for boxes.

Defaults: white fill, black 1px stroke.

type CapabilityProvider

type CapabilityProvider interface {
	Capabilities() []Feature
}

CapabilityProvider can declare supported backend features.

type Color

type Color struct {
	R uint8
	G uint8
	B uint8
	A uint8
}

Color stores an RGBA color.

Example:

color := layout.Color{R: 255, G: 0, B: 0, A: 255}

func (Color) CSSRGBA

func (c Color) CSSRGBA() string

CSSRGBA formats the color as a CSS rgba() string.

Example:

s := layout.ColorRed.CSSRGBA()
// s == "rgba(255,0,0,1.0000)"

type Document

type Document struct {
	Pages []Page
}

Document is a collection of pages.

func NewDocument

func NewDocument() Document

NewDocument returns an empty document.

Example:

doc := layout.NewDocument()
doc.AddPage(layout.Page{Size: layout.Size{Width: 600, Height: 400}})

func (*Document) AddPage

func (d *Document) AddPage(page Page)

AddPage appends a page to the document.

func (Document) Validate

func (d Document) Validate() error

Validate validates all pages in the document.

A valid document must contain at least one page and each page must validate.

type Element

type Element interface {
	Type() ElementType
	Validate() error
}

Element is the backend-agnostic layout element interface.

Implementations include Box, Line, Text, Image and reusable types in reusable.go.

func ExpandElements

func ExpandElements(elements []Element) ([]Element, error)

ExpandElements flattens reusable elements into concrete primitives.

Group, Repeat, and TemplateInstance are recursively expanded.

func ExpandElementsWithOptions

func ExpandElementsWithOptions(elements []Element, options ExpandOptions) ([]Element, error)

ExpandElementsWithOptions flattens reusable elements with explicit expansion options.

type ElementType

type ElementType string

ElementType identifies a concrete layout element kind.

const (
	ElementTypeBox   ElementType = "box"
	ElementTypeLine  ElementType = "line"
	ElementTypeText  ElementType = "text"
	ElementTypeImage ElementType = "image"
)
const ElementTypeGroup ElementType = "group"

ElementTypeGroup groups child elements and applies an offset.

const ElementTypeRepeat ElementType = "repeat"

ElementTypeRepeat repeats child elements at multiple positions.

const ElementTypeTemplateInstance ElementType = "template-instance"

ElementTypeTemplateInstance renders a template with parameter substitution.

type ExpandOptions

type ExpandOptions struct {
	DeterministicIDs bool
	Parameters       Parameters
}

ExpandOptions controls how reusable elements are flattened.

Parameters are applied at the top-level before nested template merges.

type Feature

type Feature string

Feature identifies optional rendering capabilities.

const (
	FeatureBox              Feature = "box"
	FeatureLine             Feature = "line"
	FeatureText             Feature = "text"
	FeatureImage            Feature = "image"
	FeatureInsets           Feature = "insets"
	FeatureBorder           Feature = "border"
	FeatureDash             Feature = "dash"
	FeatureCornerRadius     Feature = "corner-radius"
	FeatureTemplates        Feature = "templates"
	FeatureDeterministicIDs Feature = "deterministic-ids"
)

type FillStyle

type FillStyle struct {
	Enabled bool
	Color   Color
}

FillStyle configures a fill color.

type Group

type Group struct {
	ID       string
	Offset   Point
	Elements []Element
}

Group is a reusable element container with a coordinate offset.

Example:

group := layout.NewGroup("card", layout.Point{X: 40, Y: 40}, layout.NewBox("b", layout.Rect{X: 0, Y: 0, Width: 100, Height: 60}))

func NewGroup

func NewGroup(id string, offset Point, elements ...Element) Group

NewGroup creates a group element.

func (Group) Type

func (g Group) Type() ElementType

Type returns the element type.

func (Group) Validate

func (g Group) Validate() error

Validate validates the group and all child elements.

type HorizontalAlign

type HorizontalAlign string

HorizontalAlign describes horizontal placement in a container rectangle.

const (
	AlignLeft   HorizontalAlign = "left"
	AlignCenter HorizontalAlign = "center"
	AlignRight  HorizontalAlign = "right"
)

type Image

type Image struct {
	ID       string
	Rect     Rect
	Data     []byte
	MIMEType string
	Style    ImageStyle
}

Image represents an image drawn into a destination rectangle.

func NewImage

func NewImage(id string, rect Rect, data []byte, mimeType string) Image

NewImage creates an Image element.

Example:

img := layout.NewImage("logo", layout.Rect{X: 20, Y: 20, Width: 64, Height: 64}, data, "image/png")
img.Style.Border.Enabled = true

func (Image) InnerRect

func (i Image) InnerRect() Rect

InnerRect returns the image drawing rectangle after applying image insets.

func (Image) Type

func (i Image) Type() ElementType

Type returns the element type.

func (Image) Validate

func (i Image) Validate() error

Validate validates the image element.

type ImageStyle

type ImageStyle struct {
	Insets Insets
	Border StrokeStyle
}

ImageStyle configures visual style for Image.

func DefaultImageStyle

func DefaultImageStyle() ImageStyle

DefaultImageStyle returns the default style for images.

Defaults: no border and no insets.

type Insets

type Insets struct {
	Top    float64
	Right  float64
	Bottom float64
	Left   float64
}

Insets represents top/right/bottom/left spacing values.

Example:

box.Style.Insets = layout.Insets{Top: 4, Right: 8, Bottom: 4, Left: 8}

func (Insets) Apply

func (i Insets) Apply(rect Rect) Rect

Apply returns a new rectangle reduced by the inset values.

func (Insets) Horizontal

func (i Insets) Horizontal() float64

Horizontal returns the combined left+right inset.

func (Insets) IsValid

func (i Insets) IsValid() bool

IsValid reports whether all inset values are non-negative.

func (Insets) Validate

func (i Insets) Validate(context string, rect Rect) error

Validate ensures inset values are valid for a rectangle.

func (Insets) Vertical

func (i Insets) Vertical() float64

Vertical returns the combined top+bottom inset.

type Line

type Line struct {
	ID    string
	Start Point
	End   Point
	Style LineStyle
}

Line represents a line segment between two points.

func NewLine

func NewLine(id string, start Point, end Point) Line

NewLine creates a Line with DefaultLineStyle.

Example:

line := layout.NewLine("sep", layout.Point{X: 20, Y: 120}, layout.Point{X: 320, Y: 120})
line.Style.Stroke.Width = 2

func (Line) Type

func (l Line) Type() ElementType

Type returns the element type.

func (Line) Validate

func (l Line) Validate() error

Validate validates the line.

type LineCap

type LineCap string

LineCap configures stroke cap style.

const (
	LineCapButt   LineCap = "butt"
	LineCapRound  LineCap = "round"
	LineCapSquare LineCap = "square"
)

type LineJoin

type LineJoin string

LineJoin configures stroke join style.

const (
	LineJoinMiter LineJoin = "miter"
	LineJoinRound LineJoin = "round"
	LineJoinBevel LineJoin = "bevel"
)

type LineStyle

type LineStyle struct {
	Stroke StrokeStyle
}

LineStyle configures visual style for a Line.

func DefaultLineStyle

func DefaultLineStyle() LineStyle

DefaultLineStyle returns the default style for lines.

Defaults: black 1px stroke.

type Page

type Page struct {
	Size       Size
	Header     []Element
	Elements   []Element
	Footer     []Element
	Pagination Pagination
}

Page is a single drawable surface within a document.

Header and Footer elements are rendered in addition to Elements (body). If Pagination.Enabled is true, a pagination Text element is generated per page.

func (*Page) AddElement

func (p *Page) AddElement(element Element)

AddElement appends an element to the page body.

Example:

page.AddElement(layout.NewBox("card", layout.Rect{X: 20, Y: 20, Width: 200, Height: 120}))

func (*Page) AddFooterElement

func (p *Page) AddFooterElement(element Element)

AddFooterElement appends an element to the page footer section.

Example:

page.AddFooterElement(layout.NewText("ftr", layout.Point{X: 20, Y: 390}, "Confidential"))

func (*Page) AddHeaderElement

func (p *Page) AddHeaderElement(element Element)

AddHeaderElement appends an element to the page header section.

Example:

page.AddHeaderElement(layout.NewText("hdr", layout.Point{X: 20, Y: 24}, "Report"))

func (Page) Validate

func (p Page) Validate() error

Validate validates page dimensions and elements.

type Pagination

type Pagination struct {
	Enabled  bool
	ID       string
	Template string
	Position Point
	Style    TextStyle
}

Pagination configures automatic page number text rendering.

Template supports the placeholders {{page}} and {{total}}.

Example:

page.Pagination = layout.DefaultPagination()
page.Pagination.Enabled = true
page.Pagination.Position = layout.Point{X: 580, Y: 390}
page.Pagination.Style.Align = layout.TextAlignRight

func DefaultPagination

func DefaultPagination() Pagination

DefaultPagination returns the default pagination configuration.

func (Pagination) BuildText

func (p Pagination) BuildText(content string) Text

BuildText returns a Text element for the given resolved pagination content.

type Parameters

type Parameters map[string]any

Parameters is a key/value set for template substitution.

Placeholders use the format {{key}}.

Example:

params := layout.Parameters{"name": "Ada Lovelace", "city": "London"}

func MergeParameters

func MergeParameters(base Parameters, override Parameters) Parameters

MergeParameters merges base and override where override wins.

func (Parameters) Clone

func (p Parameters) Clone() Parameters

Clone returns a shallow copy of the parameter map.

type Point

type Point struct {
	X float64
	Y float64
}

Point represents a 2D coordinate.

Example:

p := layout.Point{X: 10, Y: 20}

func Align

func Align(container Rect, content Size, horizontal HorizontalAlign, vertical VerticalAlign) Point

Align returns a top-left point that places content inside container.

Example:

origin := layout.Align(container, layout.Size{Width: 120, Height: 40}, layout.AlignRight, layout.AlignBottom)

func AlignCenterInRect

func AlignCenterInRect(container Rect, content Size) Point

AlignCenterInRect centers content in a container rectangle.

Example:

center := layout.AlignCenterInRect(container, layout.Size{Width: 160, Height: 80})

func GridPositions

func GridPositions(origin Point, columns int, rows int, stepX float64, stepY float64) []Point

GridPositions returns row-major positions for a rectangular grid.

It returns an empty slice if columns <= 0 or rows <= 0.

Example:

positions := layout.GridPositions(layout.Point{X: 40, Y: 40}, 2, 2, 240, 140)

type Rect

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

Rect represents a rectangle by top-left origin and size.

Example:

r := layout.Rect{X: 20, Y: 40, Width: 200, Height: 120}

func (Rect) IsValid

func (r Rect) IsValid() bool

IsValid returns true when width and height are positive.

type RenderOptions

type RenderOptions struct {
	DeterministicIDs bool
}

RenderOptions controls rendering behavior shared across backends.

type Renderer

type Renderer interface {
	Backend() Backend
	Render(doc Document) ([]byte, error)
}

Renderer renders a document into a backend-specific representation.

Renderers are provided by backend packages (for example backend/html, backend/pdf).

type Repeat

type Repeat struct {
	ID        string
	Positions []Point
	Elements  []Element
}

Repeat replicates child elements at each listed position.

Example:

repeat := layout.NewRepeat("labels", positions, group)

func NewRepeat

func NewRepeat(id string, positions []Point, elements ...Element) Repeat

NewRepeat creates a repeat element.

func (Repeat) Type

func (r Repeat) Type() ElementType

Type returns the element type.

func (Repeat) Validate

func (r Repeat) Validate() error

Validate validates the repeat element and all child elements.

type Size

type Size struct {
	Width  float64
	Height float64
}

Size represents a 2D width and height.

Example:

s := layout.Size{Width: 640, Height: 480}

type StringParameters

type StringParameters map[string]string

StringParameters is kept for compatibility with string-only parameter maps. Deprecated: use Parameters.

func (StringParameters) ToParameters

func (p StringParameters) ToParameters() Parameters

ToParameters converts StringParameters to Parameters. Deprecated: use Parameters directly.

type StrokeStyle

type StrokeStyle struct {
	Enabled  bool
	Color    Color
	Width    float64
	Dash     []float64
	LineCap  LineCap
	LineJoin LineJoin
}

StrokeStyle configures a stroked outline.

type Template

type Template struct {
	ID                 string
	Elements           []Element
	DefaultParameters  Parameters
	RequiredParameters []string
}

Template is a reusable, parameterizable element tree.

Templates are instantiated through TemplateInstance.

func NewTemplate

func NewTemplate(id string, elements ...Element) Template

NewTemplate creates a reusable template.

Example:

tpl := layout.NewTemplate("label", layout.NewText("name", layout.Point{X: 10, Y: 24}, "{{name}}"))

func (Template) Validate

func (t Template) Validate() error

Validate validates the template child elements.

func (Template) WithDefaults

func (t Template) WithDefaults(defaultParameters Parameters) Template

WithDefaults returns a copy of the template with default parameters.

func (Template) WithRequired

func (t Template) WithRequired(requiredParameters ...string) Template

WithRequired returns a copy of the template with required parameter keys.

type TemplateInstance

type TemplateInstance struct {
	ID         string
	Template   Template
	Offset     Point
	Parameters Parameters
}

TemplateInstance renders a template with offset and parameters.

func NewTemplateInstance

func NewTemplateInstance(
	id string,
	template Template,
	offset Point,
	parameters Parameters,
) TemplateInstance

NewTemplateInstance creates a template instance element.

func (TemplateInstance) Type

func (t TemplateInstance) Type() ElementType

Type returns the element type.

func (TemplateInstance) Validate

func (t TemplateInstance) Validate() error

Validate validates the template instance and its template.

type Text

type Text struct {
	ID       string
	Position Point
	Content  string
	Style    TextStyle
}

Text represents a text label drawn at a position.

func NewText

func NewText(id string, position Point, content string) Text

NewText creates a Text with DefaultTextStyle.

Example:

txt := layout.NewText("title", layout.Point{X: 40, Y: 50}, "Quarterly Report")
txt.Style.Bold = true

func (Text) Type

func (t Text) Type() ElementType

Type returns the element type.

func (Text) Validate

func (t Text) Validate() error

Validate validates the text element.

type TextAlign

type TextAlign string

TextAlign controls horizontal alignment relative to the text anchor position.

const (
	TextAlignLeft   TextAlign = "left"
	TextAlignCenter TextAlign = "center"
	TextAlignRight  TextAlign = "right"
)

type TextStyle

type TextStyle struct {
	Color      Color
	FontSize   float64
	FontFamily string
	Bold       bool
	Italic     bool
	Underline  bool
	Align      TextAlign
}

TextStyle configures visual style for Text.

Example:

text.Style.Bold = true
text.Style.Italic = true
text.Style.Underline = true
text.Style.Align = layout.TextAlignCenter

func DefaultTextStyle

func DefaultTextStyle() TextStyle

DefaultTextStyle returns the default style for text.

Defaults: black 12px Helvetica, left-aligned, no bold/italic/underline.

type VerticalAlign

type VerticalAlign string

VerticalAlign describes vertical placement in a container rectangle.

const (
	AlignTop    VerticalAlign = "top"
	AlignMiddle VerticalAlign = "middle"
	AlignBottom VerticalAlign = "bottom"
)

Directories

Path Synopsis
backend
pdf
png
svg
cmd
layoutdemo command
examples
canvas command
html command
labels command
pdf command
png command
svg command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL