Skip to content

A SVG render written in Go & WASM depended on resvg without CGO

License

Notifications You must be signed in to change notification settings

kanrichan/resvg-go

Repository files navigation

椛

resvg-go


A SVG renderer written in Go & WASM depended on resvg without CGO

Usage

Render by default

// initialize and don't forget to close!
// worker are not goroutine-safe!
worker, _ := NewDefaultWorker(context.Background())
defer worker.Close()

// render the SVG as a PNG!
png, _ := worker.Render(svg)

Render with options

// initialize and don't forget to close!
// worker are not goroutine-safe!
worker, _ := NewDefaultWorker(context.Background())
defer worker.Close()

// render the SVG as a PNG!
fontdb, _ := worker.NewFontDBDefault()
defer fontdb.Close()
fontdb.LoadFontData(ttf)

pixmap, _ := worker.NewPixmap(512, 512)
defer pixmap.Close()

tree, _ := worker.NewTreeFromData(svg, &Options{})
defer tree.Close()
tree.ConvertText(fontdb)
tree.Render(TransformIdentity(), pixmap)

png, _ := pixmap.EncodePNG()

Thanks

  • resvg - an SVG rendering library written in Rust
  • wazero - the zero dependency WebAssembly runtime for Go developers

About

A SVG render written in Go & WASM depended on resvg without CGO

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •