okage

package module
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: BSD-3-Clause Imports: 18 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README


Unit Tests Go Reference Releases Discord Discussion

okage

okage draws 2D graphics in pure Go. It fills and strokes paths, renders SVG files, draws Lottie animations, lays out text and math, and writes PDF files. It needs the Go toolchain and nothing else: no cgo, no C library and no WebAssembly runtime.

okage is a port of tiny-skia, the small 2D renderer of the Rust ecosystem, and of resvg, which renders SVG files with tiny-skia. The renderer gives the same bytes as tiny-skia. okage also ports the projects around them, such as velato for Lottie and krilla for PDF. Packages lists each one.

Installing

Add okage to a Go module with this command:

go get github.com/xo/okage

A program that imports okage builds with CGO_ENABLED=0 for each platform that Go supports.

Examples

Each example below is a part of a test in test/readme. The test also draws each image of this section. The example of Lottie draws one frame, and the test draws four frames for its image.

Draw shapes

The root package fills and strokes paths onto a Pixmap, with a solid color, a gradient or a pattern. This example fills a circle with a radial gradient, and strokes a curve with round dashes:

pixmap, _ := okage.NewPixmap(480, 240)
pixmap.Fill(okage.ColorFromRGBA8(255, 255, 255, 255))

// Fill a circle with a radial gradient.
circle, _ := okage.PathFromCircle(120, 120, 96)
paint := okage.DefaultPaint()
paint.AntiAlias = true
paint.Shader, _ = okage.NewRadialGradient(
	okage.PointFromXY(84, 84), 0,
	okage.PointFromXY(120, 120), 96,
	[]okage.GradientStop{
		okage.NewGradientStop(0, okage.ColorFromRGBA8(255, 214, 102, 255)),
		okage.NewGradientStop(1, okage.ColorFromRGBA8(232, 89, 60, 255)),
	},
	okage.SpreadModePad,
	okage.IdentityTransform(),
)
pixmap.FillPath(circle, &paint, okage.FillRuleWinding, okage.IdentityTransform(), nil)

// Stroke a curve with round dashes.
pb := okage.NewPathBuilder()
pb.MoveTo(250, 200)
pb.CubicTo(290, 20, 400, 20, 450, 200)
curve, _ := pb.Finish()
paint.SetColorRGBA8(59, 113, 96, 255)
stroke := okage.DefaultStroke()
stroke.Width = 10
stroke.LineCap = okage.LineCapRound
stroke.Dash, _ = okage.NewStrokeDash([]float32{18, 18}, 0)
pixmap.StrokePath(curve, &paint, &stroke, okage.IdentityTransform(), nil)

if err := pixmap.SavePNG("shapes.png"); err != nil {
	return err
}
A circle with a gradient, and a dashed curve
Render an SVG file

svg.New makes a Renderer, which renders SVG data into an *image.RGBA in one call:

data, err := os.ReadFile("docs/okage.svg")
if err != nil {
	return err
}
r := svg.New(svg.WithWidth(480))
img, err := r.Render(data)
if err != nil {
	return err
}
The okage logo, rendered from SVG

A Renderer loads the fonts of the system on its first call. The package also registers the format svg, so image.Decode reads SVG data.

Draw text

svg shapes text with typesetting, which handles each script, the direction of the text and the fallback from one font to the next. For an image that is the same on each machine, give the fonts and turn off the fonts of the system:

data := []byte(`<svg xmlns="http://www.w3.org/2000/svg" width="480" height="80">
  <rect width="100%" height="100%" fill="white"/>
  <text x="240" y="52" font-family="Noto Sans" font-size="32"
        text-anchor="middle" fill="#3B7160">Hello, مرحبا, こんにちは</text>
</svg>`)
r := svg.New(
	svg.WithLoadSystemFonts(false),
	svg.WithFontFile(latin),
	svg.WithFontFile(arabic),
	svg.WithFontFile(japanese),
)
img, err := r.Render(data)
if err != nil {
	return err
}
Hello in English, Arabic and Japanese

