Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v0 source pure

Package svg draws the small on-chain SVGs of GnoRadio (covers, tickets, charts) with a strings.Builder, which keeps v...

Overview

Package svg draws the small on-chain SVGs of GnoRadio (covers, tickets, charts) with a strings.Builder, which keeps vm/qrender gas low.

Functions 4

func Clip

1func Clip(s string, n int) string
source

Clip shortens s to n runes, ending with an ellipsis.

func Escape

1func Escape(s string) string
source

Escape makes text safe inside SVG: titles and names may hold '&'.

func FNV

1func FNV(s string) uint32
source

FNV is the 32-bit FNV-1a hash, used to pick a composition from a title.

func New

1func New(w, h int, css string) *Canvas
source

New opens a w×h SVG whose <style> holds css.

Types 1

type Canvas

struct
1type Canvas struct{ b strings.Builder }
source

Methods on Canvas

func Circle

method on Canvas
1func (c *Canvas) Circle(cx, cy, r int, fill string)
source

func Data

method on Canvas
1func (c *Canvas) Data() string
source

Data closes the SVG and returns it as a base64 data URI.

func Image

method on Canvas
1func (c *Canvas) Image(alt string) string
source

Image closes the SVG and returns it as a markdown image.

func Raw

method on Canvas
1func (c *Canvas) Raw(s string)
source

func Rect

method on Canvas
1func (c *Canvas) Rect(x, y, w, h, rx int, fill, extra string)
source

Rect draws a rectangle; extra holds more attributes, e.g. ` mask="url(#h)"`.

func Text

method on Canvas
1func (c *Canvas) Text(x, y int, s, fill string, size int, attrs string)
source

Text writes s escaped; attrs follows font-size, e.g. ` text-anchor="end" class="m"`.

Imports 4

Source Files 2