okage

package module
v0.12.0 Latest Latest
Warning

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

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

README


Unit Tests Go Reference Releases Discord Discussion

okage

okage is a pure Go port of tiny-skia and of resvg.

  1. tiny-skia is a small 2D renderer in Rust, and it is a subset of Skia, the renderer of Chrome. It fills and strokes paths with a solid color, a gradient or a pattern. It dashes strokes, clips with a mask and blends images. It renders on the CPU only. okage ports it into the root package and the package path.
  2. resvg renders SVG files with tiny-skia. okage ports it into the package svg.
  3. velato renders Lottie animations. okage ports it into the package lottie, which draws with okage (D41).
  4. tinyhtml5, tinycss2 and cssselect2 parse HTML, parse CSS and match CSS selectors in Python, for WeasyPrint. okage ports them into the packages html, tinycss2 and cssselect2 (D49, D50).

Today xo/resvg wraps resvg through cgo and a static archive for each platform. A program that imports okage needs the Go toolchain and nothing else.

okage uses SIMD where Go can, and its scalar code is the fallback. SIMD (single instruction, multiple data) means one instruction that works on several values at once. A build with TinyGo, most of all for WebAssembly, is a goal that the port keeps in mind.

Status

The port of tiny-skia is done, in the root package and in path. It gives the same bytes as tiny-skia in the scalar build, in the SIMD build and with TinyGo, and the 157 integration tests of tiny-skia pass. It is about 1.2 to 3 times slower than the scalar code of tiny-skia, and work that makes it faster stays open (D35). The package svg is the port of usvg and resvg. It parses and renders each test file of resvg: without text and without a raster image, with the same pixels as resvg, and with text or an image, within the tolerance of D31. The package lottie is the port of velato. It gives the same calls to its sink as velato for each of the 879 Noto animated emoji, and each sampled frame of them is within the tolerance of D43 of ThorVG. docs/PLAN.md holds the plan, the phases and the open questions.

The port starts from resvg v0.49.0 and from the versions of the crates that it uses, such as tiny-skia v0.12.0. After each base port, okage follows each upstream commit. On 2026-11-12 okage follows resvg up to its commit 5bdbae64 of 2026-11-11. docs/upstream/upstreams.tsv lists the upstream repositories, and one ledger for each records what okage did with each commit.

Installing

Install okage with this command:

go get github.com/xo/okage

The renderer imports only the Go standard library. The package svg also uses typesetting for text, and golang.org/x/image/webp for WebP files. typesetting is a public copy of go-text/typesetting in okage (D52). okage does not use cgo, so a program that imports it builds with CGO_ENABLED=0 for every platform that Go supports.

SIMD

Go 1.27 has SIMD only as an experiment, so okage has two builds:

  1. The scalar build is the default.
  2. The SIMD build uses the package simd/archsimd of Go on amd64, arm64 and WebAssembly. A program gets it when it builds with GOEXPERIMENT=simd.
GOEXPERIMENT=simd go build ./...

Both builds give the same bytes for every image. On an amd64 CPU without AVX2, the SIMD build uses the scalar code. TinyGo always uses the scalar code. When Go makes SIMD a standard feature, the SIMD build becomes the default. docs/SIMD.md holds the details.

Documents

Document What it holds
docs/PLAN.md the plan, the testing plan, the phases and the open questions
docs/UPSTREAM.md the rules for porting each upstream repository and each change that it makes
docs/SIMD.md the rules for the vector code, the two builds and the SIMD packages of Go
docs/BACKLOG.md the work that is known and not done
docs/FORMATS.md a survey of the work to support other vector formats, such as PDF, EPS and DWG
docs/decisions/ every decision, one file each, with an index
CONTRIBUTING.md how to change okage
AGENTS.md the rules for a coding agent, which also hold for a person

Differences from upstream

okage differs from upstream only where a decision says so:

  1. The SIMD build computes a reciprocal exactly. The SIMD backends of tiny-skia approximate it in the blend modes color dodge and color burn, and its scalar backend computes it exactly (D16).

  2. svg decodes PNG, JPEG and GIF files with the standard library, and WebP files with golang.org/x/image/webp, in place of the decoders of resvg (D7).

  3. svg finds fonts and shapes text with typesetting, the copy of go-text/typesetting in okage, in place of the crates of resvg. Its text can differ from the text of resvg (D9, D52).

  4. Each package logs to a *slog.Logger that the caller gives (D20).

  5. An elliptical arc makes at most 4,096 cubic curves. kurbo has no limit, so an arc with a radius of about 4.23e20 or more does not end in upstream (D30).

  6. The gamma stages give one result for every NaN. Upstream reads the bits of a NaN there, and they differ between x86 and ARM (D34).

  7. The fallback of text skips a character that no font draws, and goes on with the characters after it. Upstream stops at that character, so the characters after it get no fallback (D39). The fallback also replaces whole clusters, where upstream copies glyphs one by one, so an emoji sequence such as a flag falls back with the text around it (D39).

  8. The fallback of text also goes on for an emoji that the font does not draw as an emoji: a character with U+FE0F without a color glyph, such as "©️" in a text font, and an emoji sequence that the font draws as several glyphs. Upstream falls back only for a missing glyph (D40).

  9. lottie draws as ThorVG where velato differs: the opacity, the opacity stops, the radius and the highlight of gradients, solid layers, time remap, easing, spatial positions, the closing of animated shapes, the opacity and the blend mode of layers, masks and stroke dashes (D43). Renderer.MergePaths draws merge paths by compositing, which velato and ThorVG do not, and it is off by default (D42).

  10. html builds a tree with a node for each run of text, where tinyhtml5 builds an ElementTree of Python. It goes on where upstream raises an error, and options bound the depth, the nodes and the issues of a parse (D49).

  11. tinycss2 nests at most 256 blocks and cssselect2 at most 32 selectors, where upstream has no limit. Where upstream raises an exception for a selector or a color, the port returns a SelectorError or no color (D50).

  12. A fill clamps each side of the bounds of a path to 2^26 pixels from the origin before it rounds them. Upstream panics or leaves out rows for an antialiased fill with a point past about 2^29 pixels, and draws nothing for a fill without antialiasing of a path wider or taller than 2^31 pixels. DrawPixmap of an image that is aligned to the pixels skips the stages of the pipeline, with the same bytes (D53).

  13. A hairline on a pixmap of 1 or 2 rows or columns draws its pixels. Upstream draws nothing there (D54).

When upstream changes the code of a difference, okage removes its own code and ports the change of upstream. D40 gives the steps for items 7 and 8, and D42 and D43 give them for item 9.

okage also adds APIs that upstream does not have:

  1. A Pixmap gives an *image.RGBA that shares its bytes, and it implements image.Image and draw.Image (D19).
  2. svg.New makes a Renderer, which renders SVG data into an *image.RGBA in one call, as xo/resvg does. It loads the fonts of the system on its first call, and sets each generic family to the first of a list of common fonts that is installed. The package registers the format svg with image.RegisterFormat, so image.Decode reads SVG data (D36). FontDatabase.LoadOSFonts loads the same fonts into a database of the program (D46).
  3. svg.ShapeText lays out a run of text with the fonts, the fallback and the shaping of svg, and gives its advance width and the outlines of its glyphs as a path, so that a program can draw text without SVG data (D37). TextRun.RenderColorGlyphs draws its color glyphs, such as color emoji (D39).
  4. html.Parse parses an HTML-like label of Graphviz, label=<...> in DOT, and Label.Layout lays it out as dot does: the boxes of the tables and the cells, the rules, the runs of text and the ports (D38).
  5. lottie.Parse reads a Lottie file, and lottie.RenderFrame draws a frame of it onto an okage pixmap through PixmapSink, the sink of lottie that draws with okage (D41).
  6. lottie.Detect finds a Lottie document from the start of a file, and lottie.OpenDotLottie reads a dotLottie archive. lottie.Load parses either one. Composition.Image draws a frame into an *image.RGBA of a given size, and FrameCount and Duration count and time the frames (D44).
  7. FontDatabase.LoadFontData loads a font in WOFF, WOFF2 or EOT, as well as TrueType and OpenType data. svg.ConvertFontData converts such a font to TrueType or OpenType data. FontDatabase.FaceName returns a string of the name table of a face, such as the version or the sample text (D45). The package webfont gives the same conversion to a program that does not use svg (D51).
  8. Paint.Coverage fills a path with 8 by 8 samples in each pixel, in place of the 4 by 4 of tiny-skia, and Paint.StrokeAdjust moves a thin stroke onto the pixel grid, as stroke adjustment does in PDF (D54).
  9. MeshGradient, which NewMeshGradient makes, fills a mesh of triangles with a color at each corner, for the shadings of the types 4 to 7 of PDF and PostScript. SpreadModeDecal makes a gradient transparent before its start and after its end, as the decal tile mode of Skia does (D55).
  10. MaskFromLuminance and Mask.ApplyTransfer make the soft masks of PDF with a backdrop color and a transfer function. Pixmap.RemoveBackdrop and Pixmap.Knockout composite the groups of PDF that are not isolated and the knockout groups (D56).
  11. TextStyle also takes the stretch, the variations, the features, the language and the spacing of a run, and TextRun.Clusters gives the bytes, the advance and the glyphs of each cluster. FontDatabase gives the parsed faces, the cmaps and the metrics that it keeps, and AutoFontVariations maps a CSS weight, stretch and style to the axes of a variable font. FontDatabase.ColorGlyph gives a glyph of COLR or of the table SVG as a tree (D57).
  12. svg.ReadDimensions reads the size and the viewBox of an SVG image before the parse. svg.FromXMLTree and svg.FromXMLNode make a tree from a document of roxmltree, and roxmltree.Builder makes such a document without XML text. svg.WithZeroSize accepts an image of size zero (D58).
  13. The package typesetting/font/cff exports the predefined charsets of CFF, and draws the accented glyphs of seac and the FontMatrix of each font dictionary (D59).

The output of svg is compared with resvg and with libvips within a tolerance, not byte for byte (D23). The renderer gives the same bytes as tiny-skia.

License

The root package and path are under the BSD-3-Clause license of tiny-skia. See LICENSE, which keeps the copyright lines of upstream. The package svg and the packages that it uses take the MIT license of resvg and of its crates, in a LICENSE file in each folder (D13). The package html takes the MIT license of tinyhtml5, in html/LICENSE. That license also covers the parser of the labels of Graphviz (D49). The packages tinycss2 and cssselect2 keep the BSD-3-Clause licenses of their upstreams, in tinycss2/LICENSE and cssselect2/LICENSE (D50). The brotli decoder in internal/brotli is a copy of the one of github.com/dsnet/compress, and keeps its BSD-3-Clause license, in internal/brotli/LICENSE (D45). The packages under typesetting are a copy of go-text, and keep its license, the Unlicense or the BSD-3-Clause license, in typesetting/LICENSE. The package harfbuzz keeps the MIT license of HarfBuzz in typesetting/harfbuzz/LICENSE (D52). The package lottie takes the MIT license of velato, in lottie/LICENSE. Its test files are Noto animated emoji under CC BY 4.0, as lottie/testdata/NOTICE says.

Documentation

Overview