svg.ShapeText gives the glyphs and the outlines of a run of text without SVG data. The package typesetting/shaping gives the line breaks and the shaping of whole paragraphs.

Lay out math

texmath lays out TeX math with the OpenType MATH table of a font, by the rules of TeX. The package texmath/stixtwomath holds the font STIX Two Math:

f, err := stixtwomath.Font()
if err != nil {
	return err
}
tex := `x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}`
box, err := texmath.LayoutTeX(tex, font.NewFace(f), 40, texmath.Display)
if err != nil {
	return err
}
w := uint32(math.Ceil(box.Width)) + 32
h := uint32(math.Ceil(box.Height+box.Depth)) + 32
pixmap, _ := okage.NewPixmap(w, h)
pixmap.Fill(okage.ColorFromRGBA8(255, 255, 255, 255))
paint := okage.DefaultPaint()
paint.AntiAlias = true
box.Draw(pixmap, okage.TransformFromTranslate(16, 16+float32(box.Height)), &paint)
The quadratic formula

Box.Path gives the outline of the formula as one path, for a writer of SVG or PDF.

Draw a Lottie animation

lottie reads Lottie files and dotLottie archives, and draws each frame:

c, err := lottie.Load(data)
if err != nil {
	return nil, err
}
// Draw the middle frame at 256 by 256 pixels.
img, err := c.Image(c.FrameCount()/2, 256, 256)
if err != nil {
	return nil, err
}
Four frames of the animated fire emoji

The animation is the fire emoji of the Noto animated emoji, under the CC BY 4.0 license.

Write a PDF file

pdf writes PDF files, with paths, gradients, images and text with subsets of the fonts. pdfsvg draws a tree of svg onto a page, so this example converts an SVG file to PDF:

tree, err := svg.FromData(data)
if err != nil {
	return nil, err
}
d := pdf.NewDocument(pdf.WithSVGGlyphs(pdfsvg.RenderGlyph))
ps, _ := pdf.PageSettingsFromWH(tree.Size().Width(), tree.Size().Height())
page := d.StartPage(ps)
pdfsvg.Draw(page.Surface(), tree, tree.Size())
page.Finish()
if err := d.Finish(&w); err != nil {
	return nil, err
}

Packages

Package What it does Port of
okage Fills and strokes paths, with gradients, patterns, masks and blend modes tiny-skia
path Builds, transforms, strokes and dashes paths tiny-skia-path
svg Parses SVG files into a tree, and renders the tree resvg and usvg
lottie Reads Lottie files and dotLottie archives, and draws their frames velato
filter Applies the filter effects of SVG and CSS to pixmaps, blurs masks and pixmaps, and changes the colors of pixmaps and images with a color matrix or transfer functions filtra
pdf Writes PDF files krilla
pdfsvg Draws a tree of svg onto a page of pdf krilla-svg
texmath Parses TeX math and lays it out with the MATH table of a font go-tex/math
typesetting Reads fonts, shapes text, breaks lines and runs the bidi algorithm a copy of go-text/typesetting
html Parses HTML documents, and lays out the HTML-like labels of Graphviz tinyhtml5
tinycss2 Parses CSS tinycss2
cssselect2 Matches CSS selectors cssselect2
webfont Converts WOFF, WOFF2 and EOT fonts to TrueType or OpenType data none
roxmltree Parses XML into a read-only tree roxmltree
kurbo Curves, shapes and their geometry a subset of kurbo

The root package imports only the Go standard library. svg also uses golang.org/x/image/webp for WebP files.

okage differs from its upstreams only where a decision says so. docs/DIFFERENCES.md lists each difference, and each API that okage adds. docs/STATUS.md gives the state of each package, and the upstream commit that it follows.

SIMD and TinyGo

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. 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 each image. On an amd64 CPU without AVX2, the SIMD build uses the scalar code. When Go makes SIMD a standard feature, the SIMD build becomes the default. docs/SIMD.md holds the details.

okage also builds with TinyGo, which always uses the scalar code. A build for WebAssembly is a goal that each package keeps in mind.

