Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kanrichan/resvg-go
A SVG render written in Go & WASM depended on resvg without CGO
https://github.com/kanrichan/resvg-go
golang render resvg svg wasi wasm wazero
Last synced: about 2 months ago
JSON representation
A SVG render written in Go & WASM depended on resvg without CGO
- Host: GitHub
- URL: https://github.com/kanrichan/resvg-go
- Owner: kanrichan
- License: gpl-3.0
- Created: 2023-03-02T14:57:01.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-21T10:24:54.000Z (3 months ago)
- Last Synced: 2024-10-31T21:35:13.542Z (2 months ago)
- Topics: golang, render, resvg, svg, wasi, wasm, wazero
- Language: Go
- Homepage:
- Size: 2.51 MB
- Stars: 33
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
resvg-go
A SVG renderer written in Go & WASM depended on resvg without CGO
## Usage
### Render by default
```go
// 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
```go
// 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](https://github.com/RazrFalcon/resvg) - an SVG rendering library written in Rust
- [wazero](https://github.com/tetratelabs/wazero) - the zero dependency WebAssembly runtime for Go developers