gosvg

package module
v0.0.0-...-d775dab Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: BSD-3-Clause Imports: 18 Imported by: 0

README

SVG rasterizer in Go

This module uses github.com/srwiley/rasterx and webrender library to raster SVG images.

This is a Work In Progress.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(src io.Reader) (image.Image, error)

Types

type Canvas

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

func (*Canvas) AddFont

func (cv *Canvas) AddFont(font pango.Font, content []byte) *backend.Font

AddFont register a new font to be used in the output and return an object used to store associated metadata. This method will be called several times with the same `font` argument, so caching is advised.

func (*Canvas) ClosePath

func (cv *Canvas) ClosePath()

func (*Canvas) CubicTo

func (cv *Canvas) CubicTo(x1, y1, x2, y2, x3, y3 Fl)

func (*Canvas) DrawGradient

func (cv *Canvas) DrawGradient(gradient backend.GradientLayout, width backend.Fl, height backend.Fl)

DrawGradient draws the given gradient at the current point. Solid gradient are already handled, meaning that only linear and radial must be taken care of.

func (*Canvas) DrawRasterImage

func (cv *Canvas) DrawRasterImage(image backend.RasterImage, width backend.Fl, height backend.Fl)

DrawRasterImage draws the given image at the current point, with the given dimensions. Typical format for image.Content are PNG, JPEG, GIF.

func (*Canvas) DrawText

func (cv *Canvas) DrawText(texts []backend.TextDrawing)

DrawText draws the given text using the current fill color. The rendering may be altered by a preivous `SetTextPaint` call. The fonts of the runs have been registred with `AddFont`.

func (*Canvas) DrawWithOpacity

func (cv *Canvas) DrawWithOpacity(opacity backend.Fl, group backend.Canvas)

DrawWithOpacity draw the given target to the main target, applying the given opacity (in [0,1]).

func (*Canvas) GetRectangle

func (cv *Canvas) GetRectangle() (left, top, right, bottom backend.Fl)

Returns the current canvas rectangle

func (*Canvas) LineTo

func (cv *Canvas) LineTo(x, y Fl)

func (*Canvas) MoveTo

func (cv *Canvas) MoveTo(x, y Fl)

func (*Canvas) NewGroup

func (cv *Canvas) NewGroup(x backend.Fl, y backend.Fl, width backend.Fl, height backend.Fl) backend.Canvas

NewGroup creates a new drawing target with the given bounding box. It may be filled by graphic operations before being passed to the `DrawWithOpacity`, `SetColorPattern` and `DrawAsMask` methods.

func (*Canvas) OnNewStack

func (cv *Canvas) OnNewStack(f func())

OnNewStack save the current graphic stack, execute the given closure, and restore the stack.

func (*Canvas) Paint

func (cv *Canvas) Paint(op backend.PaintOp)

Paint actually shows the current path on the target, either stroking, filling or doing both, according to `op`. The result of the operation depends on the current fill and stroke settings. After this call, the current path will be cleared.

func (*Canvas) Rectangle

func (cv *Canvas) Rectangle(x backend.Fl, y backend.Fl, width backend.Fl, height backend.Fl)

Adds a rectangle of the given size to the current path, at position “(x, y)“ in user-space coordinates. (X,Y) coordinates are the top left corner of the rectangle. Note that this method may be expressed using MoveTo and LineTo, but may be implemented more efficiently.

func (*Canvas) State

func (cv *Canvas) State() backend.GraphicState

type Fl

type Fl = backend.Fl

Jump to

Keyboard shortcuts

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