Documents

Document What it holds
docs/STATUS.md the state of each package, and the upstream commits that okage follows
docs/DIFFERENCES.md each difference from upstream, and each API that okage adds
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/ each 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

License

okage keeps the license of each upstream project. Each folder that holds code from an upstream project holds the license of that project, in a file LICENSE, NOTICE or OFL.txt. LICENSE in the root is the BSD-3-Clause license of tiny-skia, and it covers the root package and path.

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 (
	// ErrTeXMathSyntax is the error of texmath.Parse for TeX math that the
	// parser cannot read, such as a missing }, a \left without a \right, or
	// \begin{x} closed by \end{y}. The *texmath.SyntaxError gives the
	// position and the message of go-tex/math.
	ErrTeXMathSyntax Error = "parsing tex math"

	// ErrTeXMathUnknownCommand is the error of texmath.Parse for an unknown
	// command or environment. The *texmath.SyntaxError also wraps
	// ErrTeXMathSyntax, and its field Command names the command.
	ErrTeXMathUnknownCommand Error = "parsing tex math: unknown command"

	// ErrMathLimit is the error of texmath for a formula past one of its
	// limits, such as the depth of nesting, the number of nodes, or the
	// number of tokens after the expansion of the macros. go-tex/math has no
	// such limit.
	ErrMathLimit Error = "typesetting math: limit reached"

	// ErrMathNoMathTable is the error of the layout of texmath for a face
	// without a MATH table, as New of go-tex/math gives.
	ErrMathNoMathTable Error = "laying out math: the face has no MATH table"
)

The sentinel errors of texmath (D78). An error of texmath.Parse is a *texmath.SyntaxError that wraps one of them.

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 (
	// ErrSubsetUnknownKind is Error::UnknownKind of subsetter. The file
	// contains an unknown kind of font.
	ErrSubsetUnknownKind Error = "subsetting font: unknown font kind"

	// ErrSubsetMalformedFont is Error::MalformedFont of subsetter. The font
	// is malformed, or the code that reads the font has a fault.
	ErrSubsetMalformedFont Error = "subsetting font: malformed font"

	// ErrSubsetUnimplemented is Error::Unimplemented of subsetter. The font
	// relies on a feature that the subsetter does not implement, so the
	// subset cannot be made.
	ErrSubsetUnimplemented Error = "subsetting font: unsupported feature in font"

	// ErrSubsetFailed is Error::SubsetError of subsetter. An unexpected error
	// occurred when the subsetter made the subset. It shows a fault in the
	// logic of the subsetter.
	ErrSubsetFailed Error = "subsetting font: subsetting of font failed"

	// ErrSubsetOverflow is Error::OverflowError of subsetter. A value
	// overflowed during the computation. The font or the logic of the
	// subsetter can cause it.
	ErrSubsetOverflow Error = "subsetting font: overflow occurred"

	// ErrSubsetCFF is Error::CFFError of subsetter. An error occurred while
	// the subsetter processed the CFF table.
	ErrSubsetCFF Error = "subsetting font: processing CFF table failed"

	// ErrSubsetTooLarge is not in subsetter. The data of the glyphs of the
	// subset is larger than 8 times the size of the font data plus 1 MiB.
	// A hostile font can point many glyph IDs at one large glyph, and
	// subsetter copies that glyph for each ID (D74).
	ErrSubsetTooLarge Error = "subsetting font: subset is too large"
)

The sentinel errors of the font subsets of the PDF writer, one for each case of the enum Error of subsetter (D62), and one for the limit of D74. The text after "subsetting font: " is the Display text of upstream.

