style

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package style parses the engine's bounded inline CSS profile into typed values. It is manager-only and does not add parsing dependencies to TinyGo firmware.

Index

Constants

View Source
const MaxDeclarations = 4096

Variables

View Source
var ErrValue = errors.New("style: invalid or unsupported value")

Functions

This section is empty.

Types

type Block

type Block struct {
	// contains filtered or unexported fields
}

func Parse

func Parse(source string, element uint32) (Block, error)

Parse consumes an inline declaration list, not selectors or a stylesheet. Parser recovery never turns invalid input into a partially applied scene. https://pkg.go.dev/github.com/tdewolff/parse/v2/css#NewParser

func (Block) Count

func (b Block) Count() int

func (Block) Error

func (b Block) Error(name string, code renderdiag.Code) error

Error retains the winning declaration's source range after shorthand/cascade. A generated semantic default has HTML identity but no fabricated CSS range.

func (Block) Get

func (b Block) Get(name string) (Value, bool)

func (Block) WithDimensionHints

func (b Block) WithDimensionHints(width, height float64) (Block, error)

WithDimensionHints applies HTML image width/height below inline declarations. Zero means absent. It preserves CSS source ranges and never changes b.

type Computed

type Computed struct {
	// contains filtered or unexported fields
}

Computed owns resolved inheritance and font metrics for one element. Layout still resolves percentages and box-relative lengths against its containing box.

func Compute

func Compute(tag string, block Block, parent *Computed, metrics Metrics) (Computed, error)

func (Computed) Color

func (c Computed) Color(name string) color.NRGBA

func (Computed) FontSize

func (c Computed) FontSize() float64

func (Computed) Get

func (c Computed) Get(name string) Value

func (Computed) Keyword

func (c Computed) Keyword(name string) string

func (Computed) Length

func (c Computed) Length(name string) Length

func (Computed) Number

func (c Computed) Number(name string) float64

func (Computed) RootFont

func (c Computed) RootFont() float64

type Kind

type Kind uint8
const (
	LengthValue Kind = iota + 1
	KeywordValue
	NumberValue
	ColorValue
	ImageValue
)

type Length

type Length struct {
	Value float64
	Unit  Unit
}

func ParseLength

func ParseLength(source string) (Length, error)

func (Length) Resolve

func (l Length) Resolve(metrics Metrics) (float64, error)

type Metrics

type Metrics struct {
	Containing, Font, RootFont, ViewportWidth, ViewportHeight float64
}

Metrics supplies the reference for this property, not a global percentage base. For font-size, Font is the inherited size (including root's initial size). https://www.w3.org/TR/css-values-3/#font-relative-lengths

type Unit

type Unit uint8
const (
	Px Unit = iota
	Percent
	Em
	Rem
	VW
	VH
	Auto
	None
)

type Value

type Value struct {
	Kind    Kind
	Length  Length
	Number  float64
	Color   color.NRGBA
	Keyword string
	Image   string
}

Value is a closed typed union, validated at Parse. A property's grammar determines its Kind; source strings never reach geometry or paint arithmetic.

Jump to

Keyboard shortcuts

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