Package okage is a port of the Rust crate tiny-skia 0.12.0, a tiny subset of Skia (https://skia.org/).

The API of okage is a bit unconventional. It does not look like cairo, QPainter (Qt), HTML Canvas or even Skia itself. Instead, okage gives a set of low-level drawing APIs, and a user manages the world transform, the clipping mask and the style manually.

The package path holds the paths and the geometry types. okage declares a type alias for each type of path that tiny-skia exports again, so that a user needs one import.

The renderer gives the same bytes as the scalar build of tiny-skia (D16). A multiply that is followed by an add is written as float32(x*y) + z, so that the Go compiler cannot fuse the two operations.

Example (Fill)

This example ports tiny-skia examples/fill.rs. It fills two paths, one with anti-aliasing and one without.

package main

import (
	"fmt"

	"github.com/xo/okage"
)

// printPixel prints the premultiplied RGBA value of the pixel at x, y.
func printPixel(pixmap *okage.Pixmap, x, y uint32) {
	c, _ := pixmap.Pixel(x, y)
	fmt.Println(c.Red(), c.Green(), c.Blue(), c.Alpha())
}

func main() {
	paint1 := okage.DefaultPaint()
	paint1.SetColorRGBA8(50, 127, 150, 200)
	paint1.AntiAlias = true

	paint2 := okage.DefaultPaint()
	paint2.SetColorRGBA8(220, 140, 75, 180)
	paint2.AntiAlias = false

	pb := okage.NewPathBuilder()
	pb.MoveTo(60, 60)
	pb.LineTo(160, 940)
	pb.CubicTo(380, 840, 660, 800, 940, 800)
	pb.CubicTo(740, 460, 440, 160, 60, 60)
	pb.Close()
	path1, _ := pb.Finish()

	pb = okage.NewPathBuilder()
	pb.MoveTo(940, 60)
	pb.LineTo(840, 940)
	pb.CubicTo(620, 840, 340, 800, 60, 800)
	pb.CubicTo(260, 460, 560, 160, 940, 60)
	pb.Close()
	path2, _ := pb.Finish()

	pixmap, _ := okage.NewPixmap(1000, 1000)
	pixmap.FillPath(
		path1,
		&paint1,
		okage.FillRuleWinding,
		okage.IdentityTransform(),
		nil,
	)
	pixmap.FillPath(
		path2,
		&paint2,
		okage.FillRuleWinding,
		okage.IdentityTransform(),
		nil,
	)
	printPixel(pixmap, 500, 600)
}
Output:
167 129 88 239
Example (Gamma)

This example ports tiny-skia examples/gamma.rs. It strokes the same lines in each color space.

package main

import (
	"fmt"

	"github.com/xo/okage"
)

// printPixel prints the premultiplied RGBA value of the pixel at x, y.
func printPixel(pixmap *okage.Pixmap, x, y uint32) {
	c, _ := pixmap.Pixel(x, y)
	fmt.Println(c.Red(), c.Green(), c.Blue(), c.Alpha())
}

func main() {
	paint := okage.DefaultPaint()
	paint.Shader = okage.SolidColor(okage.ColorFromRGBA8(255, 100, 20, 255))
	paint.AntiAlias = true
	stroke := okage.DefaultStroke()

	pixmap, _ := okage.NewPixmap(1000, 1000)
	pixmap.Fill(okage.ColorBlack)

	pb := okage.NewPathBuilder()
	for i := range 10 {
		pb.MoveTo(50, 45+float32(i)*20)
		pb.LineTo(450, 45+float32(i)*21)
	}
	path, _ := pb.Finish()

	colors := []okage.ColorSpace{
		okage.ColorSpaceLinear,
		okage.ColorSpaceGamma2,
		okage.ColorSpaceSimpleSRGB,
		okage.ColorSpaceFullSRGBGamma,
	}

	for i, color := range colors {
		paint.Colorspace = color

		xf := okage.IdentityTransform()
		xf = xf.PreTranslate(0, 240*float32(i))

		pixmap.StrokePath(path, &paint, &stroke, xf, nil)

		// Move down 0.5 pixel so lines start in the middle of the pixel, not the edge
		xf = xf.PreTranslate(500, 0.5)

		pixmap.StrokePath(path, &paint, &stroke, xf, nil)
	}

	printPixel(pixmap, 250, 285)
}
Output:
181 71 14 255
Example (Hairline)

This example ports tiny-skia examples/hairline.rs.

This example demonstrates thin paths rendering.

package main

import (
	"fmt"

	"github.com/xo/okage"
)

// printPixel prints the premultiplied RGBA value of the pixel at x, y.
func printPixel(pixmap *okage.Pixmap, x, y uint32) {
	c, _ := pixmap.Pixel(x, y)
	fmt.Println(c.Red(), c.Green(), c.Blue(), c.Alpha())
}

func main() {
	pb := okage.NewPathBuilder()
	pb.MoveTo(50, 100)
	pb.CubicTo(130, 20, 390, 120, 450, 30)
	path, _ := pb.Finish()

	paint := okage.DefaultPaint()
	paint.SetColorRGBA8(50, 127, 150, 200)
	paint.AntiAlias = true

	pixmap, _ := okage.NewPixmap(500, 500)
	transform := okage.IdentityTransform()
	for i := range 20 {
		stroke := okage.DefaultStroke()
		stroke.Width = 2 - (float32(i) / 10)
		pixmap.StrokePath(path, &paint, &stroke, transform, nil)
		transform = transform.PreTranslate(0, 20)
	}

	printPixel(pixmap, 50, 100)
}
Output:
13 32 37 63
Example (ImageOnImage)

This example ports tiny-skia examples/image_on_image.rs. It draws a pixmap on another pixmap with a transform.

Upstream also prints the time that the drawing takes. This example does not, because the time is different on each run.

package main

import (
	"fmt"

	"github.com/xo/okage"
)

// printPixel prints the premultiplied RGBA value of the pixel at x, y.
func printPixel(pixmap *okage.Pixmap, x, y uint32) {
	c, _ := pixmap.Pixel(x, y)
	fmt.Println(c.Red(), c.Green(), c.Blue(), c.Alpha())
}

func main() {
	triangle := createTriangle()

	pixmap, _ := okage.NewPixmap(400, 400)

	paint := okage.DefaultPixmapPaint()
	paint.Quality = okage.FilterQualityBicubic

	pixmap.DrawPixmap(
		20,
		20,
		triangle.AsRef(),
		&paint,
		okage.TransformFromRow(1.2, 0.5, 0.5, 1.2, 0, 0),
		nil,
	)

	printPixel(pixmap, 200, 200)
}

// createTriangle is create_triangle in tiny-skia examples/image_on_image.rs.
func createTriangle() *okage.Pixmap {
	paint := okage.DefaultPaint()
	paint.SetColorRGBA8(50, 127, 150, 200)
	paint.AntiAlias = true

	pb := okage.NewPathBuilder()
	pb.MoveTo(0, 200)
	pb.LineTo(200, 200)
	pb.LineTo(100, 0)
	pb.Close()
	path, _ := pb.Finish()

	pixmap, _ := okage.NewPixmap(200, 200)

	pixmap.FillPath(
		path,
		&paint,
		okage.FillRuleWinding,
		okage.IdentityTransform(),
		nil,
	)

	rect, _ := okage.RectFromLTRB(0, 0, 200, 200)
	path = okage.PathFromRect(rect)
	stroke := okage.DefaultStroke()
	paint.SetColorRGBA8(200, 0, 0, 220)

	pixmap.StrokePath(path, &paint, &stroke, okage.IdentityTransform(), nil)

	return pixmap
}
Output:
39 100 118 200
Example (LargeImage)

This example ports tiny-skia examples/large_image.rs.

This example will crate a 20_000x20_000px image, which can take a while in a debug mode. This example is used mainly to tests that our tiling algorithm actually works and doesn't panic.

The pixmap and the mask need about 2 GB of memory, so this example has no Output comment, and go test compiles it but does not run it.

package main

import (
	"github.com/xo/okage"
)

func main() { //nolint:testableexamples // It needs about 2 GB of memory, so go test must not run it.
	pb := okage.NewPathBuilder()
	pb.MoveTo(1200, 1200)
	pb.LineTo(3200, 18800)
	pb.CubicTo(7600, 16800, 13200, 16000, 18800, 16000)
	pb.CubicTo(14800, 9200, 8800, 3200, 1200, 1200)
	pb.Close()
	path1, _ := pb.Finish()

	pb = okage.NewPathBuilder()
	pb.MoveTo(18800, 1200)
	pb.LineTo(16800, 18800)
	pb.CubicTo(12400, 16800, 6800, 16000, 1200, 16000)
	pb.CubicTo(5200, 9200, 11200, 3200, 18800, 1200)
	pb.Close()
	path2, _ := pb.Finish()

	pixmap, _ := okage.NewPixmap(20000, 20000)

	pb = okage.NewPathBuilder()
	pb.PushCircle(10000, 10000, 7000)
	clipPath, _ := pb.Finish()

	mask, _ := okage.NewMask(20000, 20000)
	mask.FillPath(clipPath, okage.FillRuleWinding, true, okage.DefaultTransform())

	paint := okage.DefaultPaint()
	paint.SetColorRGBA8(90, 175, 100, 150)
	paint.AntiAlias = true
	largeRect, _ := okage.RectFromXYWH(500, 500, 19000, 19000)
	pixmap.FillRect(largeRect, &paint, okage.IdentityTransform(), nil)

	paint.SetColorRGBA8(50, 127, 150, 200)
	paint.AntiAlias = true
	pixmap.FillPath(
		path1,
		&paint,
		okage.FillRuleWinding,
		okage.DefaultTransform(),
		mask,
	)

	paint.SetColorRGBA8(220, 140, 75, 180)
	paint.AntiAlias = false
	pixmap.FillPath(
		path2,
		&paint,
		okage.FillRuleWinding,
		okage.DefaultTransform(),
		nil,
	)

	paint.SetColorRGBA8(255, 10, 15, 180)
	paint.AntiAlias = true
	stroke := okage.DefaultStroke()
	stroke.Width = 0.8 // hairline
	pixmap.StrokePath(path2, &paint, &stroke, okage.DefaultTransform(), nil)
}
Example (LinearGradient)

This example ports tiny-skia examples/linear_gradient.rs. It fills a path with a linear gradient.

package main

import (
	"fmt"

	"github.com/xo/okage"
)

// printPixel prints the premultiplied RGBA value of the pixel at x, y.
func printPixel(pixmap *okage.Pixmap, x, y uint32) {
	c, _ := pixmap.Pixel(x, y)
	fmt.Println(c.Red(), c.Green(), c.Blue(), c.Alpha())
}

func main() {
	paint := okage.DefaultPaint()
	paint.AntiAlias = false
	paint.Shader, _ = okage.NewLinearGradient(
		okage.PointFromXY(100, 100),
		okage.PointFromXY(900, 900),
		[]okage.GradientStop{
			okage.NewGradientStop(0, okage.ColorFromRGBA8(50, 127, 150, 200)),
			okage.NewGradientStop(1, okage.ColorFromRGBA8(220, 140, 75, 180)),
		},
		okage.SpreadModePad,
		okage.IdentityTransform(),
	)

	pb := okage.NewPathBuilder()
	pb.MoveTo(60, 60)
	pb.LineTo(160, 940)
	pb.CubicTo(380, 840, 660, 800, 940, 800)
	pb.CubicTo(740, 460, 440, 160, 60, 60)
	pb.Close()
	path, _ := pb.Finish()

	pixmap, _ := okage.NewPixmap(1000, 1000)
	pixmap.FillPath(
		path,
		&paint,
		okage.FillRuleWinding,
		okage.IdentityTransform(),
		nil,
	)
	printPixel(pixmap, 400, 600)
}
Output:
101 100 84 190
Example (Mask)

This example ports tiny-skia examples/mask.rs. It fills a rectangle through a mask of two circles.

package main

import (
	"fmt"

	"github.com/xo/okage"
)

// printPixel prints the premultiplied RGBA value of the pixel at x, y.
func printPixel(pixmap *okage.Pixmap, x, y uint32) {
	c, _ := pixmap.Pixel(x, y)
	fmt.Println(c.Red(), c.Green(), c.Blue(), c.Alpha())
}

func main() {
	pb := okage.NewPathBuilder()
	pb.PushCircle(250, 250, 200)
	pb.PushCircle(250, 250, 100)
	clipPath, _ := pb.Finish()

	clipPath, _ = clipPath.Transform(okage.TransformFromRow(1, -0.3, 0, 1, 0, 75))

	mask, _ := okage.NewMask(500, 500)
	mask.FillPath(clipPath, okage.FillRuleEvenOdd, true, okage.DefaultTransform())

	paint := okage.DefaultPaint()
	paint.AntiAlias = false
	paint.SetColorRGBA8(50, 127, 150, 200)

	pixmap, _ := okage.NewPixmap(500, 500)
	rect, _ := okage.RectFromXYWH(0, 0, 500, 500)
	pixmap.FillRect(
		rect,
		&paint,
		okage.IdentityTransform(),
		mask,
	)
	printPixel(pixmap, 250, 100)
}
Output:
39 100 118 200
Example (Pattern)

This example ports tiny-skia examples/pattern.rs. It fills a circle with a pattern of a small pixmap. The function create_triangle of the example is the same as crate_triangle of tests/integration/pattern.rs, so the example calls crateTriangle of pattern_integration_test.go.

triangle := crateTriangle()

paint := okage.DefaultPaint()
paint.AntiAlias = true
paint.Shader = okage.NewPattern(
	triangle.AsRef(),
	okage.SpreadModeRepeat,
	okage.FilterQualityBicubic,
	1,
	okage.TransformFromRow(1.5, -0.4, 0, -0.8, 5, 1),
)

path, _ := okage.PathFromCircle(200, 200, 180)

pixmap, _ := okage.NewPixmap(400, 400)
pixmap.FillPath(
	path,
	&paint,
	okage.FillRuleWinding,
	okage.IdentityTransform(),
	nil,
)
printPixel(pixmap, 200, 200)
Output:
39 100 118 200
Example (Stroke)

This example ports tiny-skia examples/stroke.rs. It strokes a star with a dash and round caps.

Based on https://fiddle.skia.org/c/@compose_path

package main

import (
	"fmt"
	"math"

	"github.com/xo/okage"
)

// printPixel prints the premultiplied RGBA value of the pixel at x, y.
func printPixel(pixmap *okage.Pixmap, x, y uint32) {
	c, _ := pixmap.Pixel(x, y)
	fmt.Println(c.Red(), c.Green(), c.Blue(), c.Alpha())
}

func main() {
	paint := okage.DefaultPaint()
	paint.SetColorRGBA8(0, 127, 0, 200)
	paint.AntiAlias = true

	const radius float32 = 250
	const center float32 = 250
	pb := okage.NewPathBuilder()
	pb.MoveTo(center+radius, center)
	for i := 1; i < 8; i++ {
		a := 2.6927937 * float32(i)
		// Rust calls cosf and sinf of the C library. The functions of the
		// package math can give another last bit for a rare input.
		cos := float32(math.Cos(float64(a)))
		sin := float32(math.Sin(float64(a)))
		pb.LineTo(center+float32(radius*cos), center+float32(radius*sin))
	}
	path, _ := pb.Finish()

	stroke := okage.DefaultStroke()
	stroke.Width = 6
	stroke.LineCap = okage.LineCapRound
	stroke.Dash, _ = okage.NewStrokeDash([]float32{20, 40}, 0)

	pixmap, _ := okage.NewPixmap(500, 500)
	pixmap.StrokePath(path, &paint, &stroke, okage.IdentityTransform(), nil)
	printPixel(pixmap, 497, 250)
}
Output:
0 100 0 200

Index

Examples

Constants

View Source
const (
	// LineCapButt is LineCap::Butt.
	LineCapButt = path.LineCapButt
	// LineCapRound is LineCap::Round.
	LineCapRound = path.LineCapRound
	// LineCapSquare is LineCap::Square.
	LineCapSquare = path.LineCapSquare

	// LineJoinMiter is LineJoin::Miter.
	LineJoinMiter = path.LineJoinMiter
	// LineJoinMiterClip is LineJoin::MiterClip.
	LineJoinMiterClip = path.LineJoinMiterClip
	// LineJoinRound is LineJoin::Round.
	LineJoinRound = path.LineJoinRound
	// LineJoinBevel is LineJoin::Bevel.
	LineJoinBevel = path.LineJoinBevel

	// PathSegmentMoveTo is PathSegment::MoveTo.
	PathSegmentMoveTo = path.PathSegmentMoveTo
	// PathSegmentLineTo is PathSegment::LineTo.
	PathSegmentLineTo = path.PathSegmentLineTo
	// PathSegmentQuadTo is PathSegment::QuadTo.
	PathSegmentQuadTo = path.PathSegmentQuadTo
	// PathSegmentCubicTo is PathSegment::CubicTo.
	PathSegmentCubicTo = path.PathSegmentCubicTo
	// PathSegmentClose is PathSegment::Close.
	PathSegmentClose = path.PathSegmentClose
)

The constants below are the variants of the enums that tiny-skia src/lib.rs re-exports. In Rust, a variant comes with its enum.

View Source
const AlphaOpaque = path.NormalizedF32One

AlphaOpaque is ALPHA_OPAQUE in tiny-skia src/color.rs. It represents a fully opaque alpha value.

View Source
const AlphaTransparent = path.NormalizedF32Zero

AlphaTransparent is ALPHA_TRANSPARENT in tiny-skia src/color.rs. It represents a fully transparent alpha value.

View Source
const AlphaU8Opaque uint8 = 0xFF

AlphaU8Opaque is ALPHA_U8_OPAQUE in tiny-skia src/color.rs. It represents a fully opaque AlphaU8 value.

View Source
const AlphaU8Transparent uint8 = 0x00

AlphaU8Transparent is ALPHA_U8_TRANSPARENT in tiny-skia src/color.rs. It represents a fully transparent AlphaU8 value.

View Source
const BytesPerPixel = 4

BytesPerPixel is BYTES_PER_PIXEL in tiny-skia src/pixmap.rs. It is the number of bytes per pixel.

Variables

View Source
var ColorBlack = Color{/* contains filtered or unexported fields */}

ColorBlack is Color::BLACK in tiny-skia src/color.rs. It is a black color.

View Source
var ColorTransparent = Color{/* contains filtered or unexported fields */}

ColorTransparent is Color::TRANSPARENT in tiny-skia src/color.rs. It is a transparent color.

View Source
var ColorWhite = Color{/* contains filtered or unexported fields */}

ColorWhite is Color::WHITE in tiny-skia src/color.rs. It is a white color.

View Source
var PremultipliedColorU8Transparent = premultipliedColorU8FromRGBAUnchecked(0, 0, 0, 0)

PremultipliedColorU8Transparent is PremultipliedColorU8::TRANSPARENT in tiny-skia src/color.rs. It is a transparent color.

Functions

func ComputeResolutionScale

func ComputeResolutionScale(ts Transform) float32

ComputeResolutionScale is PathStroker::compute_resolution_scale. It calls path.ComputeResolutionScale.

Types

type BlendMode

type BlendMode uint8

BlendMode is BlendMode in tiny-skia src/blend_mode.rs. It is a blending mode.

const (
	// BlendModeClear is BlendMode::Clear. It replaces destination with zero:
	// fully transparent.
	BlendModeClear BlendMode = iota
	// BlendModeSource is BlendMode::Source. It replaces destination.
	BlendModeSource
	// BlendModeDestination is BlendMode::Destination. It preserves
	// destination.
	BlendModeDestination
	// BlendModeSourceOver is BlendMode::SourceOver, the default. It draws
	// source over destination.
	BlendModeSourceOver
	// BlendModeDestinationOver is BlendMode::DestinationOver. It draws
	// destination over source.
	BlendModeDestinationOver
	// BlendModeSourceIn is BlendMode::SourceIn. It keeps the source inside
	// destination.
	BlendModeSourceIn
	// BlendModeDestinationIn is BlendMode::DestinationIn. It keeps the
	// destination inside source.
	BlendModeDestinationIn
	// BlendModeSourceOut is BlendMode::SourceOut. It keeps the source
	// outside destination.
	BlendModeSourceOut
	// BlendModeDestinationOut is BlendMode::DestinationOut. It keeps the
	// destination outside source.
	BlendModeDestinationOut
	// BlendModeSourceAtop is BlendMode::SourceAtop. It blends the source
	// inside destination with destination.
	BlendModeSourceAtop
	// BlendModeDestinationAtop is BlendMode::DestinationAtop. It blends the
	// destination inside source with source.
	BlendModeDestinationAtop
	// BlendModeXor is BlendMode::Xor. It keeps each of source and
	// destination outside the other.
	BlendModeXor
	// BlendModePlus is BlendMode::Plus. It is the sum of colors.
	BlendModePlus
	// BlendModeModulate is BlendMode::Modulate. It is the product of
	// premultiplied colors. It darkens destination.
	BlendModeModulate
	// BlendModeScreen is BlendMode::Screen. It multiplies the inverse of the
	// pixels and inverts the result. It brightens destination.
	BlendModeScreen
	// BlendModeOverlay is BlendMode::Overlay. It multiplies or screens,
	// depending on destination.
	BlendModeOverlay
	// BlendModeDarken is BlendMode::Darken. It keeps the darker of source
	// and destination.
	BlendModeDarken
	// BlendModeLighten is BlendMode::Lighten. It keeps the lighter of source
	// and destination.
	BlendModeLighten
	// BlendModeColorDodge is BlendMode::ColorDodge. It brightens destination
	// to reflect source.
	BlendModeColorDodge
	// BlendModeColorBurn is BlendMode::ColorBurn. It darkens destination to
	// reflect source.
	BlendModeColorBurn
	// BlendModeHardLight is BlendMode::HardLight. It multiplies or screens,
	// depending on source.
	BlendModeHardLight
	// BlendModeSoftLight is BlendMode::SoftLight. It lightens or darkens,
	// depending on source.
	BlendModeSoftLight
	// BlendModeDifference is BlendMode::Difference. It subtracts the darker
	// from the lighter with higher contrast.
	BlendModeDifference
	// BlendModeExclusion is BlendMode::Exclusion. It subtracts the darker
	// from the lighter with lower contrast.
	BlendModeExclusion
	// BlendModeMultiply is BlendMode::Multiply. It multiplies source with
	// destination, which darkens the image.
	BlendModeMultiply
	// BlendModeHue is BlendMode::Hue. It takes the hue of source with the
	// saturation and luminosity of destination.
	BlendModeHue
	// BlendModeSaturation is BlendMode::Saturation. It takes the saturation
	// of source with the hue and luminosity of destination.
	BlendModeSaturation
	// BlendModeColor is BlendMode::Color. It takes the hue and saturation of
	// source with the luminosity of destination.
	BlendModeColor
	// BlendModeLuminosity is BlendMode::Luminosity. It takes the luminosity
	// of source with the hue and saturation of destination.
	BlendModeLuminosity
)

The values of BlendMode, in the order of the Rust enum.

func (BlendMode) String

func (m BlendMode) String() string

String satisfies the fmt.Stringer interface. It returns the name of the Rust variant.

type Color

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

Color is Color in tiny-skia src/color.rs. It is an RGBA color value that holds four floating point components.

All values are in the range 0..=1.

func ColorFromRGBA

func ColorFromRGBA(r, g, b, a float32) (Color, bool)

ColorFromRGBA is Color::from_rgba in tiny-skia src/color.rs. It creates a new color from 4 components.

All values must be in the range 0..=1. If not, it returns false.

func ColorFromRGBA8

func ColorFromRGBA8(r, g, b, a uint8) Color

ColorFromRGBA8 is Color::from_rgba8 in tiny-skia src/color.rs. It creates a new color from 4 components.

Each uint8 is divided by 255 to get the float component.

func ColorFromRGBAUnchecked

func ColorFromRGBAUnchecked(r, g, b, a float32) Color

ColorFromRGBAUnchecked is Color::from_rgba_unchecked in tiny-skia src/color.rs. It creates a new color from 4 components.

All values must be in the range 0..=1. It does not check them.

func (Color) Alpha

func (c Color) Alpha() float32

Alpha is Color::alpha in tiny-skia src/color.rs. It returns the alpha component of the color.

The value is guaranteed to be in the range 0..=1.

func (*Color) ApplyOpacity

func (c *Color) ApplyOpacity(opacity float32)

ApplyOpacity is Color::apply_opacity in tiny-skia src/color.rs. It shifts the opacity of the color.

It multiplies the alpha of the color by opacity. opacity is clamped to the range 0..=1 first. The final alpha is also clamped.

func (Color) Blue

func (c Color) Blue() float32

Blue is Color::blue in tiny-skia src/color.rs. It returns the blue component of the color.

The value is guaranteed to be in the range 0..=1.

func (Color) Green

func (c Color) Green() float32

Green is Color::green in tiny-skia src/color.rs. It returns the green component of the color.

The value is guaranteed to be in the range 0..=1.

func (Color) IsOpaque

func (c Color) IsOpaque() bool

IsOpaque is Color::is_opaque in tiny-skia src/color.rs. It returns true if the alpha is 1.0.

func (Color) Premultiply

func (c Color) Premultiply() PremultipliedColor

Premultiply is Color::premultiply in tiny-skia src/color.rs. It converts the color into a premultiplied color.

func (Color) Red

func (c Color) Red() float32

Red is Color::red in tiny-skia src/color.rs. It returns the red component of the color.

The value is guaranteed to be in the range 0..=1.

func (*Color) SetAlpha

func (c *Color) SetAlpha(v float32)

SetAlpha is Color::set_alpha in tiny-skia src/color.rs. It sets the alpha component.

The new value is clipped to the range 0..=1.

func (*Color) SetBlue

func (c *Color) SetBlue(v float32)

SetBlue is Color::set_blue in tiny-skia src/color.rs. It sets the blue component.

The new value is clipped to the range 0..=1.

func (*Color) SetGreen

func (c *Color) SetGreen(v float32)

SetGreen is Color::set_green in tiny-skia src/color.rs. It sets the green component.

The new value is clipped to the range 0..=1.

func (*Color) SetRed

func (c *Color) SetRed(v float32)

SetRed is Color::set_red in tiny-skia src/color.rs. It sets the red component.

The new value is clipped to the range 0..=1.

func (Color) ToColorU8

func (c Color) ToColorU8() ColorU8

ToColorU8 is Color::to_color_u8 in tiny-skia src/color.rs. It converts the color into a ColorU8.

type ColorSpace

type ColorSpace uint8

ColorSpace is ColorSpace in tiny-skia src/color.rs. It is the color space that is used to interpret the values of pixels.

This is a very limited subset of SkColorSpace.

const (
	// ColorSpaceLinear is linear RGB, the default. It assumes that #7f7f7f
	// is half as bright as #ffffff.
	ColorSpaceLinear ColorSpace = iota

	// ColorSpaceGamma2 applies a gamma factor of 2.
	//
	// This is the fastest gamma correction to apply, and it produces
	// reasonable quality blending.
	ColorSpaceGamma2

	// ColorSpaceSimpleSRGB applies a gamma factor of 2.2.
	//
	// This is also known as "simple sRGB". It is very close to the actual
	// gamma function that the sRGB color space specifies, but much faster to
	// compute.
	ColorSpaceSimpleSRGB

	// ColorSpaceFullSRGBGamma applies the full sRGB gamma function.
	//
	// This does not convert the RGB colors to CIE XYZ for blending. It only
	// applies the (full) gamma function.
	ColorSpaceFullSRGBGamma
)

func (ColorSpace) String

func (cs ColorSpace) String() string

String satisfies the fmt.Stringer interface. It returns the name of the Rust variant.

type ColorU8

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

ColorU8 is ColorU8 in tiny-skia src/color.rs. It is a 32-bit RGBA color value.

Byte order: RGBA.

func ColorU8FromRGBA

func ColorU8FromRGBA(r, g, b, a uint8) ColorU8

ColorU8FromRGBA is ColorU8::from_rgba in tiny-skia src/color.rs. It creates a new color.

func (ColorU8) Alpha

func (c ColorU8) Alpha() uint8

Alpha is ColorU8::alpha in tiny-skia src/color.rs. It returns the alpha component of the color.

func (ColorU8) Blue

func (c ColorU8) Blue() uint8

Blue is ColorU8::blue in tiny-skia src/color.rs. It returns the blue component of the color.

func (ColorU8) Green

func (c ColorU8) Green() uint8

Green is ColorU8::green in tiny-skia src/color.rs. It returns the green component of the color.

func (ColorU8) IsOpaque

func (c ColorU8) IsOpaque() bool

IsOpaque is ColorU8::is_opaque in tiny-skia src/color.rs. It returns true if the alpha is 255.

func (ColorU8) Premultiply

func (c ColorU8) Premultiply() PremultipliedColorU8

Premultiply is ColorU8::premultiply in tiny-skia src/color.rs. It converts the color into a premultiplied color.

func (ColorU8) Red

func (c ColorU8) Red() uint8

Red is ColorU8::red in tiny-skia src/color.rs. It returns the red component of the color.

type Coverage added in v0.11.0

type Coverage uint8

Coverage is the grid of samples from which an antialiased fill computes the coverage of a pixel. It ports no upstream type (D54).

const (
	// Coverage4x4 takes 4 by 4 samples in each pixel, as tiny-skia does. The
	// coverage of a pixel moves in steps of 1/16. It is the zero value and
	// the default, and it gives the same bytes as tiny-skia.
	Coverage4x4 Coverage = iota
	// Coverage8x8 takes 8 by 8 samples in each pixel. The coverage of a
	// pixel moves in steps of 1/64, so the edges of small text are closer
	// to the edges that FreeType and Cairo draw. A fill whose area on the
	// pixmap is wider or higher than 4095 pixels takes 4 by 4 samples.
	Coverage8x8
)

func (Coverage) String added in v0.11.0

func (c Coverage) String() string

String satisfies the fmt.Stringer interface.

type Error

type Error string

Error is an error of okage. Each sentinel error of okage is a constant of this type, so that a caller can compare it with errors.Is.

const (
	// ErrDecodingPNG is the error of DecodePNG, LoadPNG, DecodeMaskPNG and
	// LoadMaskPNG when the package image/png, or the file system, returns an
	// error. okage wraps that error with this one. Upstream returns the error
	// of the crate png.
	ErrDecodingPNG Error = "decoding png"

	// ErrEncodingPNG is the error of EncodePNG and SavePNG of a Pixmap and of
	// a Mask when the package image/png, or the file system, returns an
	// error. okage wraps that error with this one. Upstream returns the error
	// of the crate png.
	ErrEncodingPNG Error = "encoding png"

	// ErrUnsupportedPNG is the error of DecodePNG and DecodeMaskPNG for a PNG
	// image that tiny-skia does not support. Upstream gives "unsupported bit
	// depth", "indexed PNG is not supported" and "only grayscale masks are
	// supported".
	ErrUnsupportedPNG Error = "decoding png: unsupported image"

	// ErrInvalidImageSize is the error of DecodePNG and DecodeMaskPNG for an
	// image with a zero width or height. Upstream gives "invalid image size".
	ErrInvalidImageSize Error = "decoding png: invalid image size"

	// ErrImageTooBig is the error of DecodePNG for an image that is larger
	// than a Pixmap can hold. Upstream gives "image is too big".
	ErrImageTooBig Error = "decoding png: image is too big"

	// ErrCreatingPixmap is the error of DecodePNG when the decoded pixels do
	// not make a Pixmap. Upstream gives "failed to create a pixmap".
	ErrCreatingPixmap Error = "decoding png: creating a pixmap"

	// ErrCreatingMask is the error of DecodeMaskPNG when the decoded values do
	// not make a Mask. Upstream gives "failed to create a mask".
	ErrCreatingMask Error = "decoding png: creating a mask"
)

The sentinel errors of okage.

const (
	// ErrXMLInvalidXMLPrefixURI is Error::InvalidXmlPrefixUri of roxmltree.
	// The `xmlns:xml` attribute must have an
	// <http://www.w3.org/XML/1998/namespace> URI.
	ErrXMLInvalidXMLPrefixURI Error = "parsing xml: 'xml' namespace prefix mapped to wrong URI"

	// ErrXMLUnexpectedXMLURI is Error::UnexpectedXmlUri of roxmltree. Only
	// the `xmlns:xml` attribute can have the
	// <http://www.w3.org/XML/1998/namespace> URI.
	ErrXMLUnexpectedXMLURI Error = "parsing xml: the 'xml' namespace URI is used for not 'xml' prefix"

	// ErrXMLUnexpectedXMLNSURI is Error::UnexpectedXmlnsUri of roxmltree.
	// The <http://www.w3.org/2000/xmlns/> URI must not be declared.
	ErrXMLUnexpectedXMLNSURI Error = "parsing xml: the 'xmlns' URI is used, but it must not be declared"

	// ErrXMLInvalidElementNamePrefix is Error::InvalidElementNamePrefix of
	// roxmltree. `xmlns` can not be used as an element prefix.
	ErrXMLInvalidElementNamePrefix Error = "parsing xml: the 'xmlns' prefix is used, but it must not be"

	// ErrXMLDuplicatedNamespace is Error::DuplicatedNamespace of roxmltree.
	// A namespace was already defined on this element.
	ErrXMLDuplicatedNamespace Error = "parsing xml: namespace is already defined"

	// ErrXMLUnknownNamespace is Error::UnknownNamespace of roxmltree. An
	// element or an attribute has an unknown qualified name prefix.
	ErrXMLUnknownNamespace Error = "parsing xml: an unknown namespace prefix"

	// ErrXMLUnexpectedCloseTag is Error::UnexpectedCloseTag of roxmltree.
	// The tree structure is not correct.
	ErrXMLUnexpectedCloseTag Error = "parsing xml: unexpected close tag name"

	// ErrXMLUnexpectedEntityCloseTag is Error::UnexpectedEntityCloseTag of
	// roxmltree. An entity value starts with a close tag.
	ErrXMLUnexpectedEntityCloseTag Error = "parsing xml: unexpected close tag"

	// ErrXMLUnknownEntityReference is Error::UnknownEntityReference of
	// roxmltree. A reference names an entity that the DTD does not define.
	ErrXMLUnknownEntityReference Error = "parsing xml: unknown entity reference"

	// ErrXMLMalformedEntityReference is Error::MalformedEntityReference of
	// roxmltree. A `&` character inside an attribute value or text does not
	// start a correct reference.
	ErrXMLMalformedEntityReference Error = "parsing xml: malformed entity reference"

	// ErrXMLEntityReferenceLoop is Error::EntityReferenceLoop of roxmltree.
	// The depth limit of entities is 10, and an entity can expand 255
	// references at most.
	ErrXMLEntityReferenceLoop Error = "parsing xml: a possible entity reference loop is detected"

	// ErrXMLInvalidAttributeValue is Error::InvalidAttributeValue of
	// roxmltree. An attribute value cannot have a `<` character.
	ErrXMLInvalidAttributeValue Error = "parsing xml: unescaped '<' found"

	// ErrXMLDuplicatedAttribute is Error::DuplicatedAttribute of roxmltree.
	// An element has a duplicated attribute, after namespaces are resolved.
	ErrXMLDuplicatedAttribute Error = "parsing xml: attribute is already defined"

	// ErrXMLNoRootNode is Error::NoRootNode of roxmltree. The XML document
	// must have at least one element.
	ErrXMLNoRootNode Error = "parsing xml: the document does not have a root node"

	// ErrXMLUnclosedRootNode is Error::UnclosedRootNode of roxmltree. The
	// root node was opened but never closed.
	ErrXMLUnclosedRootNode Error = "parsing xml: the root node was opened but never closed"

	// ErrXMLUnexpectedDeclaration is Error::UnexpectedDeclaration of
	// roxmltree. An XML document can have only one XML declaration, at its
	// start.
	ErrXMLUnexpectedDeclaration Error = "parsing xml: unexpected XML declaration"

	// ErrXMLDTDDetected is Error::DtdDetected of roxmltree. The document has
	// a DTD and the option AllowDTD is false.
	ErrXMLDTDDetected Error = "parsing xml: XML with DTD detected"

	// ErrXMLNodesLimitReached is Error::NodesLimitReached of roxmltree. The
	// document has more nodes than the option NodesLimit allows.
	ErrXMLNodesLimitReached Error = "parsing xml: nodes limit reached"

	// ErrXMLAttributesLimitReached is Error::AttributesLimitReached of
	// roxmltree. The document has too many attributes.
	ErrXMLAttributesLimitReached Error = "parsing xml: more than 2^32 attributes were parsed"

	// ErrXMLNamespacesLimitReached is Error::NamespacesLimitReached of
	// roxmltree. The document has too many namespaces.
	ErrXMLNamespacesLimitReached Error = "parsing xml: more than 2^16 unique namespaces were parsed"

	// ErrXMLInvalidName is Error::InvalidName of roxmltree.
	ErrXMLInvalidName Error = "parsing xml: invalid name token"

	// ErrXMLNonXMLChar is Error::NonXmlChar of roxmltree. The valid
	// characters are those of <https://www.w3.org/TR/xml/#char32>.
	ErrXMLNonXMLChar Error = "parsing xml: a non-XML character found"

	// ErrXMLInvalidChar is Error::InvalidChar of roxmltree. A byte is not
	// the one that was expected.
	ErrXMLInvalidChar Error = "parsing xml: unexpected character"

	// ErrXMLInvalidChar2 is Error::InvalidChar2 of roxmltree. A byte is not
	// of the kind that was expected.
	ErrXMLInvalidChar2 Error = "parsing xml: unexpected character kind"

	// ErrXMLInvalidString is Error::InvalidString of roxmltree. A string is
	// not the one that was expected.
	ErrXMLInvalidString Error = "parsing xml: unexpected string"

	// ErrXMLInvalidExternalID is Error::InvalidExternalID of roxmltree. The
	// DTD has an ExternalID that is not correct.
	ErrXMLInvalidExternalID Error = "parsing xml: invalid ExternalID"

	// ErrXMLEntityResolver is Error::EntityResolver of roxmltree. The entity
	// resolver returned an error.
	ErrXMLEntityResolver Error = "parsing xml: entity resolver failed"

	// ErrXMLInvalidComment is Error::InvalidComment of roxmltree. A comment
	// cannot contain `--` or end with `-`.
	ErrXMLInvalidComment Error = "parsing xml: comment contains '--'"

	// ErrXMLInvalidCharacterData is Error::InvalidCharacterData of
	// roxmltree. Character data cannot contain `]]>`.
	ErrXMLInvalidCharacterData Error = "parsing xml: ']]>' is not allowed inside a character data"

	// ErrXMLUnknownToken is Error::UnknownToken of roxmltree.
	ErrXMLUnknownToken Error = "parsing xml: unknown token" //nolint:gosec // G101: an error message, not a credential.

	// ErrXMLUnexpectedEndOfStream is Error::UnexpectedEndOfStream of
	// roxmltree. The stream ended earlier than expected.
	ErrXMLUnexpectedEndOfStream Error = "parsing xml: unexpected end of stream"

	// ErrXMLBuildOrder is the error of a roxmltree.Builder for a call out of
	// order, such as an attribute after the content of an element, a second
	// root element, text outside the root element, or a call after Document
	// (D58). Upstream has no Builder.
	ErrXMLBuildOrder Error = "building xml: call out of order"
)

The sentinel errors of roxmltree.

const (
	// ErrCSSUnexpectedEndOfStream is Error::UnexpectedEndOfStream in
	// simplecss src/lib.rs. The stream ended earlier than the parser
	// expected. Upstream gives "unexpected end of stream".
	ErrCSSUnexpectedEndOfStream Error = "parsing css: unexpected end of stream"

	// ErrCSSInvalidIdent is Error::InvalidIdent in simplecss src/lib.rs.
	// Upstream gives "invalid ident at <row>:<col>".
	ErrCSSInvalidIdent Error = "parsing css: invalid ident"

	// ErrCSSInvalidComment is Error::InvalidComment in simplecss src/lib.rs,
	// for a comment that is not closed. Upstream gives "invalid comment at
	// <row>:<col>".
	ErrCSSInvalidComment Error = "parsing css: invalid comment"

	// ErrCSSInvalidValue is Error::InvalidValue in simplecss src/lib.rs, for
	// an invalid value of a declaration. Upstream gives "invalid value at
	// <row>:<col>".
	ErrCSSInvalidValue Error = "parsing css: invalid value"

	// ErrCSSInvalidByte is Error::InvalidByte in simplecss src/lib.rs.
	// Upstream gives "expected '<byte>' not '<byte>' at <row>:<col>".
	ErrCSSInvalidByte Error = "parsing css: invalid byte"

	// ErrCSSSelectorMissing is Error::SelectorMissing in simplecss
	// src/lib.rs. Upstream gives "selector missing".
	ErrCSSSelectorMissing Error = "parsing css: selector missing"

	// ErrCSSUnexpectedSelector is Error::UnexpectedSelector in simplecss
	// src/lib.rs. Upstream gives "unexpected selector".
	ErrCSSUnexpectedSelector Error = "parsing css: unexpected selector"

	// ErrCSSUnexpectedCombinator is Error::UnexpectedCombinator in simplecss
	// src/lib.rs. Upstream gives "unexpected combinator".
	ErrCSSUnexpectedCombinator Error = "parsing css: unexpected combinator"

	// ErrCSSInvalidAttributeSelector is Error::InvalidAttributeSelector in
	// simplecss src/lib.rs, for an invalid or unsupported attribute
	// selector. Upstream gives "invalid or unsupported attribute selector".
	ErrCSSInvalidAttributeSelector Error = "parsing css: invalid or unsupported attribute selector"

	// ErrCSSInvalidLanguagePseudoClass is Error::InvalidLanguagePseudoClass
	// in simplecss src/lib.rs. Upstream gives "invalid language
	// pseudo-class".
	ErrCSSInvalidLanguagePseudoClass Error = "parsing css: invalid language pseudo-class"
)

The sentinel errors of internal/simplecss.

const (
	// ErrSVGTypesUnexpectedEndOfStream is Error::UnexpectedEndOfStream in
	// svgtypes src/error.rs. An input data ended earlier than expected.
	ErrSVGTypesUnexpectedEndOfStream Error = "parsing svg value: unexpected end of stream"

	// ErrSVGTypesUnexpectedData is Error::UnexpectedData in svgtypes
	// src/error.rs. An input text contains unknown data. The error wraps it
	// with the position.
	ErrSVGTypesUnexpectedData Error = "parsing svg value: unexpected data"

	// ErrSVGTypesInvalidValue is Error::InvalidValue in svgtypes src/error.rs.
	// A provided string does not have a valid data.
	ErrSVGTypesInvalidValue Error = "parsing svg value: invalid value"

	// ErrSVGTypesInvalidIdent is Error::InvalidIdent in svgtypes src/error.rs.
	// An invalid CSS ident.
	ErrSVGTypesInvalidIdent Error = "parsing svg value: invalid ident"

	// ErrSVGTypesInvalidChar is Error::InvalidChar in svgtypes src/error.rs.
	// An invalid or unexpected character. The error wraps it with the actual
	// character, the expected characters and the position.
	ErrSVGTypesInvalidChar Error = "parsing svg value: invalid char"

	// ErrSVGTypesInvalidString is Error::InvalidString in svgtypes
	// src/error.rs. An unexpected string. The error wraps it with the actual
	// string, the expected strings and the position.
	ErrSVGTypesInvalidString Error = "parsing svg value: invalid string"

	// ErrSVGTypesInvalidNumber is Error::InvalidNumber in svgtypes
	// src/error.rs. An invalid number. The error wraps it with the position.
	ErrSVGTypesInvalidNumber Error = "parsing svg value: invalid number"
)

The sentinel errors of the enum Error in svgtypes src/error.rs.

const (
	// ErrSVGTypesViewBoxInvalidNumber is ViewBoxError::InvalidNumber in
	// svgtypes src/viewbox.rs. One of the numbers is invalid.
	ErrSVGTypesViewBoxInvalidNumber Error = "parsing svg value: viewBox contains an invalid number"

	// ErrSVGTypesViewBoxInvalidSize is ViewBoxError::InvalidSize in svgtypes
	// src/viewbox.rs. The viewBox has a negative or zero size.
	ErrSVGTypesViewBoxInvalidSize Error = "parsing svg value: viewBox has a negative or zero size"
)

The sentinel errors of the enum ViewBoxError in svgtypes src/viewbox.rs.

const (
	// ErrSVGTypesTransformOriginMissingParameters is
	// TransformOriginError::MissingParameters in svgtypes
	// src/transform_origin.rs.
	ErrSVGTypesTransformOriginMissingParameters Error = "parsing svg value: transform origin doesn't have enough parameters"

	// ErrSVGTypesTransformOriginInvalidParameters is
	// TransformOriginError::InvalidParameters in svgtypes
	// src/transform_origin.rs. One of the parameters is invalid.
	ErrSVGTypesTransformOriginInvalidParameters Error = "parsing svg value: transform origin has invalid parameters"

	// ErrSVGTypesTransformOriginZIndexIsPercentage is
	// TransformOriginError::ZIndexIsPercentage in svgtypes
	// src/transform_origin.rs. The z offset is a percentage.
	ErrSVGTypesTransformOriginZIndexIsPercentage Error = "parsing svg value: z-index cannot be a percentage"
)

The sentinel errors of the enum TransformOriginError in svgtypes src/transform_origin.rs.

const (
	// ErrSVGTypesFilterPercentageValue is
	// FilterValueListParserError::PercentageValue in svgtypes
	// src/filter_functions.rs. A length has a percentage value.
	ErrSVGTypesFilterPercentageValue Error = "parsing svg value: a percentage value detected"

	// ErrSVGTypesFilterNegativeValue is
	// FilterValueListParserError::NegativeValue in svgtypes
	// src/filter_functions.rs. A value is negative.
	ErrSVGTypesFilterNegativeValue Error = "parsing svg value: a negative value detected"

	// ErrSVGTypesFilterInvalidAngle is
	// FilterValueListParserError::InvalidAngle in svgtypes
	// src/filter_functions.rs.
	ErrSVGTypesFilterInvalidAngle Error = "parsing svg value: an invalid angle"

	// ErrSVGTypesFilterMissingDropShadowOffset is
	// FilterValueListParserError::MissingDropShadowOffset in svgtypes
	// src/filter_functions.rs. The offset values of drop-shadow are not set.
	ErrSVGTypesFilterMissingDropShadowOffset Error = "parsing svg value: drop-shadow offset values are expected"

	// ErrSVGTypesFilterInvalidURL is FilterValueListParserError::InvalidUrl
	// in svgtypes src/filter_functions.rs. Usually an empty url.
	ErrSVGTypesFilterInvalidURL Error = "parsing svg value: an invalid url"
)

The sentinel errors of the enum FilterValueListParserError in svgtypes src/filter_functions.rs. Each one wraps the position. The case StreamErrors holds an Error of src/error.rs, and okage returns that error as it is.

const (
	// ErrSVGNotAnUTF8Str is Error::NotAnUtf8Str in usvg src/parser/mod.rs.
	// Only UTF-8 content are supported.
	ErrSVGNotAnUTF8Str Error = "parsing svg: provided data has not an UTF-8 encoding"

	// ErrSVGMalformedGZip is Error::MalformedGZip in usvg
	// src/parser/mod.rs. Compressed SVG must use the GZip algorithm.
	ErrSVGMalformedGZip Error = "parsing svg: provided data has a malformed GZip content"

	// ErrSVGElementsLimitReached is Error::ElementsLimitReached in usvg
	// src/parser/mod.rs. usvg does not allow SVG with more than 1_000_000
	// elements for security reasons.
	ErrSVGElementsLimitReached Error = "parsing svg: the maximum number of SVG elements has been reached"

	// ErrSVGInvalidSize is Error::InvalidSize in usvg src/parser/mod.rs. SVG
	// does not have a valid size. It occurs when width and/or height are
	// <= 0, and also if width, height and viewBox are not set.
	ErrSVGInvalidSize Error = "parsing svg: SVG has an invalid size"

	// ErrSVGParsingFailed is Error::ParsingFailed in usvg
	// src/parser/mod.rs. It failed to parse an SVG data. The error wraps
	// the error of roxmltree. Upstream gives "SVG data parsing
	// failed cause " and the error of roxmltree.
	ErrSVGParsingFailed Error = "parsing svg: SVG data parsing failed"
)

The sentinel errors of the enum Error in usvg src/parser/mod.rs. The case SvgzFeatureNotEnabled has no port, because okage always reads SVGZ data.

const (
	// ErrSVGInvalidRenderSize is the error of a render whose image has no
	// pixel, or more pixels than a pixmap can hold.
	ErrSVGInvalidRenderSize Error = "rendering svg: invalid width or height"

	// ErrSVGInvalidRenderScale is the error of a render whose scale is zero
	// on an axis.
	ErrSVGInvalidRenderScale Error = "rendering svg: invalid scale"
)

The sentinel errors of the Renderer of svg (D36). They take the place of the errors of github.com/xo/resvg for an invalid size or scale.

const (
	// ErrSVGTextInvalidSize is the error of ShapeText when the font size is
	// not larger than 0.
	ErrSVGTextInvalidSize Error = "shaping text: invalid font size"

	// ErrSVGTextNoFont is the error of ShapeText when no font of the
	// database draws the text.
	ErrSVGTextNoFont Error = "shaping text: no font draws the text"
)

The sentinel errors of ShapeText of svg (D37).

const (
	// ErrHTMLSyntax is the error of html.Parse for a label that is not valid
	// XML, or that breaks the grammar of the HTML-like labels of Graphviz.
	// html returns an *html.SyntaxError that wraps it, with the position in
	// the label.
	ErrHTMLSyntax Error = "parsing html: syntax error"

	// ErrHTMLMeasure is the error of html.Label.Layout when the measure of
	// text returns an error. html wraps that error with this one.
	ErrHTMLMeasure Error = "laying out html: measuring text"
)

The sentinel errors of html.

const (
	// ErrLottieParse is the error of lottie.Parse for data that is not a
	// Lottie file that velato reads. lottie wraps the error of the JSON
	// decoder with this one.
	ErrLottieParse Error = "parsing lottie"

	// ErrLottieInvalid is the error of lottie.Parse for a file with an
	// invalid value, such as a frame rate that is not finite and positive.
	ErrLottieInvalid Error = "parsing lottie: invalid value"

	// ErrLottieUnsupported is the error of lottie.Parse for a file with a
	// feature that velato does not support, where velato panics.
	ErrLottieUnsupported Error = "parsing lottie: unsupported feature"

	// ErrLottieEvaluation is the error of the evaluation of a frame for a
	// file whose layers cannot be evaluated, such as a cycle of parents or
	// a missing asset. lottie returns an *lottie.EvaluationError that wraps
	// it.
	ErrLottieEvaluation Error = "evaluating lottie"

	// ErrLottieEmpty is the error of the helpers of lottie that draw or time
	// a composition for a composition with no size, no frames or no frame
	// rate, and for a target size that is not positive (D44).
	ErrLottieEmpty Error = "lottie: no size or no frames"

	// ErrLottieDotLottie is the error of lottie.OpenDotLottie for data that
	// is not a dotLottie archive, or an archive with no animation (D44).
	ErrLottieDotLottie Error = "reading dotlottie"
)

The sentinel errors of lottie (D41).

const (
	// ErrFontData is the error of webfont.Convert and svg.ConvertFontData
	// for a font in WOFF, WOFF2 or EOT whose data is malformed. The
	// conversion wraps a more precise error with this one.
	ErrFontData Error = "converting font data"

	// ErrFontUnsupported is the error of webfont.Convert and
	// svg.ConvertFontData for data that is not a font of a known format, and
	// for an EOT file that uses MicroType Express compression.
	ErrFontUnsupported Error = "converting font data: unsupported format"
)

The sentinel errors of the conversion of fonts in a web format (D45, D51).

const (
	// ErrCSSSelector is SelectorError of cssselect2, for a selector that is
	// invalid or that cssselect2 does not support. cssselect2 returns a
	// *cssselect2.SelectorError that wraps it, with the message of upstream.
	ErrCSSSelector Error = "parsing css selector"
)

The sentinel errors of cssselect2 (D50).

func (Error) Error

func (err Error) Error() string

Error satisfies the error interface.

type FillRule

type FillRule uint8

FillRule is FillRule in tiny-skia src/painter.rs. It is a path filling rule.

const (
	// FillRuleWinding is FillRule::Winding, the default. It specifies that
	// "inside" is computed by a non-zero sum of signed edge crossings.
	FillRuleWinding FillRule = iota
	// FillRuleEvenOdd is FillRule::EvenOdd. It specifies that "inside" is
	// computed by an odd number of edge crossings.
	FillRuleEvenOdd
)

func (FillRule) String

func (r FillRule) String() string

String satisfies the fmt.Stringer interface. It returns the name of the Rust variant.

type FilterQuality

type FilterQuality uint8

FilterQuality is FilterQuality in tiny-skia src/shaders/pattern.rs. It controls how much filtering to be done when transforming images.

const (
	// FilterQualityNearest is FilterQuality::Nearest. It is
	// nearest-neighbor: low quality, but fastest.
	FilterQualityNearest FilterQuality = iota
	// FilterQualityBilinear is FilterQuality::Bilinear.
	FilterQualityBilinear
	// FilterQualityBicubic is FilterQuality::Bicubic: high quality, but
	// slow.
	FilterQualityBicubic
)

The values of FilterQuality, in the order of the Rust enum.

func (FilterQuality) String

func (q FilterQuality) String() string

String satisfies the fmt.Stringer interface. It returns the name of the Rust variant.

type GradientStop

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

GradientStop is GradientStop in tiny-skia src/shaders/gradient.rs. It is a gradient point.

func NewGradientStop

func NewGradientStop(position float32, color Color) GradientStop

NewGradientStop is GradientStop::new in tiny-skia src/shaders/gradient.rs. It creates a new gradient point.

position is clamped to a 0..=1 range.

type IntRect

type IntRect = path.IntRect

IntRect is the re-export of tiny_skia_path::IntRect in tiny-skia src/lib.rs. It is an integer rectangle.

func IntRectFromLTRB

func IntRectFromLTRB(left, top, right, bottom int32) (IntRect, bool)

IntRectFromLTRB is IntRect::from_ltrb. It calls path.IntRectFromLTRB.

func IntRectFromXYWH

func IntRectFromXYWH(x, y int32, width, height uint32) (IntRect, bool)

IntRectFromXYWH is IntRect::from_xywh. It calls path.IntRectFromXYWH.

type IntSize

type IntSize = path.IntSize

IntSize is the re-export of tiny_skia_path::IntSize in tiny-skia src/lib.rs. It is an integer size.

func IntSizeFromWH

func IntSizeFromWH(width, height uint32) (IntSize, bool)

IntSizeFromWH is IntSize::from_wh. It calls path.IntSizeFromWH.

type LineCap

type LineCap = path.LineCap

LineCap is the re-export of tiny_skia_path::LineCap in tiny-skia src/lib.rs. It is what a stroke draws at the ends of an open contour.

type LineJoin

type LineJoin = path.LineJoin

LineJoin is the re-export of tiny_skia_path::LineJoin in tiny-skia src/lib.rs. It is what a stroke draws at the corners of a path.

type LinearGradient

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

LinearGradient is LinearGradient in tiny-skia src/shaders/linear_gradient.rs. It is a linear gradient shader.

func (LinearGradient) ApplyOpacity

func (g LinearGradient) ApplyOpacity(opacity float32) Shader

ApplyOpacity is the arm Shader::LinearGradient of Shader::apply_opacity in tiny-skia src/shaders/mod.rs.

func (LinearGradient) IsOpaque

func (g LinearGradient) IsOpaque() bool

IsOpaque is LinearGradient::is_opaque in tiny-skia src/shaders/linear_gradient.rs, and the arm Shader::LinearGradient of Shader::is_opaque in tiny-skia src/shaders/mod.rs.

func (LinearGradient) Transform

func (g LinearGradient) Transform(ts Transform) Shader

Transform is the arm Shader::LinearGradient of Shader::transform in tiny-skia src/shaders/mod.rs.

type Mask

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

Mask is Mask in tiny-skia src/mask.rs. It is a mask.

During drawing over Pixmap, mask's black (0) "pixels" block rendering and white (255) allow it. Anything in between is used for gradual masking and anti-aliasing.

Unlike Skia, we are using just a simple 8bit alpha mask. It is way slower, but easier to implement.

Port: logger is the logger of D20, which FillPath logs to. The option WithLogger sets it. A nil logger logs nothing.

func DecodeMaskPNG

func DecodeMaskPNG(data []byte, opts ...Option) (*Mask, error)

DecodeMaskPNG is Mask::decode_png in tiny-skia src/mask.rs. It loads a PNG file into a Mask.

Only grayscale images are supported.

Port: upstream decodes with the crate png and asks it to expand a gray image with fewer than 8 bits and to strip 16 bits to 8 bits. The package image/png decodes the image here (D7). It gives an image.Gray for a gray image of 8 bits or fewer, with the same values, and an image.Gray16 for one of 16 bits, whose high byte is kept. opts configure the mask, as D20 says.

func LoadMaskPNG

func LoadMaskPNG(name string, opts ...Option) (*Mask, error)

LoadMaskPNG is Mask::load_png in tiny-skia src/mask.rs. It loads a PNG file into a Mask.

Only grayscale images are supported.

Port: opts configure the mask, as D20 says.

func MaskFromLuminance added in v0.11.0

func MaskFromLuminance(pixmap PixmapRef, backdrop Color, opts ...Option) *Mask

MaskFromLuminance makes a mask from the luminance of pixmap over an opaque backdrop of the color backdrop. It is the soft mask of luminosity of PDF with the backdrop color BC (ISO 32000-2, 11.6.5.2). The value of each pixel is the luminance of the pixel of pixmap, composited with the normal blend mode over the backdrop.

The function ignores the alpha of backdrop, because the backdrop of PDF is opaque. With ColorBlack, or with any color of a luminance of zero, the mask has the same bytes as MaskFromPixmap with MaskTypeLuminance.

opts configure the mask, as D20 says.

func MaskFromPixmap

func MaskFromPixmap(pixmap PixmapRef, maskType MaskType, opts ...Option) *Mask

MaskFromPixmap is Mask::from_pixmap in tiny-skia src/mask.rs. It creates a new mask from a PixmapRef.

Port: opts configure the mask, as D20 says.

func MaskFromVec

func MaskFromVec(data []byte, size path.IntSize, opts ...Option) (*Mask, bool)

MaskFromVec is Mask::from_vec in tiny-skia src/mask.rs. It creates a new mask by taking ownership over a mask buffer.

The size needs to match the data provided.

Port: Rust takes ownership of data. Go keeps data in the mask, so the caller does not use data after the call. opts configure the mask, as D20 says.

func NewMask

func NewMask(width, height uint32, opts ...Option) (*Mask, bool)

NewMask is Mask::new in tiny-skia src/mask.rs. It creates a new mask, allocating a buffer of the given size.

Port: opts configure the mask, as D20 says. Upstream has no options.

func (*Mask) ApplyTransfer added in v0.11.0

func (m *Mask) ApplyTransfer(table *[256]uint8)

ApplyTransfer changes each value v of the mask to table[v]. It applies the transfer function TR of a soft mask of PDF (ISO 32000-2, 11.6.5.2), with the function sampled at the 256 values of a byte. table[i] is the value of the function at i/255, times 255.

func (*Mask) Clear

func (m *Mask) Clear()

Clear is Mask::clear in tiny-skia src/mask.rs. It clears the mask.

It zero-fills the internal data buffer.

func (*Mask) Clone

func (m *Mask) Clone() *Mask

Clone is the derived Clone impl of Mask in tiny-skia src/mask.rs. It returns a copy of the mask with its own data.

func (*Mask) Data

func (m *Mask) Data() []byte

Data is Mask::data in tiny-skia src/mask.rs. It returns the internal data.

func (*Mask) DataMut

func (m *Mask) DataMut() []byte

DataMut is Mask::data_mut in tiny-skia src/mask.rs. It returns the mutable internal data.

func (*Mask) EncodePNG

func (m *Mask) EncodePNG() ([]byte, error)

EncodePNG is Mask::encode_png in tiny-skia src/mask.rs. It encodes the mask into PNG data.

Port: upstream encodes with the crate png, as 8-bit grayscale. The package image/png encodes here (D7), also as 8-bit grayscale. The bytes of the file can differ from upstream, and the decoded values are the same.

func (*Mask) FillPath

func (m *Mask) FillPath(
	p *Path,
	fillRule FillRule,
	antiAlias bool,
	transform Transform,
)

FillPath is Mask::fill_path in tiny-skia src/mask.rs. It draws a filled path onto the mask.

It is almost a direct copy of PixmapMut.FillPath.

In terms of RGB (no alpha) image, it draws a white path on top of black mask.

It does not reset the existing mask content and draws the path on top of existing data.

If the above behavior is undesired, call Mask.Clear first.

This method is intended to be used for simple cases. For more complex masks prefer MaskFromPixmap.

Port: upstream logs a warning with log::warn!. Go logs it to the logger of the mask, as D20 says.

func (*Mask) Height

func (m *Mask) Height() uint32

Height is Mask::height in tiny-skia src/mask.rs. It returns mask's height.

func (*Mask) IntersectPath

func (m *Mask) IntersectPath(
	p *Path,
	fillRule FillRule,
	antiAlias bool,
	transform Transform,
)

IntersectPath is Mask::intersect_path in tiny-skia src/mask.rs. It intersects the provided path with the current clipping path.

A temporary mask with the same size as the current one is created.

Port: the temporary mask comes from a pool, and only the rows that the path can cover are cleared and multiplied. The other pixels of the mask are 0, as the multiplication by 0 of upstream gives. A clip of a page then takes a time that depends on the size of the path, not on the size of the page. The bytes are the same as upstream (D60).

func (*Mask) Invert

func (m *Mask) Invert()

Invert is Mask::invert in tiny-skia src/mask.rs. It inverts the mask.

func (*Mask) SavePNG

func (m *Mask) SavePNG(name string) error

SavePNG is Mask::save_png in tiny-skia src/mask.rs. It saves the mask as a PNG file.

func (*Mask) Size

func (m *Mask) Size() path.IntSize

Size is Mask::size in tiny-skia src/mask.rs. It returns mask's size.

Port: upstream makes it public in the crate only. Go exports it, as Pixmap.Size does.

func (*Mask) String

func (m *Mask) String() string

String is the Debug impl of Mask in tiny-skia src/mask.rs. It satisfies the fmt.Stringer interface.

func (*Mask) Take

func (m *Mask) Take() []byte

Take is Mask::take in tiny-skia src/mask.rs. It consumes the mask and returns its owned internal data.

Port: Rust consumes the mask. Go returns the data, and the caller does not use m after the call.

func (*Mask) Width

func (m *Mask) Width() uint32

Width is Mask::width in tiny-skia src/mask.rs. It returns mask's width.

type MaskType

type MaskType uint8

MaskType is MaskType in tiny-skia src/mask.rs. It is a mask type.

const (
	// MaskTypeAlpha is MaskType::Alpha. It transfers only the Alpha channel
	// from Pixmap to Mask.
	MaskTypeAlpha MaskType = iota

	// MaskTypeLuminance is MaskType::Luminance. It transfers RGB channels as
	// luminance from Pixmap to Mask.
	//
	// Formula: Y = 0.2126 * R + 0.7152 * G + 0.0722 * B.
	MaskTypeLuminance
)

The values of MaskType, in the order of the Rust enum.

func (MaskType) String

func (t MaskType) String() string

String satisfies the fmt.Stringer interface. It returns the name of the Rust variant.

type MeshGradient added in v0.11.0

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

MeshGradient is a shader that fills a mesh of triangles with a color for each corner (D55). It is the shading of the types 4 to 7 of PDF and PostScript, after a caller splits the patches of the types 6 and 7 into triangles. tiny-skia does not have it.

The shader takes the center of each pixel, in the space of the mesh:

  • If triangles cover the center, the last of them in the list gives the color. The color is the interpolation of the colors of its corners.
  • If no triangle covers the center, but the square of the pixel overlaps triangles, the last of them gives the color of its point that is near the center. An antialiased fill of the outline of the mesh then has no dark border.
  • Elsewhere, the color is transparent black.

The shader interpolates the colors without premultiplied alpha, in the ColorSpace of the Paint, and then premultiplies them, as the gradients do.

Two triangles that share an edge compute the same value for it, with the opposite sign. Each pixel thus takes its color from one triangle, and a fill of the mesh has no seam between its triangles. Fill a path that covers the mesh, such as its outline, with the shader. The path, the mask and the blend mode of the fill work as with every shader.

A MeshGradient is never opaque. Its copies share the triangles, which do not change.

func (MeshGradient) ApplyOpacity added in v0.11.0

func (m MeshGradient) ApplyOpacity(opacity float32) Shader

ApplyOpacity satisfies the Shader interface. It returns the shader with the alpha of each color multiplied by opacity.

opacity is clamped to the 0..=1 range.

func (MeshGradient) IsOpaque added in v0.11.0

func (m MeshGradient) IsOpaque() bool

IsOpaque satisfies the Shader interface. A MeshGradient is never opaque, because it is transparent outside its triangles.

func (MeshGradient) Transform added in v0.11.0

func (m MeshGradient) Transform(ts Transform) Shader

Transform satisfies the Shader interface. It returns the shader transformed by ts.

type MeshTriangle added in v0.11.0

type MeshTriangle [3]MeshVertex

MeshTriangle is a triangle of a MeshGradient. The order of its corners does not matter.

type MeshVertex added in v0.11.0

type MeshVertex struct {
	Point Point
	Color Color
}

MeshVertex is a corner of a triangle of a MeshGradient. It holds the point of the corner and the color at that point.

type NonZeroRect

type NonZeroRect = path.NonZeroRect

NonZeroRect is the re-export of tiny_skia_path::NonZeroRect in tiny-skia src/lib.rs. It is a rectangle with a width and a height above zero.

func NonZeroRectFromLTRB

func NonZeroRectFromLTRB(left, top, right, bottom float32) (NonZeroRect, bool)

NonZeroRectFromLTRB is NonZeroRect::from_ltrb. It calls path.NonZeroRectFromLTRB.

func NonZeroRectFromXYWH

func NonZeroRectFromXYWH(x, y, w, h float32) (NonZeroRect, bool)

NonZeroRectFromXYWH is NonZeroRect::from_xywh. It calls path.NonZeroRectFromXYWH.

type Option

type Option func(*options)

Option is an option of a constructor of okage, such as NewPixmap or NewMask. It changes the configuration of the value that the constructor makes.

func WithLogger

func WithLogger(l *slog.Logger) Option

WithLogger is an option that sets the logger of a Pixmap or a Mask. The warnings that tiny-skia logs with log::warn! go to l, with the text of upstream. Without this option, okage logs nothing.

type Paint

type Paint struct {
	// Shader is the paint shader.
	//
	// Default: black color
	Shader Shader

	// BlendMode is the paint blending mode.
	//
	// Default: SourceOver
	BlendMode BlendMode

	// AntiAlias enables anti-aliased painting.
	//
	// Default: true
	AntiAlias bool

	// Colorspace is the colorspace for blending.
	//
	// This enables gamma correction during the blend operation. While skia
	// supports full color-space conversions, we only support a few (simple)
	// cases. Note that any color space other than Linear forces using the
	// high-quality pipeline.
	//
	// Default: Linear
	Colorspace ColorSpace

	// ForceHQPipeline forces the high quality/precision rendering pipeline.
	//
	// tiny-skia, just like Skia, has two rendering pipelines: one uses f32
	// and another one uses u16. The u16 one is usually way faster, but less
	// precise. Which can lead to slight differences.
	//
	// By default, tiny-skia chooses the pipeline automatically, depending on
	// a blending mode and other parameters. But you can force the high
	// quality one using this flag.
	//
	// This feature is especially useful during testing.
	//
	// Unlike the high quality pipeline, the low quality one does not support
	// all rendering stages, therefore we cannot force it like the hq one.
	//
	// Default: false
	ForceHQPipeline bool

	// Coverage is the grid of samples from which an antialiased fill
	// computes the coverage of a pixel. It applies to FillPath, and to a
	// stroke that StrokePath fills. It does not apply to FillRect, to a
	// hairline or to a Mask.
	//
	// Port (D54): upstream has no such field, and always takes 4 by 4
	// samples.
	//
	// Default: Coverage4x4
	Coverage Coverage

	// StrokeAdjust turns on the automatic stroke adjustment of PDF, the SA
	// entry of a graphics state. StrokePath then rounds the width of the
	// stroke on the device to a whole number of pixels, at least 1, and
	// moves each horizontal or vertical line of the path so that the edges
	// of its stroke fall on the borders of the pixels. A thin line then
	// covers whole pixels, and does not spread over two light rows. FillPath
	// ignores it.
	//
	// Port (D54): upstream has no such field.
	//
	// Default: false
	StrokeAdjust bool
}

Paint is Paint in tiny-skia src/painter.rs. It controls how a shape is painted.

Port: the zero Paint is not the default of upstream. Its Shader is nil, its BlendMode is Clear and AntiAlias is false. Use DefaultPaint to get the default of upstream. A nil Shader is not valid, and drawing with it panics.

func DefaultPaint

func DefaultPaint() Paint

DefaultPaint is the Default impl of Paint in tiny-skia src/painter.rs. It returns the default paint: solid black, SourceOver, anti-aliased, linear.

func (*Paint) IsSolidColor

func (p *Paint) IsSolidColor() bool

IsSolidColor is Paint::is_solid_color in tiny-skia src/painter.rs. It checks that the paint source is a solid color.

func (*Paint) SetColor

func (p *Paint) SetColor(color Color)

SetColor is Paint::set_color in tiny-skia src/painter.rs. It sets a paint source to a solid color.

func (*Paint) SetColorRGBA8

func (p *Paint) SetColorRGBA8(r, g, b, a uint8)

SetColorRGBA8 is Paint::set_color_rgba8 in tiny-skia src/painter.rs. It sets a paint source to a solid color.

It is a shorthand for p.Shader = SolidColor(ColorFromRGBA8(r, g, b, a)).

type Path

type Path = path.Path

Path is the re-export of tiny_skia_path::Path in tiny-skia src/lib.rs. It is a Bezier path.

func PathFromCircle

func PathFromCircle(cx, cy, radius float32) (*Path, bool)

PathFromCircle is PathBuilder::from_circle. It calls path.PathFromCircle.

func PathFromOval

func PathFromOval(oval Rect) (*Path, bool)

PathFromOval is PathBuilder::from_oval. It calls path.PathFromOval.

func PathFromRect

func PathFromRect(rect Rect) *Path

PathFromRect is PathBuilder::from_rect. It calls path.PathFromRect.

type PathBuilder

type PathBuilder = path.PathBuilder

PathBuilder is the re-export of tiny_skia_path::PathBuilder in tiny-skia src/lib.rs. It builds a Path.

func NewPathBuilder

func NewPathBuilder() *PathBuilder

NewPathBuilder is PathBuilder::new. It calls path.NewPathBuilder.

func NewPathBuilderWithCapacity

func NewPathBuilderWithCapacity(verbsCapacity, pointsCapacity int) *PathBuilder

NewPathBuilderWithCapacity is PathBuilder::with_capacity. It calls path.NewPathBuilderWithCapacity.

type PathSegment

type PathSegment = path.PathSegment

PathSegment is the re-export of tiny_skia_path::PathSegment in tiny-skia src/lib.rs. It is a segment of a path.

type PathSegmentKind

type PathSegmentKind = path.PathSegmentKind

PathSegmentKind is the kind of a PathSegment. In Rust, it is the variant of the enum PathSegment, which tiny-skia src/lib.rs re-exports.

type PathSegmentsIter

type PathSegmentsIter = path.PathSegmentsIter

PathSegmentsIter is the re-export of tiny_skia_path::PathSegmentsIter in tiny-skia src/lib.rs. It is an iterator over the segments of a path.

type PathStroker

type PathStroker = path.PathStroker

PathStroker is the re-export of tiny_skia_path::PathStroker in tiny-skia src/lib.rs. It makes the outline of a stroke.

func NewPathStroker

func NewPathStroker() *PathStroker

NewPathStroker is PathStroker::new. It calls path.NewPathStroker.

type Pattern

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

Pattern is Pattern in tiny-skia src/shaders/pattern.rs. It is a pattern shader.

Essentially a SkImageShader.

Unlike Skia, we do not support FilterQuality::Medium, because it involves mipmap generation, which adds too much complexity.

func (Pattern) ApplyOpacity

func (p Pattern) ApplyOpacity(opacity float32) Shader

ApplyOpacity is the arm Shader::Pattern of Shader::apply_opacity in tiny-skia src/shaders/mod.rs.

func (Pattern) IsOpaque

func (p Pattern) IsOpaque() bool

IsOpaque is the arm Shader::Pattern of Shader::is_opaque in tiny-skia src/shaders/mod.rs.

func (Pattern) Transform

func (p Pattern) Transform(ts Transform) Shader

Transform is the arm Shader::Pattern of Shader::transform in tiny-skia src/shaders/mod.rs.

type PixelSlice

type PixelSlice []byte

PixelSlice is the Go form of the Rust slices &PremultipliedColorU8 and &mut PremultipliedColorU8, which tiny-skia src/pixmap.rs makes from the bytes of a pixmap with bytemuck. It ports no upstream item.

Go cannot view a []byte as a slice of colors without the package unsafe (D25), so a PixelSlice holds the bytes and reads or writes one pixel at a time. It shares the bytes of the pixmap. Its length is a multiple of BytesPerPixel.

func (PixelSlice) At

At returns the pixel at index i. It panics if i is out of range.

func (PixelSlice) Len

func (s PixelSlice) Len() int

Len returns the number of pixels.

func (PixelSlice) Set

func (s PixelSlice) Set(i int, c PremultipliedColorU8)

Set sets the pixel at index i to c. It panics if i is out of range.

type Pixmap

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

Pixmap is Pixmap in tiny-skia src/pixmap.rs. It is a container that owns premultiplied RGBA pixels.

The data is not aligned, therefore width == stride.

Port: logger is the logger of D20, which the painter logs to. The option WithLogger sets it. A nil logger logs nothing.

func DecodePNG

func DecodePNG(data []byte, opts ...Option) (*Pixmap, error)

DecodePNG is Pixmap::decode_png in tiny-skia src/pixmap.rs. It decodes PNG data into a Pixmap.

Only 8-bit images are supported. Index PNGs are not supported.

Port: upstream decodes with the crate png, and asks it to expand a palette, a gray image with fewer than 8 bits and the tRNS chunk, and to strip 16 bits to 8 bits. The package image/png decodes the image here (D7). The conversion keeps the high byte of a 16-bit value and expands the other formats as the crate png does, so that the same pixels come out. Before it decodes the pixels, it reads the size of the image and makes the size checks of upstream, so that it does not allocate a huge image that upstream rejects later. opts configure the pixmap, as D20 says.

func LoadPNG

func LoadPNG(name string, opts ...Option) (*Pixmap, error)

LoadPNG is Pixmap::load_png in tiny-skia src/pixmap.rs. It loads a PNG file into a Pixmap.

Only 8-bit images are supported. Index PNGs are not supported.

Port: opts configure the pixmap, as D20 says.

func NewPixmap

func NewPixmap(width, height uint32, opts ...Option) (*Pixmap, bool)

NewPixmap is Pixmap::new in tiny-skia src/pixmap.rs. It allocates a new pixmap.

A pixmap is filled with transparent black by default, aka (0, 0, 0, 0).

A zero size is an error, and NewPixmap returns false.

The width of a pixmap is limited by i32::MAX/4.

Port: opts configure the pixmap, as D20 says. Upstream has no options.

func PixmapFromVec

func PixmapFromVec(data []byte, size path.IntSize, opts ...Option) (*Pixmap, bool)

PixmapFromVec is Pixmap::from_vec in tiny-skia src/pixmap.rs. It creates a new pixmap by taking ownership over an image buffer (premultiplied RGBA pixels).

The size needs to match the data provided.

The width of a pixmap is limited by i32::MAX/4.

Port: Rust takes ownership of data. Go keeps data in the pixmap, so the caller does not use data after the call. opts configure the pixmap, as D20 says.

func (*Pixmap) ApplyMask

func (p *Pixmap) ApplyMask(mask *Mask)

ApplyMask is Pixmap::apply_mask in tiny-skia src/painter.rs. It applies a mask.

See PixmapMut.ApplyMask for details.

func (*Pixmap) AsMut

func (p *Pixmap) AsMut() PixmapMut

AsMut is Pixmap::as_mut in tiny-skia src/pixmap.rs. It returns a container that references the data of the pixmap.

func (*Pixmap) AsRGBA

func (p *Pixmap) AsRGBA() *image.RGBA

AsRGBA returns an *image.RGBA that shares the bytes of the pixmap. A change to one is a change to the other. Its bounds start at (0, 0).

func (*Pixmap) AsRef

func (p *Pixmap) AsRef() PixmapRef

AsRef is Pixmap::as_ref in tiny-skia src/pixmap.rs. It returns a container that references the data of the pixmap.

func (*Pixmap) At

func (p *Pixmap) At(x, y int) color.Color

At satisfies the image.Image interface. It returns the premultiplied color of the pixel at (x, y) as a color.RGBA. It returns a transparent color for a position outside the bounds.

func (*Pixmap) Bounds

func (p *Pixmap) Bounds() image.Rectangle

Bounds satisfies the image.Image interface. The bounds start at (0, 0).

func (*Pixmap) Clone

func (p *Pixmap) Clone() *Pixmap

Clone is the derived Clone impl of Pixmap in tiny-skia src/pixmap.rs. It returns a copy of the pixmap with its own data.

func (*Pixmap) CloneRect

func (p *Pixmap) CloneRect(rect IntRect) (*Pixmap, bool)

CloneRect is Pixmap::clone_rect in tiny-skia src/pixmap.rs. It returns a copy of the part of the pixmap that intersects rect.

It returns false when the rect of the pixmap does not contain rect.

func (*Pixmap) ColorModel

func (p *Pixmap) ColorModel() color.Model

ColorModel satisfies the image.Image interface. It returns color.RGBAModel, because the pixels are premultiplied 8-bit RGBA.

func (*Pixmap) Data

func (p *Pixmap) Data() []byte

Data is Pixmap::data in tiny-skia src/pixmap.rs. It returns the internal data.

Byte order: RGBA.

func (*Pixmap) DataMut

func (p *Pixmap) DataMut() []byte

DataMut is Pixmap::data_mut in tiny-skia src/pixmap.rs. It returns the mutable internal data.

Byte order: RGBA.

func (*Pixmap) DrawPixmap

func (p *Pixmap) DrawPixmap(
	x, y int32,
	pixmap PixmapRef,
	paint *PixmapPaint,
	transform Transform,
	mask *Mask,
)

DrawPixmap is Pixmap::draw_pixmap in tiny-skia src/painter.rs. It draws a Pixmap on top of the current Pixmap.

See PixmapMut.DrawPixmap for details. A nil mask is the Rust None.

func (*Pixmap) EncodePNG

func (p *Pixmap) EncodePNG() ([]byte, error)

EncodePNG is Pixmap::encode_png in tiny-skia src/pixmap.rs. It encodes the pixmap into PNG data.

func (*Pixmap) Fill

func (p *Pixmap) Fill(color Color)

Fill is Pixmap::fill in tiny-skia src/pixmap.rs. It fills the entire pixmap with the given color.

func (*Pixmap) FillPath

func (p *Pixmap) FillPath(
	pa *Path,
	paint *Paint,
	fillRule FillRule,
	transform Transform,
	mask *Mask,
)

FillPath is Pixmap::fill_path in tiny-skia src/painter.rs. It draws a filled path onto the pixmap.

See PixmapMut.FillPath for details. A nil mask is the Rust None.

func (*Pixmap) FillRect

func (p *Pixmap) FillRect(
	rect Rect,
	paint *Paint,
	transform Transform,
	mask *Mask,
)

FillRect is Pixmap::fill_rect in tiny-skia src/painter.rs. It draws a filled rectangle onto the pixmap.

See PixmapMut.FillRect for details. A nil mask is the Rust None.

func (*Pixmap) Height

func (p *Pixmap) Height() uint32

Height is Pixmap::height in tiny-skia src/pixmap.rs. It returns the height of the pixmap.

func (*Pixmap) Knockout added in v0.11.0

func (p *Pixmap) Knockout(element, backdrop PixmapRef, shape *Mask)

Knockout calls PixmapMut.Knockout on the pixels of p. See PixmapMut.Knockout for details.

func (*Pixmap) Pixel

func (p *Pixmap) Pixel(x, y uint32) (PremultipliedColorU8, bool)

Pixel is Pixmap::pixel in tiny-skia src/pixmap.rs. It returns the color of a pixel.

It returns false when the position is out of bounds.

func (*Pixmap) Pixels

func (p *Pixmap) Pixels() PixelSlice

Pixels is Pixmap::pixels in tiny-skia src/pixmap.rs. It returns a slice of pixels.

func (*Pixmap) PixelsMut

func (p *Pixmap) PixelsMut() PixelSlice

PixelsMut is Pixmap::pixels_mut in tiny-skia src/pixmap.rs. It returns a mutable slice of pixels.

func (*Pixmap) RemoveBackdrop added in v0.11.0

func (p *Pixmap) RemoveBackdrop(backdrop, group PixmapRef)

RemoveBackdrop calls PixmapMut.RemoveBackdrop on the pixels of p. See PixmapMut.RemoveBackdrop for details.

func (*Pixmap) SavePNG

func (p *Pixmap) SavePNG(name string) error

SavePNG is Pixmap::save_png in tiny-skia src/pixmap.rs. It saves the pixmap as a PNG file.

func (*Pixmap) Set

func (p *Pixmap) Set(x, y int, c color.Color)

Set satisfies the draw.Image interface. It converts c to a premultiplied color.RGBA and stores it at (x, y). It does nothing for a position outside the bounds.

func (*Pixmap) Size

func (p *Pixmap) Size() path.IntSize

Size is Pixmap::size in tiny-skia src/pixmap.rs. It returns the size of the pixmap.

Port: upstream makes it public in the crate only. Go exports it, because the method of PixmapRef has the same name.

func (*Pixmap) StrokePath

func (p *Pixmap) StrokePath(
	pa *Path,
	paint *Paint,
	stroke *Stroke,
	transform Transform,
	mask *Mask,
)

StrokePath is Pixmap::stroke_path in tiny-skia src/painter.rs. It strokes a path.

See PixmapMut.StrokePath for details. A nil mask is the Rust None.

func (*Pixmap) Take

func (p *Pixmap) Take() []byte

Take is Pixmap::take in tiny-skia src/pixmap.rs. It consumes the internal data.

Byte order: RGBA.

Port: Rust consumes the pixmap. Go returns the data, and the caller does not use p after the call.

func (*Pixmap) TakeDemultiplied

func (p *Pixmap) TakeDemultiplied() []byte

TakeDemultiplied is Pixmap::take_demultiplied in tiny-skia src/pixmap.rs. It consumes the pixmap and returns the internal data as demultiplied RGBA bytes.

Byte order: RGBA.

Port: Rust consumes the pixmap. Go changes the data in place and returns it, and the caller does not use p after the call.

func (*Pixmap) Width

func (p *Pixmap) Width() uint32

Width is Pixmap::width in tiny-skia src/pixmap.rs. It returns the width of the pixmap.

type PixmapMut

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

PixmapMut is PixmapMut in tiny-skia src/pixmap.rs. It is a container that references mutable premultiplied RGBA pixels.

It can be created from a Pixmap or from data that the user gives.

The data is not aligned, therefore width == stride.

Port: logger is the logger of D20, which the painter logs to.

func PixmapMutFromBytes

func PixmapMutFromBytes(data []byte, width, height uint32, opts ...Option) (PixmapMut, bool)

PixmapMutFromBytes is PixmapMut::from_bytes in tiny-skia src/pixmap.rs. It creates a new PixmapMut from bytes.

The size must be at least width * height * BytesPerPixel. A zero size is an error. The width is limited by i32::MAX/4.

The data is assumed to have premultiplied RGBA pixels (byte order: RGBA).

Port: opts configure the PixmapMut, as D20 says.

func (*PixmapMut) ApplyMask

func (m *PixmapMut) ApplyMask(mask *Mask)

ApplyMask is PixmapMut::apply_mask in tiny-skia src/painter.rs. It applies a mask.

When a Mask is passed to drawing methods, it is used to mask-out content we are about to draw. This method masks-out an already drawn content. It is not as fast, but can be useful when a mask is not available during drawing.

This method is similar to filling the whole pixmap with another, mask-like pixmap using the DestinationOut blend mode.

The Mask must have the same size as the Pixmap. No transform or offset are allowed.

Port: upstream logs a warning with log::warn!. Go logs it to the logger of the pixmap, as D20 says.

func (*PixmapMut) AsRef

func (m *PixmapMut) AsRef() PixmapRef

AsRef is PixmapMut::as_ref in tiny-skia src/pixmap.rs. It returns a container that references the data of the pixmap.

func (*PixmapMut) DataMut

func (m *PixmapMut) DataMut() []byte

DataMut is PixmapMut::data_mut in tiny-skia src/pixmap.rs. It returns the mutable internal data.

Byte order: RGBA.

func (*PixmapMut) DrawPixmap

func (m *PixmapMut) DrawPixmap(
	x, y int32,
	pixmap PixmapRef,
	paint *PixmapPaint,
	transform Transform,
	mask *Mask,
)

DrawPixmap is PixmapMut::draw_pixmap in tiny-skia src/painter.rs. It draws a Pixmap on top of the current Pixmap.

It is the same as filling a rectangle with a pixmap pattern.

A nil mask is the Rust None.

Port (D53): an image that is aligned to the pixels and drawn with SourceOver takes drawPixmapAligned, which gives the same bytes without the raster pipeline.

func (*PixmapMut) Fill

func (m *PixmapMut) Fill(color Color)

Fill is PixmapMut::fill in tiny-skia src/pixmap.rs. It fills the entire pixmap with the given color.

func (*PixmapMut) FillPath

func (m *PixmapMut) FillPath(
	p *Path,
	paint *Paint,
	fillRule FillRule,
	transform Transform,
	mask *Mask,
)

FillPath is PixmapMut::fill_path in tiny-skia src/painter.rs. It draws a filled path onto the pixmap.

A nil mask is the Rust None.

Port: upstream logs a warning with log::warn!. Go logs it to the logger of the pixmap, as D20 says.

func (*PixmapMut) FillRect

func (m *PixmapMut) FillRect(
	rect Rect,
	paint *Paint,
	transform Transform,
	mask *Mask,
)

FillRect is PixmapMut::fill_rect in tiny-skia src/painter.rs. It draws a filled rectangle onto the pixmap.

This function is usually slower than filling a rectangular path, but it produces better results. Mainly it does not suffer from weird clipping of horizontal/vertical edges.

It is used mainly to render a pixmap onto a pixmap.

A nil mask is the Rust None.

func (*PixmapMut) Height

func (m *PixmapMut) Height() uint32

Height is PixmapMut::height in tiny-skia src/pixmap.rs. It returns the height of the pixmap.

func (*PixmapMut) Knockout added in v0.11.0

func (m *PixmapMut) Knockout(element, backdrop PixmapRef, shape *Mask)

Knockout draws one element of a knockout group (ISO 32000-2, 11.4.8 and 11.6.3). In a knockout group, each element composites with the backdrop of the group, not with the earlier elements. Where the element has shape, it replaces what the earlier elements drew.

m holds the result of the earlier elements of the group. element holds the element drawn onto a copy of backdrop, the initial backdrop of the group. The zero PixmapRef is a transparent backdrop, as in a group that is isolated, and element then holds the element drawn onto a transparent pixmap. shape holds the shape of the element: its coverage, without its opacity. A nil shape covers the whole pixmap.

For each pixel, with the shape f from 0 to 1, the result is element + (m - backdrop)*(1-f), on premultiplied colors. It is the result of the earlier elements where f is 0, and element where f is 1. The function rounds the product to the nearest integer, clamps the alpha between 0 and 255, and clamps each color between 0 and the alpha.

A knockout group that is not isolated also needs the alpha of the group alone for RemoveBackdrop. A caller gets it with a second call of Knockout, on a pixmap that holds that alpha, with the element drawn onto a transparent pixmap and the zero PixmapRef as the backdrop.

m, element, a backdrop that is not the zero PixmapRef, and a shape that is not nil must have the same size. Else the function logs a warning to the logger of m and does nothing.

func (*PixmapMut) PixelsMut

func (m *PixmapMut) PixelsMut() PixelSlice

PixelsMut is PixmapMut::pixels_mut in tiny-skia src/pixmap.rs. It returns a mutable slice of pixels.

func (*PixmapMut) RemoveBackdrop added in v0.11.0

func (m *PixmapMut) RemoveBackdrop(backdrop, group PixmapRef)

RemoveBackdrop turns the result of a group that is not isolated into the result of the group alone, with the contribution of the backdrop removed (ISO 32000-2, 11.6.3). A caller then draws the pixmap onto the backdrop with DrawPixmap, with the blend mode, the opacity and the mask of the group.

A group that is not isolated starts as a copy of its backdrop. Its elements draw onto that copy, so that their blend modes see the backdrop. m holds that result, and backdrop holds the backdrop of the group. The alpha channel of group holds the alpha of the group alone. A caller gets it when it draws each element of the group a second time, onto a transparent pixmap. The colors of group are not read.

PDF gives the color of the result as C = Cn + (Cn - C0) * (a0/ag - a0), with the alpha ag. Cn is the color of m, C0 the color of the backdrop, a0 the alpha of the backdrop, and ag the alpha of group. With premultiplied colors this is c = cn - c0*(1-ag). The function rounds c0*(1-ag) to the nearest integer, and clamps c between 0 and ag.

When the blend mode of the group is SourceOver, its opacity is 1 and it has no mask, DrawPixmap draws the result onto the backdrop and gives the colors of m again, where no clamp changed them. Over an opaque backdrop, it gives the same bytes as m. Over a backdrop that is not opaque, the alpha can differ by 1, because the alpha of m is the union a0 + ag - a0*ag, and the pipeline rounds it in other steps.

m, backdrop and group must have the same size. Else the function logs a warning to the logger of m and does nothing.

func (*PixmapMut) Size

func (m *PixmapMut) Size() path.IntSize

Size is PixmapMut::size in tiny-skia src/pixmap.rs. It returns the size of the pixmap.

Port: upstream makes it public in the crate only. Go exports it, so that a later port, such as the painter, can call it.

func (*PixmapMut) StrokePath

func (m *PixmapMut) StrokePath(
	p *Path,
	paint *Paint,
	stroke *Stroke,
	transform Transform,
	mask *Mask,
)

StrokePath is PixmapMut::stroke_path in tiny-skia src/painter.rs. It strokes a path.

Stroking is implemented using two separate algorithms:

  1. If a stroke width is wider than 1px (after applying the transformation), a path is converted into a stroked path and then filled using FillPath. Which means that we have to allocate a separate Path, that can be 2-3x larger than the original path.
  2. If a stroke width is thinner than 1px (after applying the transformation), we use hairline stroking, which does not involve a separate path allocation.

Also, if a stroke has a dash array, then the path is converted into a dashed path first and then stroked. Which means yet another allocation.

A nil mask is the Rust None.

Port: upstream logs a warning with log::warn!. Go logs it to the logger of the pixmap, as D20 says.

func (*PixmapMut) ToOwned

func (m *PixmapMut) ToOwned() *Pixmap

ToOwned is PixmapMut::to_owned in tiny-skia src/pixmap.rs. It creates a new Pixmap from the current data.

It clones the underlying data.

func (*PixmapMut) Width

func (m *PixmapMut) Width() uint32

Width is PixmapMut::width in tiny-skia src/pixmap.rs. It returns the width of the pixmap.

type PixmapPaint

type PixmapPaint struct {
	// Opacity is the pixmap opacity.
	//
	// Must be in 0..=1 range.
	//
	// Default: 1.0
	Opacity float32

	// BlendMode is the pixmap blending mode.
	//
	// Default: SourceOver
	BlendMode BlendMode

	// Quality specifies how much filtering to be done when transforming
	// images.
	//
	// Default: Nearest
	Quality FilterQuality
}

PixmapPaint is PixmapPaint in tiny-skia src/shaders/pattern.rs. It controls how a pixmap is blended.

It is like Paint, but for Pixmap.

func DefaultPixmapPaint

func DefaultPixmapPaint() PixmapPaint

DefaultPixmapPaint is the Default impl of PixmapPaint in tiny-skia src/shaders/pattern.rs.

type PixmapRef

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

PixmapRef is PixmapRef in tiny-skia src/pixmap.rs. It is a container that references premultiplied RGBA pixels.

It can be created from a Pixmap or from data that the user gives.

The data is not aligned, therefore width == stride.

Port: logger is the logger of D20. A Pixmap that ToOwned or CloneRect makes takes it.

func PixmapRefFromBytes

func PixmapRefFromBytes(data []byte, width, height uint32, opts ...Option) (PixmapRef, bool)

PixmapRefFromBytes is PixmapRef::from_bytes in tiny-skia src/pixmap.rs. It creates a new PixmapRef from bytes.

The size must be at least width * height * BytesPerPixel. A zero size is an error. The width is limited by i32::MAX/4.

The data is assumed to have premultiplied RGBA pixels (byte order: RGBA).

Port: opts configure the PixmapRef, as D20 says.

func (PixmapRef) CloneRect

func (r PixmapRef) CloneRect(rect IntRect) (*Pixmap, bool)

CloneRect is PixmapRef::clone_rect in tiny-skia src/pixmap.rs. It returns a copy of the part of the pixmap that intersects rect.

It returns false when the rect of the pixmap does not contain rect.

func (PixmapRef) Data

func (r PixmapRef) Data() []byte

Data is PixmapRef::data in tiny-skia src/pixmap.rs. It returns the internal data.

Byte order: RGBA.

func (PixmapRef) EncodePNG

func (r PixmapRef) EncodePNG() ([]byte, error)

EncodePNG is PixmapRef::encode_png in tiny-skia src/pixmap.rs. It encodes the pixmap into PNG data.

Port: upstream encodes with the crate png, as 8-bit RGBA. The package image/png encodes here (D7). It writes 8-bit RGB when every pixel is opaque. The bytes of the file differ from upstream, and the decoded pixels are the same.

func (PixmapRef) Height

func (r PixmapRef) Height() uint32

Height is PixmapRef::height in tiny-skia src/pixmap.rs. It returns the height of the pixmap.

func (PixmapRef) Pixel

func (r PixmapRef) Pixel(x, y uint32) (PremultipliedColorU8, bool)

Pixel is PixmapRef::pixel in tiny-skia src/pixmap.rs. It returns the color of a pixel.

It returns false when the position is out of bounds.

func (PixmapRef) Pixels

func (r PixmapRef) Pixels() PixelSlice

Pixels is PixmapRef::pixels in tiny-skia src/pixmap.rs. It returns a slice of pixels.

func (PixmapRef) SavePNG

func (r PixmapRef) SavePNG(name string) error

SavePNG is PixmapRef::save_png in tiny-skia src/pixmap.rs. It saves the pixmap as a PNG file.

func (PixmapRef) Size

func (r PixmapRef) Size() path.IntSize

Size is PixmapRef::size in tiny-skia src/pixmap.rs. It returns the size of the pixmap.

Port: upstream makes it public in the crate only. Go exports it, so that a later port, such as the pipeline, can call it.

func (PixmapRef) ToOwned

func (r PixmapRef) ToOwned() *Pixmap

ToOwned is PixmapRef::to_owned in tiny-skia src/pixmap.rs. It creates a new Pixmap from the current data.

It clones the underlying data.

func (PixmapRef) Width

func (r PixmapRef) Width() uint32

Width is PixmapRef::width in tiny-skia src/pixmap.rs. It returns the width of the pixmap.

type Point

type Point = path.Point

Point is the re-export of tiny_skia_path::Point in tiny-skia src/lib.rs. It is a point.

func PointFromXY

func PointFromXY(x, y float32) Point

PointFromXY is Point::from_xy. It calls path.PointFromXY.

func PointZero

func PointZero() Point

PointZero is Point::zero. It calls path.PointZero.

type PremultipliedColor

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

PremultipliedColor is PremultipliedColor in tiny-skia src/color.rs. It is a premultiplied RGBA color value that holds four floating point components.

All values are in the range 0..=1, and the RGB components are <= A.

func (PremultipliedColor) Alpha

func (c PremultipliedColor) Alpha() float32

Alpha is PremultipliedColor::alpha in tiny-skia src/color.rs. It returns the alpha component of the color.

The value is guaranteed to be in the range 0..=1.

func (PremultipliedColor) Blue

func (c PremultipliedColor) Blue() float32

Blue is PremultipliedColor::blue in tiny-skia src/color.rs. It returns the blue component of the color.

The value is guaranteed to be in the range 0..=1, and it is <= alpha.

func (PremultipliedColor) Demultiply

func (c PremultipliedColor) Demultiply() Color

Demultiply is PremultipliedColor::demultiply in tiny-skia src/color.rs. It returns a demultiplied color.

func (PremultipliedColor) Green

func (c PremultipliedColor) Green() float32

Green is PremultipliedColor::green in tiny-skia src/color.rs. It returns the green component of the color.

The value is guaranteed to be in the range 0..=1, and it is <= alpha.

func (PremultipliedColor) Red

func (c PremultipliedColor) Red() float32

Red is PremultipliedColor::red in tiny-skia src/color.rs. It returns the red component of the color.

The value is guaranteed to be in the range 0..=1, and it is <= alpha.

func (PremultipliedColor) ToColorU8

ToColorU8 is PremultipliedColor::to_color_u8 in tiny-skia src/color.rs. It converts the color into a PremultipliedColorU8.

type PremultipliedColorU8

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

PremultipliedColorU8 is PremultipliedColorU8 in tiny-skia src/color.rs. It is a 32-bit premultiplied RGBA color value.

Byte order: RGBA.

func PremultipliedColorU8FromRGBA

func PremultipliedColorU8FromRGBA(r, g, b, a uint8) (PremultipliedColorU8, bool)

PremultipliedColorU8FromRGBA is PremultipliedColorU8::from_rgba in tiny-skia src/color.rs. It creates a new premultiplied color.

The RGB components must be <= alpha. If not, it returns false.

func (PremultipliedColorU8) Alpha

func (c PremultipliedColorU8) Alpha() uint8

Alpha is PremultipliedColorU8::alpha in tiny-skia src/color.rs. It returns the alpha component of the color.

func (PremultipliedColorU8) Blue

func (c PremultipliedColorU8) Blue() uint8

Blue is PremultipliedColorU8::blue in tiny-skia src/color.rs. It returns the blue component of the color.

The value is <= alpha.

func (PremultipliedColorU8) Demultiply

func (c PremultipliedColorU8) Demultiply() ColorU8

Demultiply is PremultipliedColorU8::demultiply in tiny-skia src/color.rs. It returns a demultiplied color.

func (PremultipliedColorU8) Green

func (c PremultipliedColorU8) Green() uint8

Green is PremultipliedColorU8::green in tiny-skia src/color.rs. It returns the green component of the color.

The value is <= alpha.

func (PremultipliedColorU8) IsOpaque

func (c PremultipliedColorU8) IsOpaque() bool

IsOpaque is PremultipliedColorU8::is_opaque in tiny-skia src/color.rs. It returns true if the alpha is 255.

func (PremultipliedColorU8) Red

func (c PremultipliedColorU8) Red() uint8

Red is PremultipliedColorU8::red in tiny-skia src/color.rs. It returns the red component of the color.

The value is <= alpha.

type RadialGradient

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

RadialGradient is RadialGradient in tiny-skia src/shaders/radial_gradient.rs. It is a 2-point conical gradient shader.

func (RadialGradient) ApplyOpacity

func (g RadialGradient) ApplyOpacity(opacity float32) Shader

ApplyOpacity is the arm Shader::RadialGradient of Shader::apply_opacity in tiny-skia src/shaders/mod.rs.

func (RadialGradient) IsOpaque

func (g RadialGradient) IsOpaque() bool

IsOpaque is the arm Shader::RadialGradient of Shader::is_opaque in tiny-skia src/shaders/mod.rs.

A radial gradient can have points that are "undefined" so we just assume that it is not opaque.

func (RadialGradient) Transform

func (g RadialGradient) Transform(ts Transform) Shader

Transform is the arm Shader::RadialGradient of Shader::transform in tiny-skia src/shaders/mod.rs.

type Rect

type Rect = path.Rect

Rect is the re-export of tiny_skia_path::Rect in tiny-skia src/lib.rs. It is a rectangle.

func RectFromLTRB

func RectFromLTRB(left, top, right, bottom float32) (Rect, bool)

RectFromLTRB is Rect::from_ltrb. It calls path.RectFromLTRB.

func RectFromPoints

func RectFromPoints(points []Point) (Rect, bool)

RectFromPoints is Rect::from_points. It calls path.RectFromPoints.

func RectFromXYWH

func RectFromXYWH(x, y, w, h float32) (Rect, bool)

RectFromXYWH is Rect::from_xywh. It calls path.RectFromXYWH.

type Shader

type Shader interface {
	// IsOpaque is Shader::is_opaque. It checks if the shader is guaranteed
	// to produce only opaque colors.
	IsOpaque() bool

	// Transform is Shader::transform. It returns the shader transformed by
	// ts.
	Transform(ts Transform) Shader

	// ApplyOpacity is Shader::apply_opacity. It returns the shader with its
	// opacity shifted by opacity.
	//
	// opacity is clamped to the 0..=1 range.
	//
	// This is roughly the same as Skia's SkPaint::setAlpha.
	//
	// Unlike Skia, we do not support global alpha/opacity, which in Skia is
	// set via the alpha channel of the SkPaint::fColor4f. Instead, you can
	// shift the opacity of the shader to whatever value you need.
	//
	//   - For SolidColor this function multiplies color.alpha by opacity.
	//   - For gradients this function multiplies all colors by opacity.
	//   - For Pattern this function multiplies Pattern::opacity by opacity.
	ApplyOpacity(opacity float32) Shader
	// contains filtered or unexported methods
}

Shader is Shader in tiny-skia src/shaders/mod.rs. A shader specifies the source color(s) for what is being drawn.

If a paint has no shader, then the paint's color is used. If the paint has a shader, then the shader's color(s) are used instead, but they are modulated by the paint's alpha. This makes it easy to create a shader once (e.g. bitmap tiling or gradient) and then change its transparency without having to modify the original shader. Only the paint's alpha needs to be modified.

Port: Shader is a Rust enum with data. In Go it is an interface with one type for each variant: SolidColor, LinearGradient, RadialGradient, SweepGradient and Pattern. okage adds MeshGradient, which tiny-skia does not have (D55). Each type is a value type. A type switch on a Shader takes the place of a match on the enum. The unexported method keeps other types out. Transform and ApplyOpacity change a Rust shader in place. In Go they return the changed shader and leave the receiver as it was, so that a copy of a Paint does not share its shader with the original, as the clone of a Rust Paint does.

func NewLinearGradient

func NewLinearGradient(
	start Point,
	end Point,
	stops []GradientStop,
	mode SpreadMode,
	transform Transform,
) (Shader, bool)

NewLinearGradient is LinearGradient::new in tiny-skia src/shaders/linear_gradient.rs. It creates a new linear gradient shader.

It returns a SolidColor when:

  • len(stops) == 1
  • start and end are very close. In the decal mode, the color is transparent (D55)

It returns false when:

  • stops is empty
  • start == end
  • transform is not invertible

func NewMeshGradient added in v0.11.0

func NewMeshGradient(triangles []MeshTriangle, transform Transform) (Shader, bool)

NewMeshGradient makes a MeshGradient from triangles, with transform from the space of the triangles to the space of the user. The triangles paint in their order, so a later triangle covers an earlier one.

It skips a triangle with no area or with a point that is not finite. It returns false when no triangle is left, and when transform is not invertible.

The shader keeps a grid of the triangles, so that each pixel tests only the triangles near it. The grid holds at most about 16 entries for each triangle. The time to fill a pixel can still grow with the number of triangles that overlap at that pixel.

func NewPattern

func NewPattern(
	pixmap PixmapRef,
	spreadMode SpreadMode,
	quality FilterQuality,
	opacity float32,
	transform Transform,
) Shader

NewPattern is Pattern::new in tiny-skia src/shaders/pattern.rs. It creates a new pattern shader.

opacity is clamped to the 0..=1 range.

func NewRadialGradient

func NewRadialGradient(
	startPoint Point,
	startRadius float32,
	endPoint Point,
	endRadius float32,
	stops []GradientStop,
	mode SpreadMode,
	transform Transform,
) (Shader, bool)

NewRadialGradient is RadialGradient::new in tiny-skia src/shaders/radial_gradient.rs. It creates a new two-point conical gradient shader.

A two-point conical gradient (also known as a radial gradient) interpolates colors between two circles defined by their center points and radii.

It returns a SolidColor when:

  • len(stops) == 1

It returns false when:

  • stops is empty
  • startRadius < 0 or endRadius < 0
  • transform is not invertible
  • The gradient is degenerate (both radii and centers are equal, except in specific pad mode cases)

func NewSweepGradient

func NewSweepGradient(
	center Point,
	startAngle float32,
	endAngle float32,
	stops []GradientStop,
	mode SpreadMode,
	transform Transform,
) (Shader, bool)

NewSweepGradient is SweepGradient::new in tiny-skia src/shaders/sweep_gradient.rs. It creates a new sweep gradient shader.

It returns false when an angle is not finite, when startAngle is larger than endAngle, when stops is empty, when transform is not invertible, and for most degenerate gradients.

type Size

type Size = path.Size

Size is the re-export of tiny_skia_path::Size in tiny-skia src/lib.rs. It is a size.

func SizeFromWH

func SizeFromWH(width, height float32) (Size, bool)

SizeFromWH is Size::from_wh. It calls path.SizeFromWH.

type SolidColor

type SolidColor Color

SolidColor is Shader::SolidColor in tiny-skia src/shaders/mod.rs. It is a solid color shader.

Unlike Skia, we do not have is_constant, because we do not have Color shaders.

func (SolidColor) ApplyOpacity

func (c SolidColor) ApplyOpacity(opacity float32) Shader

ApplyOpacity is the arm Shader::SolidColor of Shader::apply_opacity in tiny-skia src/shaders/mod.rs.

func (SolidColor) IsOpaque

func (c SolidColor) IsOpaque() bool

IsOpaque is the arm Shader::SolidColor of Shader::is_opaque in tiny-skia src/shaders/mod.rs.

func (SolidColor) Transform

func (c SolidColor) Transform(_ Transform) Shader

Transform is the arm Shader::SolidColor of Shader::transform in tiny-skia src/shaders/mod.rs. It returns c.

type SpreadMode

type SpreadMode uint8

SpreadMode is SpreadMode in tiny-skia src/shaders/mod.rs. It is a shader spreading mode.

const (
	// SpreadModePad is SpreadMode::Pad, the default. It replicates the edge
	// color if the shader draws outside of its original bounds.
	SpreadModePad SpreadMode = iota

	// SpreadModeReflect is SpreadMode::Reflect. It repeats the shader's image
	// horizontally and vertically, alternating mirror images so that adjacent
	// images always seam.
	SpreadModeReflect

	// SpreadModeRepeat is SpreadMode::Repeat. It repeats the shader's image
	// horizontally and vertically.
	SpreadModeRepeat

	// SpreadModeDecal is the tile mode kDecal of Skia. tiny-skia does not
	// have it (D55). A gradient paints transparent black where its t is
	// outside 0..=1, that is before its start and after its end. A gradient
	// with this mode is never opaque. A Pattern treats it as SpreadModePad.
	SpreadModeDecal
)

The values of SpreadMode, in the order of the Rust enum.

func (SpreadMode) String

func (m SpreadMode) String() string

String satisfies the fmt.Stringer interface. It returns the name of the Rust variant.

type Stroke

type Stroke = path.Stroke

Stroke is the re-export of tiny_skia_path::Stroke in tiny-skia src/lib.rs. It holds the properties of a stroke.

func DefaultStroke

func DefaultStroke() Stroke

DefaultStroke is Stroke::default. It calls path.DefaultStroke.

type StrokeDash

type StrokeDash = path.StrokeDash

StrokeDash is the re-export of tiny_skia_path::StrokeDash in tiny-skia src/lib.rs. It is a dash of a stroke.

func NewStrokeDash

func NewStrokeDash(dashArray []float32, dashOffset float32) (*StrokeDash, bool)

NewStrokeDash is StrokeDash::new. It calls path.NewStrokeDash.

type SweepGradient

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

SweepGradient is SweepGradient in tiny-skia src/shaders/sweep_gradient.rs. It is a sweep gradient shader.

func (SweepGradient) ApplyOpacity

func (g SweepGradient) ApplyOpacity(opacity float32) Shader

ApplyOpacity is the arm Shader::SweepGradient of Shader::apply_opacity in tiny-skia src/shaders/mod.rs.

func (SweepGradient) IsOpaque

func (g SweepGradient) IsOpaque() bool

IsOpaque is SweepGradient::is_opaque in tiny-skia src/shaders/sweep_gradient.rs, and the arm Shader::SweepGradient of Shader::is_opaque in tiny-skia src/shaders/mod.rs.

func (SweepGradient) Transform

func (g SweepGradient) Transform(ts Transform) Shader

Transform is the arm Shader::SweepGradient of Shader::transform in tiny-skia src/shaders/mod.rs.

type Transform

type Transform = path.Transform

Transform is the re-export of tiny_skia_path::Transform in tiny-skia src/lib.rs. It is an affine transform.

func DefaultTransform

func DefaultTransform() Transform

DefaultTransform is Transform::default. It calls path.DefaultTransform.

func IdentityTransform

func IdentityTransform() Transform

IdentityTransform is Transform::identity. It calls path.IdentityTransform.

func TransformFromBBox

func TransformFromBBox(bbox NonZeroRect) Transform

TransformFromBBox is Transform::from_bbox. It calls path.TransformFromBBox.

func TransformFromRotate

func TransformFromRotate(angle float32) Transform

TransformFromRotate is Transform::from_rotate. It calls path.TransformFromRotate.

func TransformFromRotateAt

func TransformFromRotateAt(angle, tx, ty float32) Transform

TransformFromRotateAt is Transform::from_rotate_at. It calls path.TransformFromRotateAt.

func TransformFromRow

func TransformFromRow(sx, ky, kx, sy, tx, ty float32) Transform

TransformFromRow is Transform::from_row. It calls path.TransformFromRow.

func TransformFromScale

func TransformFromScale(sx, sy float32) Transform

TransformFromScale is Transform::from_scale. It calls path.TransformFromScale.

func TransformFromSkew

func TransformFromSkew(kx, ky float32) Transform

TransformFromSkew is Transform::from_skew. It calls path.TransformFromSkew.

func TransformFromTranslate

func TransformFromTranslate(tx, ty float32) Transform

TransformFromTranslate is Transform::from_translate. It calls path.TransformFromTranslate.

Directories

Path Synopsis
Package cssselect2 is a port of the Python package cssselect2 0.10.1, the selectors of CSS 4 for a document tree.
Package cssselect2 is a port of the Python package cssselect2 0.10.1, the selectors of CSS 4 for a document tree.
Package html parses and lays out the HTML-like labels of Graphviz (D38), and parses HTML documents (D49).
Package html parses and lays out the HTML-like labels of Graphviz (D38), and parses HTML documents (D49).
internal
brotli
Package brotli implements the Brotli compressed data format, described in RFC 7932.
Package brotli implements the Brotli compressed data format, described in RFC 7932.
crmath
Package crmath gives correctly rounded results of the math functions that tiny-skia, kurbo, svgtypes and resvg call from the C library: acos, cos, sin, tan, atan2, pow, ln and log2 for an f64, and acos, cos, sin, tan, atan2, pow and hypot for an f32.
Package crmath gives correctly rounded results of the math functions that tiny-skia, kurbo, svgtypes and resvg call from the C library: acos, cos, sin, tan, atan2, pow, ln and log2 for an f64, and acos, cos, sin, tan, atan2, pow and hypot for an f32.
lottiecompat
Package lottiecompat holds the switch that makes the package lottie draw as velato does, without the differences of D42 and D43.
Package lottiecompat holds the switch that makes the package lottie draw as velato does, without the differences of D42 and D43.
simplecss
Package simplecss is a port of the Rust crate simplecss 0.2.2, a simple CSS 2.1 parser and selector.
Package simplecss is a port of the Rust crate simplecss 0.2.2, a simple CSS 2.1 parser and selector.
svgtypes
Package svgtypes is a port of the Rust crate svgtypes 0.16.1, a collection of parsers for SVG types, at the commit fa62387a.
Package svgtypes is a port of the Rust crate svgtypes 0.16.1, a collection of parsers for SVG types, at the commit fa62387a.
wide
Package wide holds the vector types of tiny-skia, a port of src/wide, and the conversions from a float to an integer that give the result of Rust.
Package wide holds the vector types of tiny-skia, a port of src/wide, and the conversions from a float to an integer that give the result of Rust.
wide/internal/widegen command
Command widegen writes the generated files of the package wide.
Command widegen writes the generated files of the package wide.
xmlwriter
Package xmlwriter is a port of the Rust crate xmlwriter 0.1.0, a simple, streaming, partially-validating XML writer that writes XML data into an internal buffer.
Package xmlwriter is a port of the Rust crate xmlwriter 0.1.0, a simple, streaming, partially-validating XML writer that writes XML data into an internal buffer.
Package kurbo is a port of a subset of the Rust crate kurbo 0.13.1, a 2D curves library, at the commit 838b69ef.
Package kurbo is a port of a subset of the Rust crate kurbo 0.13.1, a 2D curves library, at the commit 838b69ef.
Package lottie renders Lottie animations with okage.
Package lottie renders Lottie animations with okage.
Package path is a port of the Rust crate tiny-skia-path 0.12.0, a Bezier path of tiny-skia, and of the crate strict-num 0.1.1, which holds the checked float types.
Package path is a port of the Rust crate tiny-skia-path 0.12.0, a Bezier path of tiny-skia, and of the crate strict-num 0.1.1, which holds the checked float types.
Package roxmltree is a port of the Rust crate roxmltree 0.21.1.
Package roxmltree is a port of the Rust crate roxmltree 0.21.1.
Package svg is a port of the Rust crates usvg 0.49.0 and resvg 0.49.0, in one package (D5).
Package svg is a port of the Rust crates usvg 0.49.0 and resvg 0.49.0, in one package (D5).
Package tinycss2 is a port of the Python package tinycss2 1.5.1, a low-level CSS parser and generator.
Package tinycss2 is a port of the Python package tinycss2 1.5.1, a low-level CSS parser and generator.
typesetting
bidi
bidi implements the Unicode Bidi algorithm.
bidi implements the Unicode Bidi algorithm.
di
font
Package font provides an high level API to access Opentype font properties.
Package font provides an high level API to access Opentype font properties.
font/cff/interpreter
Package psinterpreter implement a Postscript interpreter required to parse .CFF files, and Type1 and Type2 Charstrings.
Package psinterpreter implement a Postscript interpreter required to parse .CFF files, and Type1 and Type2 Charstrings.
font/opentype
Package opentype provides the low level routines required to read and write Opentype font files, including collections.
Package opentype provides the low level routines required to read and write Opentype font files, including collections.
harfbuzz
Package harfbuzz provides advanced text layout for various scripts and languages, with font-aware substitutions and positionning.
Package harfbuzz provides advanced text layout for various scripts and languages, with font-aware substitutions and positionning.
internal/unicodedata
Package unicodedata provides additional lookup functions for unicode properties, not covered by the standard package unicode.
Package unicodedata provides additional lookup functions for unicode properties, not covered by the standard package unicode.
segmenter
Package segmenter implements Unicode rules used to segment a paragraph of text according to several criteria.
Package segmenter implements Unicode rules used to segment a paragraph of text according to several criteria.
Package webfont converts a font in WOFF, WOFF2 or EOT into an sfnt file, the format of a TrueType or OpenType font file (D45).
Package webfont converts a font in WOFF, WOFF2 or EOT into an sfnt file, the format of a TrueType or OpenType font file (D45).

Jump to

Keyboard shortcuts

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