const (
	// ErrPDFValidation is KrillaError::Validation of krilla. The validator
	// of pdf.WithArchivalValidator found faults in the document (D99). The
	// error gives the number of faults.
	ErrPDFValidation Error = "writing pdf: validation failed"

	// ErrPDFXMP is KrillaError::Xmp of krilla. The custom XMP metadata of
	// the document is not valid (D99). Document.Finish returns a
	// *pdf.XMPError that wraps it, with the case of XmpError and its name.
	ErrPDFXMP Error = "writing pdf: invalid custom XMP metadata"

	// ErrPDFTooLargeFloat is KrillaError::Limit with LimitError::TooLargeFloat
	// of krilla. A float is larger than PDF 1.4 allows.
	ErrPDFTooLargeFloat Error = "writing pdf: PDF version limit exceeded: a float exceeded the maximum allowed size"

	// ErrPDFTooLongArray is KrillaError::Limit with LimitError::TooLongArray
	// of krilla. An array is longer than PDF 1.4 allows.
	ErrPDFTooLongArray Error = "writing pdf: PDF version limit exceeded: an array exceeded the maximum allowed length"

	// ErrPDFTooLongDictionary is KrillaError::Limit with
	// LimitError::TooLongDictionary of krilla. A dictionary has more entries
	// than PDF 1.4 allows.
	ErrPDFTooLongDictionary Error = "writing pdf: PDF version limit exceeded: a dictionary exceeded the maximum allowed number of entries"

	// ErrPDFImage is KrillaError::Image of krilla, and the error of a
	// function of pdf that makes an image from data that it cannot read. An
	// image could not be read or decoded. The error that wraps it holds the
	// message of the decoder.
	ErrPDFImage Error = "writing pdf: failed to process image"

	// ErrPDFSixteenBitImage is KrillaError::SixteenBitImage of krilla. A
	// document of PDF 1.4 holds an image with 16 bits for each component.
	ErrPDFSixteenBitImage Error = "writing pdf: sixteen bit images require PDF 1.5 or newer, but the selected PDF version does not support them"

	// ErrPDFVersion is ConfigurationError::VersionDoesNotMatchValidatorsRange
	// of krilla src/configure/mod.rs. The option WithPDFVersion gave a
	// version that pdf does not know. Document.Finish returns it.
	ErrPDFVersion Error = "writing pdf: the PDF version does not match the range of the validators"

	// ErrPDFInvalidBox is the error of Document.Finish for a box of a page
	// that becomes invalid when the page is flipped into the coordinates of
	// PDF, such as a box with a coordinate near the largest float32. krilla
	// panics in this case.
	ErrPDFInvalidBox Error = "writing pdf: a box of a page is not valid"

	// ErrPDFFinished is the error of a second call of Document.Finish.
	// krilla consumes the document when it finishes it.
	ErrPDFFinished Error = "writing pdf: the document is already finished"

	// ErrPDFPushPop is the error of Document.Finish for a surface whose
	// pushes and pops do not match: a pop without a push, or a push without
	// a pop when the surface finishes. krilla panics in this case.
	ErrPDFPushPop Error = "writing pdf: the pushes and the pops of a surface do not match"

	// ErrPDFInvalidClipPath is the error of Document.Finish for a clip path
	// that becomes invalid in the coordinates of PDF, such as a path with a
	// coordinate near the largest float32 under a transform that scales it
	// up. krilla panics in this case.
	ErrPDFInvalidClipPath Error = "writing pdf: a clip path is not valid in the coordinates of the page"

	// ErrPDFInvalidStroke is the error of Document.Finish for a stroke whose
	// width is negative or NaN. krilla panics in this case.
	ErrPDFInvalidStroke Error = "writing pdf: the width of a stroke is not valid"

	// ErrPDFInvalidPath is the error of Document.Finish for a path to stroke
	// with a point that is NaN, or with a coordinate whose magnitude, with
	// the width of the stroke, is above 2^60. When krilla computes the bbox
	// of the stroke, its stroker can panic for such a path, or not end (D66).
	ErrPDFInvalidPath Error = "writing pdf: a path to stroke has coordinates that are not valid"

	// ErrPDFMixedColorSpaces is the error of Document.Finish for a gradient
	// whose stops have colors in color spaces with different numbers of
	// components, such as RGB and CMYK. krilla panics in this case (D66).
	ErrPDFMixedColorSpaces Error = "writing pdf: the stops of a gradient are in different color spaces"

	// ErrPDFInvalidGradient is the error of Document.Finish for a gradient
	// with a transform that cannot be inverted where the gradient needs the
	// inverse. krilla panics in this case.
	ErrPDFInvalidGradient Error = "writing pdf: a gradient is not valid"

	// ErrPDFDuplicateNamedDestination is
	// KrillaError::DuplicateNamedDestination of krilla. The same name of a
	// destination has two different destinations. The error names the
	// destination.
	ErrPDFDuplicateNamedDestination Error = "writing pdf: duplicate named destination"

	// ErrPDFInvalidDestination is the error of Document.Finish for a
	// destination that links to a page that does not exist. krilla panics in
	// this case.
	ErrPDFInvalidDestination Error = "writing pdf: a destination links to a page that does not exist"

	// ErrPDFInvalidAnnotation is the error of Document.Finish for a link
	// annotation with no target, with quadrilaterals that give no
	// rectangle, or with a rectangle that is not valid in the coordinates of
	// the page. krilla panics in these cases.
	ErrPDFInvalidAnnotation Error = "writing pdf: a link annotation is not valid"

	// ErrPDFFont is KrillaError::Font of krilla. Document.Finish cannot
	// embed a font, for example because the subset of the font fails. The
	// error names the font, when the font has a PostScript name, and gives
	// the message of upstream.
	ErrPDFFont Error = "writing pdf: failed to embed font"

	// ErrPDFInvalidFont is the error of NewFont for data that is not a
	// TrueType or OpenType font, or for an index that the data does not
	// have. krilla returns None in these cases.
	ErrPDFInvalidFont Error = "writing pdf: the font cannot be read"

	// ErrPDFInvalidGlyph is the error of Document.Finish for a glyph of
	// Surface.DrawGlyphs whose range is not a range of the text, or whose
	// ID is above 65535. krilla panics in these cases.
	ErrPDFInvalidGlyph Error = "writing pdf: a glyph is not valid"
)

The sentinel errors of the PDF writer of pdf, for the cases of KrillaError and of LimitError of krilla src/error.rs that the base port keeps, and for the panics of krilla that a caller can cause (D62). The text after "writing pdf: " is the Display text of upstream, where upstream has one.

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 GradientParameters added in v0.17.0

type GradientParameters struct {
	// Start is the start point of a linear gradient, the center of the start
	// circle of a radial gradient, or the center of a sweep gradient.
	Start Point
	// End is the end point of a linear gradient, or the center of the end
	// circle of a radial gradient.
	End Point
	// StartRadius and EndRadius are the radii of the circles of a radial
	// gradient.
	StartRadius float32
	EndRadius   float32
	// StartAngle and EndAngle are the angles of a sweep gradient, in
	// degrees.
	StartAngle float32
	EndAngle   float32
	// Stops are the stops as the shader draws them. The first stop is at 0,
	// the last stop is at 1, and the positions do not go down. An opacity
	// that ApplyOpacity gave is in the alpha of each color.
	Stops []GradientStop
	// Mode is the spread mode. It is SpreadModePad for a gradient of
	// NewRadialGradientExtend.
	Mode SpreadMode
	// Extend is true for a gradient of NewRadialGradientExtend. ExtendStart
	// and ExtendEnd are then its flags (D64).
	Extend      bool
	ExtendStart bool
	ExtendEnd   bool
	// Transform maps the space of the gradient to the space of the user.
	Transform Transform
}

GradientParameters are the parameters of a linear, radial or sweep gradient, which the method Parameters of each gradient gives (D68).

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.

func (GradientStop) Color added in v0.17.0

func (s GradientStop) Color() Color

Color gives the color of the stop.

func (GradientStop) Position added in v0.17.0

func (s GradientStop) Position() float32

Position gives the position of the stop, from 0 to 1.

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) Parameters added in v0.17.0

func (g LinearGradient) Parameters() GradientParameters

Parameters gives the parameters of the linear gradient. The points come from the inverse of the transform that tiny-skia keeps, so they can differ from the points of NewLinearGradient in the last bits.

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.

