render

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package render defines the boundary between the display model and whatever engine lays it out and draws it. Engine types stay behind this boundary.

Index

Constants

View Source
const FullPNGScale = 2

FullPNGScale is the scale of the PNG unless the engine cannot draw the figure that large.

Variables

This section is empty.

Functions

This section is empty.

Types

type LayoutError

type LayoutError struct {
	Engine view.Engine
	Err    error
}

LayoutError says the layout engine could not place the figure. Err is the engine's own error.

func (*LayoutError) Error

func (e *LayoutError) Error() string

func (*LayoutError) Unwrap

func (e *LayoutError) Unwrap() error

type MissingGlyphError

type MissingGlyphError struct {
	Rune rune
	// SceneID is the ID of the group, node, or relation of the scene whose
	// text holds the character. It is empty when the text is the title, the
	// legend, or a note.
	SceneID string
}

MissingGlyphError says the fonts have no glyph for a character of a text in the scene. It names the character and never the text, which may be a label of the user.

func (*MissingGlyphError) Error

func (e *MissingGlyphError) Error() string

type Options

type Options struct {
	Engine view.Engine
	// Seed picks one of the layouts TALA can give for the same scene. The
	// caller names it and keeps it, so that the same scene and options give
	// the same bytes. ELK has no seed and ignores it.
	Seed int64
}

Options name the one layout a render runs. A render never tries a second engine or a second seed.

type Renderer

type Renderer interface {
	Render(ctx context.Context, scene *view.Scene, opts Options) (*Result, error)
}

type Result

type Result struct {
	SVG []byte
	// PNG is the figure at PNGScale times the width and height of the SVG.
	// An engine limits how large a PNG it draws. A figure it cannot draw at
	// FullPNGScale gets a PNG at scale 1, and a figure it cannot draw at
	// scale 1 either gets none: PNG is nil and PNGScale is 0. The SVG is there
	// in every case.
	PNG      []byte
	PNGScale int
	// PNGLimit says which limit of the engine kept the PNG from the full scale,
	// in the engine's words, such as "frame pixels exceed limit 67108864". It
	// holds numbers and fixed words only, so it is safe to show. It is empty for
	// a PNG at FullPNGScale, and when the engine's reason is not one of its
	// limits: that text may quote the figure.
	PNGLimit string
}

Directories

Path Synopsis
Package d2render draws a Scene with D2.
Package d2render draws a Scene with D2.

Jump to

Keyboard shortcuts

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