Port: data holds only a rectangle of the mask, and the other pixels are 0 (D35). The rectangle has the rows from top and the columns from left to left+stride. The byte of the pixel (x, y) is at stride*(y-top) + x, so the first left bytes of data are not used, and the stages find a pixel with the offset of upstream, with stride in place of the width. A clip then takes the memory and the time of the pixels that its path covers, not of the whole pixmap. The rectangle has a margin of maskChunk-1 columns on each side of the pixels that are not 0, or ends at the side of the mask, so that each chunk that maskBounds keeps is inside it (D60). Clone shares data, and the first write to a mask that shares its data copies it. A caller can hold data after Data, DataMut, Take or MaskFromVec. Then data holds every pixel, and the mask never shares it again. A caller sees no difference, except in the memory that a mask takes.

Port: a mask of NewRectMask holds a rectangle and no pixels (D86). The first read or write of its pixels makes the pixels of the rectangle, with the layout above.

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 NewRectMask added in v0.20.0

func NewRectMask(width, height uint32, rect IntRect, opts ...Option) (*Mask, bool)

NewRectMask makes a mask of the size width by height that is 255 on the pixels of rect inside the mask and 0 on the other pixels. It returns false where NewMask returns false. It ports no upstream function (D86).

The mask holds the rectangle and no pixels. A method of Pixmap or PixmapMut that draws through the mask gives the same bytes as through a mask that holds those pixels, and runs the stage mask_u8 only on the chunks of pixels at the sides of the rectangle. The first method that reads or writes the pixels of the mask, such as Data, DataMut, FillPath, IntersectPath or Invert, makes its pixels. A rect with no pixel inside the mask gives the mask of NewMask.

opts configure the mask, as D20 says.

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.

Port: a mask that no caller can hold drops its data (D35). A mask of NewRectMask drops its rectangle (D86).

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.

Port: the copy shares data with m, and the first write to either mask copies it. Clone only sets an atomic flag, so that two goroutines can clone a mask at the same time, as they can in upstream. When m cannot share its data, as when a caller can hold it, the copy takes only the rows of m from its first row that is not 0 to its last (D35). The copy of a mask of NewRectMask holds the same rectangle and no pixels (D86).

func (*Mask) Data

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

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

Port: the first call makes data hold every pixel (D35).

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.

Port: the first call makes data hold every pixel (D35).

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 pixels 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). Then data holds only the pixels that the path and the mask both cover, with the margin of padColumns (D35). A mask of NewRectMask first makes its pixels (D86).

func (*Mask) Invert

func (m *Mask) Invert()

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

Port: data first holds every pixel (D35).

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) Parameters added in v0.17.0

func (m MeshGradient) Parameters() MeshParameters

Parameters gives the parameters of the mesh. It copies the 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 MeshParameters added in v0.17.0

type MeshParameters struct {
	// Triangles are the triangles that NewMeshGradient kept, in their
	// order. The colors are the colors of the caller, without Opacity.
	Triangles []MeshTriangle
	// Opacity is the opacity that ApplyOpacity gave, from 0 to 1.
	Opacity float32
	// Transform maps the space of the triangles to the space of the user.
	Transform Transform
}

MeshParameters are the parameters of a MeshGradient, which MeshGradient.Parameters gives (D68).

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) Parameters added in v0.17.0

func (p Pattern) Parameters() PatternParameters

Parameters gives the parameters of the pattern.

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 PatternParameters added in v0.17.0

type PatternParameters struct {
	// Pixmap is the pixmap of the pattern. It shares the pixels of the
	// pattern.
	Pixmap PixmapRef
	// Mode is the spread mode.
	Mode SpreadMode
	// Quality is the filter quality.
	Quality FilterQuality
	// Opacity is the opacity, from 0 to 1.
	Opacity float32
	// Transform maps the space of the pixmap to the space of the user.
	Transform Transform
}

PatternParameters are the parameters of a Pattern, which Pattern.Parameters gives (D68).

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) Parameters added in v0.17.0

func (g RadialGradient) Parameters() GradientParameters

Parameters gives the parameters of the radial gradient: the circles that its constructor took. For a degenerate gradient of NewRadialGradient that draws a ring, the start circle has the radius 0 and the stops give the ring.

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 NewRadialGradientExtend added in v0.13.0

func NewRadialGradientExtend(
	startPoint Point,
	startRadius float32,
	endPoint Point,
	endRadius float32,
	stops []GradientStop,
	extendStart, extendEnd bool,
	transform Transform,
) (Shader, bool)

NewRadialGradientExtend makes a radial gradient that follows the rule of the radial shadings of PDF and PostScript, the shadings of type 3 (D64). tiny-skia does not have it.

The gradient has a circle for each t. The center of the circle goes from startPoint at t = 0 to endPoint at t = 1, and its radius goes from startRadius to endRadius. A point takes the color of the largest t whose circle passes through the point and has a radius of at least 0. The t must be in 0..=1, with two exceptions:

  • If extendStart is true, t can be less than 0. The point then takes the color at t = 0.
  • If extendEnd is true, t can be more than 1. The point then takes the color at t = 1.

A point without such a t is transparent black. extendStart and extendEnd are the two values of the key Extend of a shading of PDF, and of the shadings of PostScript.

A gradient of NewRadialGradient takes the largest t of all, and its spread mode then gives the color of that t. The two rules give the same colors when the circles nest and both extendStart and extendEnd are true. They can differ in the other cases. For example, a point whose largest t is more than 1 takes the color of a smaller t in 0..=1 here, when one exists.

In one case, the radius changes almost as fast as the center moves. The start circle then almost touches the end circle on the inside. The gradient then has one circle at most through each point. tiny-skia does the same for a focal point on the end circle.

The gradient is a RadialGradient. Its colors come from the highp pipeline, and it is never opaque. A gradient with one stop has the color of that stop where a t exists.

It returns false when:

  • stops is empty
  • startRadius < 0 or endRadius < 0, or a point or a radius is not finite
  • transform is not invertible
  • the centers are nearly equal and the radii are nearly equal, so that each circle is the same circle

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) Parameters added in v0.17.0

func (g SweepGradient) Parameters() GradientParameters

Parameters gives the parameters of the sweep gradient. The angles come from the values that tiny-skia keeps, so they can differ from the angles of NewSweepGradient in the last bits.

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 filter is the port of filtra, which applies the filter effects of SVG and CSS to pixmaps (D108).
Package filter is the port of filtra, which applies the filter effects of SVG and CSS to pixmaps (D108).
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.
colr
Package colr walks the paint graph of a COLR glyph.
Package colr walks the paint graph of a COLR glyph.
crmath
Package crmath gives correctly rounded results of the math functions that tiny-skia, kurbo, svgtypes, resvg and filtra call from the C library: acos, cos, sin, tan, atan2, pow, exp, 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, resvg and filtra call from the C library: acos, cos, sin, tan, atan2, pow, exp, ln and log2 for an f64, and acos, cos, sin, tan, atan2, pow and hypot for an f32.
glyphoutline
Package glyphoutline draws the outline of a glyph of typesetting in the order of skrifa.
Package glyphoutline draws the outline of a glyph of typesetting in the order of skrifa.
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.
pathbool
Package pathbool computes the geometric boolean operations of paths: the union, the difference, the intersection and the exclusion of the areas that they fill.
Package pathbool computes the geometric boolean operations of paths: the union, the difference, the intersection and the exclusion of the areas that they fill.
pdfcompat
Package pdfcompat holds the switch that makes the package pdf write the text of a glyph as krilla does, without the second CIDs and the empty ActualText of D102.
Package pdfcompat holds the switch that makes the package pdf write the text of a glyph as krilla does, without the second CIDs and the empty ActualText of D102.
pdfwriter
Package pdfwriter is a port of the part of the Rust crate pdf-writer 0.15.0 that krilla calls, at the commit fdf09012 (D62).
Package pdfwriter is a port of the part of the Rust crate pdf-writer 0.15.0 that krilla calls, at the commit fdf09012 (D62).
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.
siphasher
Package siphasher is a port of the module sip128 of the Rust crate siphasher 1.0.2, at the commit db817204.
Package siphasher is a port of the module sip128 of the Rust crate siphasher 1.0.2, at the commit db817204.
subsetter
Package subsetter is a port of the Rust crate subsetter 0.2.6, from the base commit c3f23c67 (D62).
Package subsetter is a port of the Rust crate subsetter 0.2.6, from the base commit c3f23c67 (D62).
svgtypes
Package svgtypes is a port of the Rust crate svgtypes 0.16.2, a collection of parsers for SVG types.
Package svgtypes is a port of the Rust crate svgtypes 0.16.2, a collection of parsers for SVG types.
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/fusegen command
Command fusegen writes the fused programs of the package wide (D98).
Command fusegen writes the fused programs of the package wide (D98).
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.
xmpwriter
Package xmpwriter is a port of the Rust crate xmp-writer 0.3.3, at the commit 9498ae2b that krilla uses (D99).
Package xmpwriter is a port of the Rust crate xmp-writer 0.3.3, at the commit 9498ae2b that krilla uses (D99).
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 pdf is a port of the Rust crate krilla, from the base commit e3459d06 (D62).
Package pdf is a port of the Rust crate krilla, from the base commit e3459d06 (D62).
Package pdfsvg is a port of the Rust crate krilla-svg, from the base commit e3459d06 of krilla (D62).
Package pdfsvg is a port of the Rust crate krilla-svg, from the base commit e3459d06 of krilla (D62).
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 texmath lays out mathematical formulas with the OpenType MATH table of a font, by the rules of TeX Appendix G. It is the port of github.com/go-tex/math at the commit 6a6d2729, and a fork of it (D78).
Package texmath lays out mathematical formulas with the OpenType MATH table of a font, by the rules of TeX Appendix G. It is the port of github.com/go-tex/math at the commit 6a6d2729, and a fork of it (D78).
stixtwomath
Package stixtwomath holds the font STIX Two Math, which has an OpenType MATH table, for the math layout of texmath (D78).
Package stixtwomath holds the font STIX Two Math, which has an OpenType MATH table, for the math layout of texmath (D78).
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.
harfbuzz/internal/packtab
Package packtab is a copy of the package packtab of the generators of github.com/go-text/typesetting-utils, which packs a table of integers into small lookup tables.
Package packtab is a copy of the package packtab of the generators of github.com/go-text/typesetting-utils, which packs a table of integers into small lookup tables.
harfbuzz/internal/usegen command
Command usegen writes ot_shape_use_table.go, the table of the categories of the USE shaper of harfbuzz.
Command usegen writes ot_shape_use_table.go, the table of the categories of the USE shaper of harfbuzz.
harfbuzz/internal/usetable
Package usetable is a port of src/gen-use-table.py of HarfBuzz 15.2.0.
Package usetable is a port of src/gen-use-table.py of HarfBuzz 15.2.0.
internal/testfonts
Package testfonts reads the files of the module github.com/go-text/typesetting-utils that okage copies into typesetting/testdata (D63).
Package testfonts reads the files of the module github.com/go-text/typesetting-utils that okage copies into typesetting/testdata (D63).
internal/testfonts/harfbuzz
Package harfbuzz gives the files of the folder harfbuzz of the module github.com/go-text/typesetting-utils, which okage copies into typesetting/testdata/harfbuzz (D63, D76).
Package harfbuzz gives the files of the folder harfbuzz of the module github.com/go-text/typesetting-utils, which okage copies into typesetting/testdata/harfbuzz (D63, D76).
internal/testfonts/opentype
Package opentype gives the files of the folder opentype of the module github.com/go-text/typesetting-utils, which okage copies into typesetting/testdata/opentype (D63, D76).
Package opentype gives the files of the folder opentype of the module github.com/go-text/typesetting-utils, which okage copies into typesetting/testdata/opentype (D63, D76).
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