path

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: BSD-3-Clause Imports: 7 Imported by: 1 module, 3 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.

Documentation

Overview

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.

The package holds a memory-efficient container for a Bezier path, a path builder, a path stroker and a path dasher.

It also holds some basic geometry types. Upstream says that they will move to an external crate eventually.

All types use single precision floats (float32), as Skia does.

The arithmetic gives the same bits as the Rust code. 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 (D16).

Index

Constants

View Source
const NormalizedF32ExclusiveAny = NormalizedF32ExclusiveHalf

NormalizedF32ExclusiveAny is NormalizedF32Exclusive::ANY in tiny-skia-path path/src/floating_point.rs. It is just a random, valid number.

View Source
const ScalarMax float32 = 3.402823466e+38

ScalarMax is SCALAR_MAX in tiny-skia-path path/src/scalar.rs.

View Source
const ScalarNearlyZero float32 = 1.0 / (1 << 12)

ScalarNearlyZero is SCALAR_NEARLY_ZERO in tiny-skia-path path/src/scalar.rs.

View Source
const ScalarRoot2Over2 float32 = 0.707106781

ScalarRoot2Over2 is SCALAR_ROOT_2_OVER_2 in tiny-skia-path path/src/scalar.rs.

Variables

This section is empty.

Functions

func AlmostDequalULPs

func AlmostDequalULPs(x, other float32) bool

AlmostDequalULPs is Scalar::almost_dequal_ulps in tiny-skia-path path/src/scalar.rs. It comes from SkPathOpsTypes.

func Ave

func Ave(x, other float32) float32

Ave is Scalar::ave in tiny-skia-path path/src/scalar.rs.

func Bound

func Bound(x, min, max float32) float32

Bound is Scalar::bound in tiny-skia-path path/src/scalar.rs. It is a clamp that does not panic.

It works like SkTPin, and returns max for NaN and infinity.

func ChopCubicAt2

func ChopCubicAt2(src *[4]Point, t NormalizedF32Exclusive, dst []Point)

ChopCubicAt2 is chop_cubic_at2 in tiny-skia-path path/src/path_geometry.rs.

func ChopQuadAt

func ChopQuadAt(src []Point, t NormalizedF32Exclusive, dst *[5]Point)

ChopQuadAt is chop_quad_at in tiny-skia-path path/src/path_geometry.rs.

func ComputeResolutionScale

func ComputeResolutionScale(ts Transform) float32

ComputeResolutionScale is PathStroker::compute_resolution_scale in tiny-skia-path path/src/stroker.rs. It computes a resolution scale.

The resolution scale is the "intended" resolution for the output. The default is 1.0.

A larger value (res > 1) tells that the result must be more precise, because it will be zoomed up, and small errors will be magnified.

A smaller value (0 < res < 1) tells that the result can be less precise, because it will be zoomed down, and small errors can be invisible.

func FindUnitQuadRoots

func FindUnitQuadRoots(a, b, c float32, roots *[3]NormalizedF32Exclusive) int

FindUnitQuadRoots is find_unit_quad_roots in tiny-skia-path path/src/path_geometry.rs.

From Numerical Recipes in C.

Q = -1/2 (B + sign(B) sqrt[B*B - 4*A*C])
x1 = Q / A
x2 = C / Q

func Half

func Half(x float32) float32

Half is Scalar::half in tiny-skia-path path/src/scalar.rs.

func Invert

func Invert(x float32) float32

Invert is Scalar::invert in tiny-skia-path path/src/scalar.rs.

func IsNearlyEqual

func IsNearlyEqual(x, other float32) bool

IsNearlyEqual is Scalar::is_nearly_equal in tiny-skia-path path/src/scalar.rs.

func IsNearlyEqualWithinTolerance

func IsNearlyEqualWithinTolerance(x, other, tolerance float32) bool

IsNearlyEqualWithinTolerance is Scalar::is_nearly_equal_within_tolerance in tiny-skia-path path/src/scalar.rs.

func IsNearlyZero

func IsNearlyZero(x float32) bool

IsNearlyZero is Scalar::is_nearly_zero in tiny-skia-path path/src/scalar.rs.

func IsNearlyZeroWithinTolerance

func IsNearlyZeroWithinTolerance(x, tolerance float32) bool

IsNearlyZeroWithinTolerance is Scalar::is_nearly_zero_within_tolerance in tiny-skia-path path/src/scalar.rs.

func SaturateCeil

func SaturateCeil(x float32) int32

SaturateCeil is i32::saturate_ceil of the trait SaturateRound<f32> in tiny-skia-path path/src/floating_point.rs.

func SaturateFloor

func SaturateFloor(x float32) int32

SaturateFloor is i32::saturate_floor of the trait SaturateRound<f32> in tiny-skia-path path/src/floating_point.rs.

func SaturateFrom

func SaturateFrom(x float32) int32

SaturateFrom is i32::saturate_from of the trait SaturateCast<f32> in tiny-skia-path path/src/floating_point.rs. It returns the closest integer for the given float.

It returns MAX_I32_FITS_IN_F32 for NaN.

func SaturateFromF64

func SaturateFromF64(x float64) int32

SaturateFromF64 is i32::saturate_from of the trait SaturateCast<f64> in tiny-skia-path path/src/floating_point.rs. It returns the closest integer for the given double.

It returns i32::MAX for NaN.

func SaturateRound

func SaturateRound(x float32) int32

SaturateRound is i32::saturate_round of the trait SaturateRound<f32> in tiny-skia-path path/src/floating_point.rs.

func Sqr

func Sqr(x float32) float32

Sqr is Scalar::sqr in tiny-skia-path path/src/scalar.rs.

Types

type CubicCoeff

type CubicCoeff struct {
	A F32x2
	B F32x2
	C F32x2
	D F32x2
}

CubicCoeff is CubicCoeff in tiny-skia-path path/src/path_geometry.rs.

func CubicCoeffFromPoints

func CubicCoeffFromPoints(points *[4]Point) CubicCoeff

CubicCoeffFromPoints is CubicCoeff::from_points in tiny-skia-path path/src/path_geometry.rs.

func (CubicCoeff) Eval

func (c CubicCoeff) Eval(t F32x2) F32x2

Eval is CubicCoeff::eval in tiny-skia-path path/src/path_geometry.rs.

type F32x2

type F32x2 [2]float32

F32x2 is f32x2 in tiny-skia-path path/src/f32x2_t.rs. It is a pair of float32 numbers.

Upstream says that it is mainly for internal use, and that a user must not rely on it.

Right now, there are no visible benefits of using SIMD for f32x2. So we don't.

func F32x2Splat

func F32x2Splat(x float32) F32x2

F32x2Splat is f32x2::splat in tiny-skia-path path/src/f32x2_t.rs. It creates a new pair from a single value.

func NewF32x2

func NewF32x2(a, b float32) F32x2

NewF32x2 is f32x2::new in tiny-skia-path path/src/f32x2_t.rs. It creates a new pair.

func (F32x2) Abs

func (v F32x2) Abs() F32x2

Abs is f32x2::abs in tiny-skia-path path/src/f32x2_t.rs. It returns an absolute value.

func (F32x2) Add

func (v F32x2) Add(other F32x2) F32x2

Add is the core::ops::Add impl of f32x2 in tiny-skia-path path/src/f32x2_t.rs.

func (F32x2) Div

func (v F32x2) Div(other F32x2) F32x2

Div is the core::ops::Div impl of f32x2 in tiny-skia-path path/src/f32x2_t.rs.

func (F32x2) Max

func (v F32x2) Max(other F32x2) F32x2

Max is f32x2::max in tiny-skia-path path/src/f32x2_t.rs. It returns a maximum value.

func (F32x2) MaxComponent

func (v F32x2) MaxComponent() float32

MaxComponent is f32x2::max_component in tiny-skia-path path/src/f32x2_t.rs. It returns the maximum of both values.

func (F32x2) Min

func (v F32x2) Min(other F32x2) F32x2

Min is f32x2::min in tiny-skia-path path/src/f32x2_t.rs. It returns a minimum value.

func (F32x2) Mul

func (v F32x2) Mul(other F32x2) F32x2

Mul is the core::ops::Mul impl of f32x2 in tiny-skia-path path/src/f32x2_t.rs.

func (F32x2) Sub

func (v F32x2) Sub(other F32x2) F32x2

Sub is the core::ops::Sub impl of f32x2 in tiny-skia-path path/src/f32x2_t.rs.

func (F32x2) X

func (v F32x2) X() float32

X is f32x2::x in tiny-skia-path path/src/f32x2_t.rs. It returns the first value.

func (F32x2) Y

func (v F32x2) Y() float32

Y is f32x2::y in tiny-skia-path path/src/f32x2_t.rs. It returns the second value.

type FiniteF32

type FiniteF32 float32

FiniteF32 is FiniteF32 in strict-num src/lib.rs. It is an immutable, finite float32.

func NewFiniteF32

func NewFiniteF32(n float32) (FiniteF32, bool)

NewFiniteF32 is FiniteF32::new in strict-num src/lib.rs. It creates a finite float32.

It returns false for NaN and infinity.

func (FiniteF32) Get

func (n FiniteF32) Get() float32

Get is FiniteF32::get in strict-num src/lib.rs. It returns the value as a primitive type.

type IntRect

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

IntRect is IntRect in tiny-skia-path path/src/rect.rs. It is an integer rectangle.

The type guarantees these facts:

  • The width and the height are in the range 1..=i32::MAX.
  • x+width and y+height do not overflow.

func IntRectFromLTRB

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

IntRectFromLTRB is IntRect::from_ltrb in tiny-skia-path path/src/rect.rs. It creates a new IntRect.

func IntRectFromXYWH

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

IntRectFromXYWH is IntRect::from_xywh in tiny-skia-path path/src/rect.rs. It creates a new IntRect.

func (IntRect) Bottom

func (r IntRect) Bottom() int32

Bottom is IntRect::bottom in tiny-skia-path path/src/rect.rs. It returns the bottom edge of the rectangle.

func (IntRect) Contains

func (r IntRect) Contains(other IntRect) bool

Contains is IntRect::contains in tiny-skia-path path/src/rect.rs. It checks that the rectangle includes all of other.

func (IntRect) Height

func (r IntRect) Height() uint32

Height is IntRect::height in tiny-skia-path path/src/rect.rs. It returns the height of the rectangle.

func (IntRect) Inset

func (r IntRect) Inset(dx, dy int32) (IntRect, bool)

Inset is IntRect::inset in tiny-skia-path path/src/rect.rs. It insets the rectangle.

func (IntRect) Intersect

func (r IntRect) Intersect(other IntRect) (IntRect, bool)

Intersect is IntRect::intersect in tiny-skia-path path/src/rect.rs. It returns the intersection of two rectangles.

It returns false if the rectangles do not intersect.

func (IntRect) Left

func (r IntRect) Left() int32

Left is IntRect::left in tiny-skia-path path/src/rect.rs. It returns the left edge of the rectangle.

func (IntRect) MakeOutset

func (r IntRect) MakeOutset(dx, dy int32) (IntRect, bool)

MakeOutset is IntRect::make_outset in tiny-skia-path path/src/rect.rs. It outsets the rectangle.

func (IntRect) Right

func (r IntRect) Right() int32

Right is IntRect::right in tiny-skia-path path/src/rect.rs. It returns the right edge of the rectangle.

func (IntRect) Size

func (r IntRect) Size() IntSize

Size is IntRect::size in tiny-skia-path path/src/rect.rs. It returns the size of the rectangle.

func (IntRect) ToRect

func (r IntRect) ToRect() Rect

ToRect is IntRect::to_rect in tiny-skia-path path/src/rect.rs. It converts the rectangle into a Rect.

func (IntRect) Top

func (r IntRect) Top() int32

Top is IntRect::top in tiny-skia-path path/src/rect.rs. It returns the top edge of the rectangle.

func (IntRect) Translate

func (r IntRect) Translate(tx, ty int32) (IntRect, bool)

Translate is IntRect::translate in tiny-skia-path path/src/rect.rs. It translates the rectangle by the given offset.

func (IntRect) TranslateTo

func (r IntRect) TranslateTo(x, y int32) (IntRect, bool)

TranslateTo is IntRect::translate_to in tiny-skia-path path/src/rect.rs. It translates the rectangle to the given position.

func (IntRect) Width

func (r IntRect) Width() uint32

Width is IntRect::width in tiny-skia-path path/src/rect.rs. It returns the width of the rectangle.

func (IntRect) X

func (r IntRect) X() int32

X is IntRect::x in tiny-skia-path path/src/rect.rs. It returns the X position of the rectangle.

func (IntRect) Y

func (r IntRect) Y() int32

Y is IntRect::y in tiny-skia-path path/src/rect.rs. It returns the Y position of the rectangle.

type IntSize

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

IntSize is IntSize in tiny-skia-path path/src/size.rs. It is an integer size.

The width and the height are guaranteed to be positive and not zero.

func IntSizeFromWH

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

IntSizeFromWH is IntSize::from_wh in tiny-skia-path path/src/size.rs. It creates a new IntSize from a width and a height.

func (IntSize) Dimensions

func (s IntSize) Dimensions() (uint32, uint32)

Dimensions is IntSize::dimensions in tiny-skia-path path/src/size.rs. It returns the width and the height.

func (IntSize) Height

func (s IntSize) Height() uint32

Height is IntSize::height in tiny-skia-path path/src/size.rs. It returns the height.

func (IntSize) ScaleBy

func (s IntSize) ScaleBy(factor float32) (IntSize, bool)

ScaleBy is IntSize::scale_by in tiny-skia-path path/src/size.rs. It scales the size by the given factor.

func (IntSize) ScaleTo

func (s IntSize) ScaleTo(to IntSize) IntSize

ScaleTo is IntSize::scale_to in tiny-skia-path path/src/size.rs. It scales the size to the given size.

func (IntSize) ScaleToHeight

func (s IntSize) ScaleToHeight(newHeight uint32) (IntSize, bool)

ScaleToHeight is IntSize::scale_to_height in tiny-skia-path path/src/size.rs. It scales the size to the given height.

func (IntSize) ScaleToWidth

func (s IntSize) ScaleToWidth(newWidth uint32) (IntSize, bool)

ScaleToWidth is IntSize::scale_to_width in tiny-skia-path path/src/size.rs. It scales the size to the given width.

func (IntSize) ToIntRect

func (s IntSize) ToIntRect(x, y int32) IntRect

ToIntRect is IntSize::to_int_rect in tiny-skia-path path/src/size.rs. It converts the size into an IntRect at the given position.

func (IntSize) ToSize

func (s IntSize) ToSize() Size

ToSize is IntSize::to_size in tiny-skia-path path/src/size.rs. It converts the size into a Size.

func (IntSize) Width

func (s IntSize) Width() uint32

Width is IntSize::width in tiny-skia-path path/src/size.rs. It returns the width.

type LineCap

type LineCap uint8

LineCap is LineCap in tiny-skia-path path/src/stroker.rs. It is what a stroke draws at the start and the end of an open contour of a path.

The zero value is LineCapButt, the Default of upstream.

const (
	// LineCapButt adds no extension to the stroke.
	LineCapButt LineCap = iota
	// LineCapRound adds a circle.
	LineCapRound
	// LineCapSquare adds a square.
	LineCapSquare
)

func (LineCap) String

func (c LineCap) String() string

String satisfies the fmt.Stringer interface.

type LineJoin

type LineJoin uint8

LineJoin is LineJoin in tiny-skia-path path/src/stroker.rs. It sets how a stroke draws the corners of a shape.

The join affects the four corners of a stroked rectangle, and the connected segments of a stroked path.

Choose the miter join to draw sharp corners. Choose the round join to draw a circle with a radius equal to the stroke width on top of the corner. Choose the bevel join to connect the thick strokes with the smallest shape.

The fill path made to describe the stroked path uses the join setting, but it can omit the actual join. For example, a fill path made with round joins does not always include circles at each connected segment.

The zero value is LineJoinMiter, the Default of upstream.

const (
	// LineJoinMiter extends to the miter limit, then switches to bevel.
	LineJoinMiter LineJoin = iota
	// LineJoinMiterClip extends to the miter limit, then clips the corner.
	LineJoinMiterClip
	// LineJoinRound adds a circle.
	LineJoinRound
	// LineJoinBevel connects the outside edges.
	LineJoinBevel
)

func (LineJoin) String

func (j LineJoin) String() string

String satisfies the fmt.Stringer interface.

type NonZeroPositiveF32

type NonZeroPositiveF32 float32

NonZeroPositiveF32 is NonZeroPositiveF32 in strict-num src/lib.rs. It is an immutable, finite float32 that is known to be > 0.

func NewNonZeroPositiveF32

func NewNonZeroPositiveF32(n float32) (NonZeroPositiveF32, bool)

NewNonZeroPositiveF32 is NonZeroPositiveF32::new in strict-num src/lib.rs. It creates a new NonZeroPositiveF32 if the given value is > 0.

It returns false for a negative value, zero, NaN and infinity.

func (NonZeroPositiveF32) Get

func (n NonZeroPositiveF32) Get() float32

Get is NonZeroPositiveF32::get in strict-num src/lib.rs. It returns the value as a primitive type.

func (NonZeroPositiveF32) GetFinite

func (n NonZeroPositiveF32) GetFinite() FiniteF32

GetFinite is NonZeroPositiveF32::get_finite in strict-num src/lib.rs. It returns the value as a FiniteF32.

type NonZeroRect

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

NonZeroRect is NonZeroRect in tiny-skia-path path/src/rect.rs. It is a rectangle defined by its left, top, right and bottom edges.

It is like Rect, but its width and its height are guaranteed to be positive and not zero.

The type guarantees these facts:

  • All values are finite.
  • The left edge is < right.
  • The top edge is < bottom.
  • The width and the height are <= f32::MAX.
  • The width and the height are > 0.0.

func NonZeroRectFromLTRB

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

NonZeroRectFromLTRB is NonZeroRect::from_ltrb in tiny-skia-path path/src/rect.rs. It creates a new NonZeroRect.

func NonZeroRectFromXYWH

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

NonZeroRectFromXYWH is NonZeroRect::from_xywh in tiny-skia-path path/src/rect.rs. It creates a new NonZeroRect.

func (NonZeroRect) BBoxTransform

func (r NonZeroRect) BBoxTransform(bbox NonZeroRect) NonZeroRect

BBoxTransform is NonZeroRect::bbox_transform in tiny-skia-path path/src/rect.rs. It applies a bounding box transform.

func (NonZeroRect) Bottom

func (r NonZeroRect) Bottom() float32

Bottom is NonZeroRect::bottom in tiny-skia-path path/src/rect.rs. It returns the bottom edge.

func (NonZeroRect) Height

func (r NonZeroRect) Height() float32

Height is NonZeroRect::height in tiny-skia-path path/src/rect.rs. It returns the height of the rectangle.

func (NonZeroRect) Left

func (r NonZeroRect) Left() float32

Left is NonZeroRect::left in tiny-skia-path path/src/rect.rs. It returns the left edge.

func (NonZeroRect) Right

func (r NonZeroRect) Right() float32

Right is NonZeroRect::right in tiny-skia-path path/src/rect.rs. It returns the right edge.

func (NonZeroRect) Size

func (r NonZeroRect) Size() Size

Size is NonZeroRect::size in tiny-skia-path path/src/rect.rs. It returns the size of the rectangle.

func (NonZeroRect) ToIntRect

func (r NonZeroRect) ToIntRect() IntRect

ToIntRect is NonZeroRect::to_int_rect in tiny-skia-path path/src/rect.rs. It converts the rectangle into an IntRect.

func (NonZeroRect) ToRect

func (r NonZeroRect) ToRect() Rect

ToRect is NonZeroRect::to_rect in tiny-skia-path path/src/rect.rs. It converts the rectangle into a Rect.

func (NonZeroRect) Top

func (r NonZeroRect) Top() float32

Top is NonZeroRect::top in tiny-skia-path path/src/rect.rs. It returns the top edge.

func (NonZeroRect) Transform

func (r NonZeroRect) Transform(ts Transform) (NonZeroRect, bool)

Transform is NonZeroRect::transform in tiny-skia-path path/src/rect.rs. It transforms the rectangle with the given Transform.

If the transform is a skew, the result is a bounding box around the skewed rectangle.

func (NonZeroRect) TranslateTo

func (r NonZeroRect) TranslateTo(x, y float32) (NonZeroRect, bool)

TranslateTo is NonZeroRect::translate_to in tiny-skia-path path/src/rect.rs. It translates the rectangle to the given position.

func (NonZeroRect) Width

func (r NonZeroRect) Width() float32

Width is NonZeroRect::width in tiny-skia-path path/src/rect.rs. It returns the width of the rectangle.

func (NonZeroRect) X

func (r NonZeroRect) X() float32

X is NonZeroRect::x in tiny-skia-path path/src/rect.rs. It returns the X position of the rectangle.

func (NonZeroRect) Y

func (r NonZeroRect) Y() float32

Y is NonZeroRect::y in tiny-skia-path path/src/rect.rs. It returns the Y position of the rectangle.

type NormalizedF32

type NormalizedF32 float32

NormalizedF32 is NormalizedF32 in strict-num src/lib.rs. It is an immutable, finite float32 in the range 0..=1.

const NormalizedF32One NormalizedF32 = 1

NormalizedF32One is NormalizedF32::ONE in strict-num src/lib.rs. It is a NormalizedF32 with the value one.

const NormalizedF32Zero NormalizedF32 = 0

NormalizedF32Zero is NormalizedF32::ZERO in strict-num src/lib.rs. It is a NormalizedF32 with the value zero.

func FindCubicMaxCurvature

func FindCubicMaxCurvature(src *[4]Point, tValues *[3]NormalizedF32) []NormalizedF32

FindCubicMaxCurvature is find_cubic_max_curvature in tiny-skia-path path/src/path_geometry.rs. It returns the part of tValues that holds the result.

Looking for

F' dot F'' == 0

A = b - a
B = c - 2b + a
C = d - 3c + 3b - a

F' = 3Ct^2 + 6Bt + 3A
F'' = 6Ct + 6B

F' dot F'' -> CCt^3 + 3BCt^2 + (2BB + CA)t + AB

func NewNormalizedF32

func NewNormalizedF32(n float32) (NormalizedF32, bool)

NewNormalizedF32 is NormalizedF32::new in strict-num src/lib.rs. It creates a NormalizedF32 if the given value is in the range 0..=1.

func NormalizedF32Clamped

func NormalizedF32Clamped(n float32) NormalizedF32

NormalizedF32Clamped is NormalizedF32::new_clamped in strict-num src/lib.rs. It creates a NormalizedF32 and clamps the given value to the range 0..=1.

It returns zero for NaN or infinity.

func NormalizedF32FromU8

func NormalizedF32FromU8(n uint8) NormalizedF32

NormalizedF32FromU8 is NormalizedF32::new_u8 in strict-num src/lib.rs. It creates a NormalizedF32 by dividing the given value by 255.

func NormalizedF32FromU16

func NormalizedF32FromU16(n uint16) NormalizedF32

NormalizedF32FromU16 is NormalizedF32::new_u16 in strict-num src/lib.rs. It creates a NormalizedF32 by dividing the given value by 65535.

func (NormalizedF32) Get

func (n NormalizedF32) Get() float32

Get is NormalizedF32::get in strict-num src/lib.rs. It returns the value as a primitive type.

func (NormalizedF32) GetFinite

func (n NormalizedF32) GetFinite() FiniteF32

GetFinite is NormalizedF32::get_finite in strict-num src/lib.rs. It returns the value as a FiniteF32.

func (NormalizedF32) Mul

Mul is the core::ops::Mul impl of NormalizedF32 in strict-num src/lib.rs. The product is clamped to the range 0..=1.

func (NormalizedF32) ToU8

func (n NormalizedF32) ToU8() uint8

ToU8 is NormalizedF32::to_u8 in strict-num src/lib.rs. It returns the value as a uint8.

func (NormalizedF32) ToU16

func (n NormalizedF32) ToU16() uint16

ToU16 is NormalizedF32::to_u16 in strict-num src/lib.rs. It returns the value as a uint16.

type NormalizedF32Exclusive

type NormalizedF32Exclusive float32

NormalizedF32Exclusive is NormalizedF32Exclusive in tiny-skia-path path/src/floating_point.rs. It is an immutable float32 that is larger than 0 and less than 1.

Port: upstream wraps a FiniteF32. A conversion such as NormalizedF32Exclusive(x) does not check the value, as new_unchecked does not in Rust. Use NewNormalizedF32Exclusive to check it.

const NormalizedF32ExclusiveHalf NormalizedF32Exclusive = 0.5

NormalizedF32ExclusiveHalf is NormalizedF32Exclusive::HALF in tiny-skia-path path/src/floating_point.rs. It is a predefined 0.5 value.

func NewNormalizedF32Exclusive

func NewNormalizedF32Exclusive(n float32) (NormalizedF32Exclusive, bool)

NewNormalizedF32Exclusive is NormalizedF32Exclusive::new in tiny-skia-path path/src/floating_point.rs. It creates a NormalizedF32Exclusive.

func NewTValues

func NewTValues() [3]NormalizedF32Exclusive

NewTValues is new_t_values in tiny-skia-path path/src/path_geometry.rs.

TODO: to a custom type?

func NormalizedF32ExclusiveBounded

func NormalizedF32ExclusiveBounded(n float32) NormalizedF32Exclusive

NormalizedF32ExclusiveBounded is NormalizedF32Exclusive::new_bounded in tiny-skia-path path/src/floating_point.rs. It creates a NormalizedF32Exclusive and clamps the given value.

Upstream says that it returns zero for NaN or infinity. The code returns the upper bound, 1 - f32::EPSILON, for NaN and infinity.

func ValidUnitDivide

func ValidUnitDivide(numer, denom float32) (NormalizedF32Exclusive, bool)

ValidUnitDivide is valid_unit_divide in tiny-skia-path path/src/path_geometry.rs.

func (NormalizedF32Exclusive) Get

Get is NormalizedF32Exclusive::get in tiny-skia-path path/src/floating_point.rs. It returns the value as a primitive type.

func (NormalizedF32Exclusive) ToNormalized

func (n NormalizedF32Exclusive) ToNormalized() NormalizedF32

ToNormalized is NormalizedF32Exclusive::to_normalized in tiny-skia-path path/src/floating_point.rs. It returns the value as a NormalizedF32.

type Path

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

Path is Path in tiny-skia-path path/src/path.rs. It is a Bezier path.

A PathBuilder creates a Path. PathBuilder.Finish returns the path, and Path.Clear returns a PathBuilder that reuses the memory of the path.

A Path is immutable and uses compact storage: it stores the types of the segments and the points apart. Path.Verbs and Path.Points give access to them, and so does Path.Segments.

The type guarantees these facts:

  • It has valid bounds, computed in advance.
  • All points are finite.
  • It has at least two segments.
  • Each contour starts with a MoveTo.
  • No Move follows a Move.
  • No Close follows a Close.
  • Contours of zero length are allowed.

func PathFromCircle

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

PathFromCircle is PathBuilder::from_circle in tiny-skia-path path/src/path_builder.rs. It creates a new Path from a circle.

See PathBuilder.PushCircle for details.

func PathFromOval

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

PathFromOval is PathBuilder::from_oval in tiny-skia-path path/src/path_builder.rs. It creates a new Path from an oval.

See PathBuilder.PushOval for details.

func PathFromRect

func PathFromRect(rect Rect) *Path

PathFromRect is PathBuilder::from_rect in tiny-skia-path path/src/path_builder.rs. It creates a new Path from a Rect.

It never fails, because a Rect is always valid.

It creates the segments clockwise: TopLeft -> TopRight -> BottomRight -> BottomLeft.

The contour is closed.

func (*Path) Bounds

func (p *Path) Bounds() Rect

Bounds is Path::bounds in tiny-skia-path path/src/path.rs. It returns the bounds of the points of the path.

The value is already computed.

func (*Path) Clear

func (p *Path) Clear() *PathBuilder

Clear is Path::clear in tiny-skia-path path/src/path.rs. It clears the path and returns a PathBuilder that reuses the allocated memory.

Port: Rust consumes the path. Do not use p after Clear.

func (*Path) Clone

func (p *Path) Clone() *Path

Clone is the derived Clone impl of Path in tiny-skia-path path/src/path.rs. It returns a deep copy of the path.

func (*Path) ComputeTightBounds

func (p *Path) ComputeTightBounds() (Rect, bool)

ComputeTightBounds is Path::compute_tight_bounds in tiny-skia-path path/src/path.rs. It computes the tight bounds of the path.

This operation can be expensive.

func (*Path) Dash

func (p *Path) Dash(dash *StrokeDash, resolutionScale float32) (*Path, bool)

Dash is Path::dash in tiny-skia-path path/src/dash.rs. It converts the path into a dashed one.

ComputeResolutionScale gives resolutionScale.

It returns false when it has to make more than 1_000_000 dashes, or when the final path has an invalid bounding box.

func (*Path) IsEmpty

func (p *Path) IsEmpty() bool

IsEmpty is Path::is_empty in tiny-skia-path path/src/path.rs. It returns true if the path is empty.

func (*Path) Len

func (p *Path) Len() int

Len is Path::len in tiny-skia-path path/src/path.rs. It returns the number of segments in the path.

func (*Path) Points

func (p *Path) Points() []Point

Points is Path::points in tiny-skia-path path/src/path.rs. It returns the internal slice of points.

func (*Path) Segments

func (p *Path) Segments() PathSegmentsIter

Segments is Path::segments in tiny-skia-path path/src/path.rs. It returns an iterator over the segments of the path.

func (*Path) String

func (p *Path) String() string

String is the Debug impl of Path in tiny-skia-path path/src/path.rs. It satisfies the fmt.Stringer interface. It writes the segments as the commands of an SVG path, and the bounds.

Port: Rust writes the struct with the Debug format of Rust. Go writes the same text.

func (*Path) Stroke

func (p *Path) Stroke(stroke *Stroke, resolutionScale float32) (*Path, bool)

Stroke is Path::stroke in tiny-skia-path path/src/stroker.rs. It returns a stroked path.

ComputeResolutionScale gives resolutionScale.

If you plan to stroke many paths, you can use a PathStroker. It keeps the temporary allocations that a stroke needs, and this can make it a bit faster.

It returns false when a point of the path is NaN or infinite (D74).

func (*Path) Transform

func (p *Path) Transform(ts Transform) (*Path, bool)

Transform is Path::transform in tiny-skia-path path/src/path.rs. It transforms the path in place and returns it.

Some points can become NaN or infinity, so this method can fail.

Port: Rust consumes the path. Go changes p in place and returns p. When it returns false, p holds the transformed points and the old bounds, and it is not valid.

func (*Path) Verbs

func (p *Path) Verbs() []PathVerb

Verbs is Path::verbs in tiny-skia-path path/src/path.rs. It returns the internal slice of verbs.

type PathBuilder

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

PathBuilder is PathBuilder in tiny-skia-path path/src/path_builder.rs. It is a path builder.

The zero value is the Default impl of upstream. It differs from NewPathBuilder: it does not require a MoveTo first, so a LineTo on an empty zero value adds no Move(0, 0).

func NewPathBuilder

func NewPathBuilder() *PathBuilder

NewPathBuilder is PathBuilder::new in tiny-skia-path path/src/path_builder.rs. It creates a new builder.

func NewPathBuilderWithCapacity

func NewPathBuilderWithCapacity(verbsCapacity, pointsCapacity int) *PathBuilder

NewPathBuilderWithCapacity is PathBuilder::with_capacity in tiny-skia-path path/src/path_builder.rs. It creates a new builder with the given capacity.

The number of points depends on the type of the verb:

  • Move: 1
  • Line: 1
  • Quad: 2
  • Cubic: 3
  • Close: 0

func (*PathBuilder) Clear

func (pb *PathBuilder) Clear()

Clear is PathBuilder::clear in tiny-skia-path path/src/path_builder.rs. It resets the builder.

It keeps the allocated memory.

func (*PathBuilder) Clone

func (pb *PathBuilder) Clone() *PathBuilder

Clone is the derived Clone impl of PathBuilder in tiny-skia-path path/src/path_builder.rs. It returns a deep copy of the builder.

func (*PathBuilder) Close

func (pb *PathBuilder) Close()

Close is PathBuilder::close in tiny-skia-path path/src/path_builder.rs. It closes the current contour.

A closed contour connects the first and the last point with a line, and so forms a continuous loop.

It does nothing when the Path is empty or already closed.

An open contour and a closed contour are filled the same way. A stroke of an open contour adds a LineCap at the start and the end of the contour. A stroke of a closed contour adds a LineJoin at the start and the end of the contour.

func (*PathBuilder) CubicTo

func (pb *PathBuilder) CubicTo(x1, y1, x2, y2, x, y float32)

CubicTo is PathBuilder::cubic_to in tiny-skia-path path/src/path_builder.rs. It adds a cubic curve from the last point to x, y.

  • If the Path is empty, it adds Move(0, 0) first.
  • If the Path ends with Close, it adds Move(last_x, last_y) first.

func (*PathBuilder) Finish

func (pb *PathBuilder) Finish() (*Path, bool)

Finish is PathBuilder::finish in tiny-skia-path path/src/path_builder.rs. It finishes the builder and returns a Path.

It returns false when the Path is empty or has invalid bounds.

Port: Rust consumes the builder. Go moves the memory of pb into the Path and leaves pb as a zero value, in each case.

func (*PathBuilder) IsEmpty

func (pb *PathBuilder) IsEmpty() bool

IsEmpty is PathBuilder::is_empty in tiny-skia-path path/src/path_builder.rs. It checks if the builder has no segments.

func (*PathBuilder) LastPoint

func (pb *PathBuilder) LastPoint() (Point, bool)

LastPoint is PathBuilder::last_point in tiny-skia-path path/src/path_builder.rs. It returns the last point, if there is one.

func (*PathBuilder) Len

func (pb *PathBuilder) Len() int

Len is PathBuilder::len in tiny-skia-path path/src/path_builder.rs. It returns the current number of segments in the builder.

func (*PathBuilder) LineTo

func (pb *PathBuilder) LineTo(x, y float32)

LineTo is PathBuilder::line_to in tiny-skia-path path/src/path_builder.rs. It adds a line from the last point.

  • If the Path is empty, it adds Move(0, 0) first.
  • If the Path ends with Close, it adds Move(last_x, last_y) first.

func (*PathBuilder) MoveTo

func (pb *PathBuilder) MoveTo(x, y float32)

MoveTo is PathBuilder::move_to in tiny-skia-path path/src/path_builder.rs. It adds the start of a contour.

A MoveTo segment cannot follow a MoveTo segment. If the previous segment was also a MoveTo, the current one overwrites it.

func (*PathBuilder) PushCircle

func (pb *PathBuilder) PushCircle(x, y, r float32)

PushCircle is PathBuilder::push_circle in tiny-skia-path path/src/path_builder.rs. It adds a circle contour.

The contour is closed and has a clockwise direction.

It does nothing when:

  • radius <= 0
  • a value is not finite or is very large

func (*PathBuilder) PushOval

func (pb *PathBuilder) PushOval(oval Rect)

PushOval is PathBuilder::push_oval in tiny-skia-path path/src/path_builder.rs. It adds an oval contour bounded by the given rectangle.

The contour is closed and has a clockwise direction.

func (*PathBuilder) PushPath

func (pb *PathBuilder) PushPath(other *Path)

PushPath is PathBuilder::push_path in tiny-skia-path path/src/path_builder.rs. It adds a path.

func (*PathBuilder) PushRect

func (pb *PathBuilder) PushRect(rect Rect)

PushRect is PathBuilder::push_rect in tiny-skia-path path/src/path_builder.rs. It adds a rectangle contour.

The contour is closed and has a clockwise direction.

func (*PathBuilder) QuadTo

func (pb *PathBuilder) QuadTo(x1, y1, x, y float32)

QuadTo is PathBuilder::quad_to in tiny-skia-path path/src/path_builder.rs. It adds a quad curve from the last point to x, y.

  • If the Path is empty, it adds Move(0, 0) first.
  • If the Path ends with Close, it adds Move(last_x, last_y) first.

type PathSegment

type PathSegment struct {
	Kind   PathSegmentKind
	Points [3]Point
}

PathSegment is PathSegment in tiny-skia-path path/src/path.rs. It is a path segment.

Port: the Rust enum carries data, so it becomes a struct with a kind field. Points holds the points of the variant in their order: one for MoveTo and LineTo, two for QuadTo, three for CubicTo and none for Close. The other points are zero, so that two segments compare equal with ==.

type PathSegmentKind

type PathSegmentKind uint8

PathSegmentKind is the kind of a PathSegment. It is the variant of the enum PathSegment in tiny-skia-path path/src/path.rs.

const (
	PathSegmentMoveTo PathSegmentKind = iota
	PathSegmentLineTo
	PathSegmentQuadTo
	PathSegmentCubicTo
	PathSegmentClose
)

The values of PathSegmentKind.

func (PathSegmentKind) String

func (k PathSegmentKind) String() string

String satisfies the fmt.Stringer interface.

type PathSegmentsIter

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

PathSegmentsIter is PathSegmentsIter in tiny-skia-path path/src/path.rs. It is an iterator over the segments of a path.

func (PathSegmentsIter) All

All returns an iterator over the remaining segments, for use with range. It iterates over a copy of it, so it does not change it.

Port: it ports no upstream function. It is the Go form of the Rust Iterator impl of PathSegmentsIter.

func (*PathSegmentsIter) CurrVerb

func (it *PathSegmentsIter) CurrVerb() PathVerb

CurrVerb is PathSegmentsIter::curr_verb in tiny-skia-path path/src/path.rs. It returns the current verb.

func (*PathSegmentsIter) Next

func (it *PathSegmentsIter) Next() (PathSegment, bool)

Next is Iterator::next of PathSegmentsIter in tiny-skia-path path/src/path.rs. It returns the next segment, or false at the end.

func (*PathSegmentsIter) NextVerb

func (it *PathSegmentsIter) NextVerb() (PathVerb, bool)

NextVerb is PathSegmentsIter::next_verb in tiny-skia-path path/src/path.rs. It returns the next verb.

func (*PathSegmentsIter) SetAutoClose

func (it *PathSegmentsIter) SetAutoClose(flag bool)

SetAutoClose is PathSegmentsIter::set_auto_close in tiny-skia-path path/src/path.rs. It sets the auto closing mode. It is off by default.

When it is on, the iterator returns an extra LineTo segment from the current position to the previous MoveTo, and only then a Close segment.

type PathStroker

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

PathStroker is PathStroker in tiny-skia-path path/src/stroker.rs. It is a path stroker.

func NewPathStroker

func NewPathStroker() *PathStroker

NewPathStroker is PathStroker::new in tiny-skia-path path/src/stroker.rs. It creates a new PathStroker. The Default impl of upstream is the same.

func (*PathStroker) Stroke

func (s *PathStroker) Stroke(path *Path, stroke *Stroke, resolutionScale float32) (*Path, bool)

Stroke is PathStroker::stroke in tiny-skia-path path/src/stroker.rs. It strokes the path.

It can be called many times, to reuse the allocated buffers.

ComputeResolutionScale gives resolutionScale.

It returns false when a point of the path is NaN or infinite.

type PathVerb

type PathVerb uint8

PathVerb is PathVerb in tiny-skia-path path/src/path.rs. It is a path verb.

const (
	PathVerbMove PathVerb = iota
	PathVerbLine
	PathVerbQuad
	PathVerbCubic
	PathVerbClose
)

The values of PathVerb.

func (PathVerb) String

func (v PathVerb) String() string

String satisfies the fmt.Stringer interface.

type Point

type Point struct {
	X float32
	Y float32
}

Point is Point in tiny-skia-path path/src/lib.rs. It is a point.

The point is not guaranteed to be finite.

func PointFromF32x2

func PointFromF32x2(r F32x2) Point

PointFromF32x2 is Point::from_f32x2 in tiny-skia-path path/src/lib.rs. It creates a new Point from an F32x2.

func PointFromXY

func PointFromXY(x, y float32) Point

PointFromXY is Point::from_xy in tiny-skia-path path/src/lib.rs. It creates a new Point.

func PointZero

func PointZero() Point

PointZero is Point::zero in tiny-skia-path path/src/lib.rs. It creates a point at the position 0x0.

func (Point) Add

func (p Point) Add(other Point) Point

Add is the core::ops::Add impl of Point in tiny-skia-path path/src/lib.rs.

func (*Point) AddAssign

func (p *Point) AddAssign(other Point)

AddAssign is the core::ops::AddAssign impl of Point in tiny-skia-path path/src/lib.rs.

func (Point) Cross

func (p Point) Cross(other Point) float32

Cross is Point::cross in tiny-skia-path path/src/lib.rs. It returns the cross product of the vector and other.

The vector and other form three-dimensional vectors with a z value of zero. The cross product is a three-dimensional vector with x and y values of zero. Cross returns its z component.

func (Point) Distance

func (p Point) Distance(other Point) float32

Distance is Point::distance in tiny-skia-path path/src/lib.rs. It returns the Euclidean distance from other.

func (Point) Dot

func (p Point) Dot(other Point) float32

Dot is Point::dot in tiny-skia-path path/src/lib.rs. It returns the dot product of two points.

func (Point) IsFinite

func (p Point) IsFinite() bool

IsFinite is Point::is_finite in tiny-skia-path path/src/lib.rs. It returns true if both x and y are measurable values.

Both values are other than infinities and NaN.

Port: upstream tests the product x*y, so a product that overflows to infinity also gives false.

func (Point) IsZero

func (p Point) IsZero() bool

IsZero is Point::is_zero in tiny-skia-path path/src/lib.rs. It returns true if x and y are both zero.

func (Point) Length

func (p Point) Length() float32

Length is Point::length in tiny-skia-path path/src/lib.rs. It returns the Euclidean distance from the origin.

func (Point) Mul

func (p Point) Mul(other Point) Point

Mul is the core::ops::Mul impl of Point in tiny-skia-path path/src/lib.rs.

func (*Point) MulAssign

func (p *Point) MulAssign(other Point)

MulAssign is the core::ops::MulAssign impl of Point in tiny-skia-path path/src/lib.rs.

func (Point) Neg

func (p Point) Neg() Point

Neg is the core::ops::Neg impl of Point in tiny-skia-path path/src/lib.rs.

func (*Point) Normalize

func (p *Point) Normalize() bool

Normalize is Point::normalize in tiny-skia-path path/src/lib.rs. It scales (x, y) so that Length returns one, and keeps the ratio of x to y, if it can.

If the length before is nearly zero, it sets the vector to (0, 0) and returns false. Otherwise it returns true.

func (*Point) Scale

func (p *Point) Scale(scale float32)

Scale is Point::scale in tiny-skia-path path/src/lib.rs. It scales the point in place by scale.

func (*Point) SetLength

func (p *Point) SetLength(length float32) bool

SetLength is Point::set_length in tiny-skia-path path/src/lib.rs. It scales the vector so that its distance to the origin is length, if it can.

If the length before is nearly zero, it sets the vector to (0, 0) and returns false. Otherwise it returns true.

func (*Point) SetLengthFrom

func (p *Point) SetLengthFrom(x, y, length float32) bool

SetLengthFrom is Point::set_length_from in tiny-skia-path path/src/lib.rs. It sets the vector to (x, y) scaled to length, if it can.

If the length before is nearly zero, it sets the vector to (0, 0) and returns false. Otherwise it returns true.

func (*Point) SetNormalize

func (p *Point) SetNormalize(x, y float32) bool

SetNormalize is Point::set_normalize in tiny-skia-path path/src/lib.rs. It sets the vector to (x, y) scaled so that Length returns one, and so that the vector is proportional to (x, y).

If the length of (x, y) is nearly zero, it sets the vector to (0, 0) and returns false. Otherwise it returns true.

func (Point) Sub

func (p Point) Sub(other Point) Point

Sub is the core::ops::Sub impl of Point in tiny-skia-path path/src/lib.rs.

func (*Point) SubAssign

func (p *Point) SubAssign(other Point)

SubAssign is the core::ops::SubAssign impl of Point in tiny-skia-path path/src/lib.rs.

func (Point) ToF32x2

func (p Point) ToF32x2() F32x2

ToF32x2 is Point::to_f32x2 in tiny-skia-path path/src/lib.rs. It converts a Point into an F32x2.

type PositiveF32

type PositiveF32 float32

PositiveF32 is PositiveF32 in strict-num src/lib.rs. It is an immutable, finite float32 that is known to be >= 0.

const PositiveF32Zero PositiveF32 = 0

PositiveF32Zero is PositiveF32::ZERO in strict-num src/lib.rs. It is a PositiveF32 with the value zero.

func NewPositiveF32

func NewPositiveF32(n float32) (PositiveF32, bool)

NewPositiveF32 is PositiveF32::new in strict-num src/lib.rs. It creates a new PositiveF32 if the given value is >= 0.

It returns false for a negative value, NaN and infinity.

func (PositiveF32) Get

func (n PositiveF32) Get() float32

Get is PositiveF32::get in strict-num src/lib.rs. It returns the value as a primitive type.

func (PositiveF32) GetFinite

func (n PositiveF32) GetFinite() FiniteF32

GetFinite is PositiveF32::get_finite in strict-num src/lib.rs. It returns the value as a FiniteF32.

type QuadCoeff

type QuadCoeff struct {
	A F32x2
	B F32x2
	C F32x2
}

QuadCoeff is QuadCoeff in tiny-skia-path path/src/path_geometry.rs.

use for : eval(t) == A * t^2 + B * t + C.

func QuadCoeffFromPoints

func QuadCoeffFromPoints(points *[3]Point) QuadCoeff

QuadCoeffFromPoints is QuadCoeff::from_points in tiny-skia-path path/src/path_geometry.rs.

func (QuadCoeff) Eval

func (q QuadCoeff) Eval(t F32x2) F32x2

Eval is QuadCoeff::eval in tiny-skia-path path/src/path_geometry.rs.

type Rect

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

Rect is Rect in tiny-skia-path path/src/rect.rs. It is a rectangle defined by its left, top, right and bottom edges.

It can have a zero width or height, or both. But not a negative one.

The type guarantees these facts:

  • All values are finite.
  • The left edge is <= right.
  • The top edge is <= bottom.
  • The width and the height are <= f32::MAX.

func RectFromLTRB

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

RectFromLTRB is Rect::from_ltrb in tiny-skia-path path/src/rect.rs. It creates a new Rect.

func RectFromPoints

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

RectFromPoints is Rect::from_points in tiny-skia-path path/src/rect.rs. It creates a Rect from a slice of points.

It returns false if the slice is empty or if a point holds an infinity or NaN.

func RectFromXYWH

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

RectFromXYWH is Rect::from_xywh in tiny-skia-path path/src/rect.rs. It creates a new Rect.

func (Rect) BBoxTransform

func (r Rect) BBoxTransform(bbox NonZeroRect) Rect

BBoxTransform is Rect::bbox_transform in tiny-skia-path path/src/rect.rs. It applies a bounding box transform.

func (Rect) Bottom

func (r Rect) Bottom() float32

Bottom is Rect::bottom in tiny-skia-path path/src/rect.rs. It returns the bottom edge.

func (Rect) Height

func (r Rect) Height() float32

Height is Rect::height in tiny-skia-path path/src/rect.rs. It returns the height of the rectangle.

func (Rect) Inset

func (r Rect) Inset(dx, dy float32) (Rect, bool)

Inset is Rect::inset in tiny-skia-path path/src/rect.rs. It insets the rectangle by the given offset.

func (Rect) Intersect

func (r Rect) Intersect(other Rect) (Rect, bool)

Intersect is Rect::intersect in tiny-skia-path path/src/rect.rs. It returns the intersection of two rectangles.

It returns false if the rectangles do not intersect.

func (Rect) IsEmpty

func (r Rect) IsEmpty() bool

IsEmpty is Rect::is_empty in tiny-skia-path path/src/rect.rs. It returns true if the rectangle is empty.

func (Rect) Join

func (r Rect) Join(other Rect) (Rect, bool)

Join is Rect::join in tiny-skia-path path/src/rect.rs. It returns the union of two rectangles.

It returns false if the width or the height overflows.

func (Rect) Left

func (r Rect) Left() float32

Left is Rect::left in tiny-skia-path path/src/rect.rs. It returns the left edge.

func (Rect) Outset

func (r Rect) Outset(dx, dy float32) (Rect, bool)

Outset is Rect::outset in tiny-skia-path path/src/rect.rs. It outsets the rectangle by the given offset.

func (Rect) Right

func (r Rect) Right() float32

Right is Rect::right in tiny-skia-path path/src/rect.rs. It returns the right edge.

func (Rect) Round

func (r Rect) Round() (IntRect, bool)

Round is Rect::round in tiny-skia-path path/src/rect.rs. It converts the rectangle into an IntRect: it adds 0.5 and discards the fraction.

The width and the height are guaranteed to be >= 1.

func (Rect) RoundOut

func (r Rect) RoundOut() (IntRect, bool)

RoundOut is Rect::round_out in tiny-skia-path path/src/rect.rs. It converts the rectangle into an IntRect and rounds outwards.

The width and the height are guaranteed to be >= 1.

func (Rect) String

func (r Rect) String() string

String is the Debug impl of Rect in tiny-skia-path path/src/rect.rs. It satisfies the fmt.Stringer interface.

func (Rect) ToNonZeroRect

func (r Rect) ToNonZeroRect() (NonZeroRect, bool)

ToNonZeroRect is Rect::to_non_zero_rect in tiny-skia-path path/src/rect.rs. It converts the rectangle into a NonZeroRect.

func (Rect) Top

func (r Rect) Top() float32

Top is Rect::top in tiny-skia-path path/src/rect.rs. It returns the top edge.

func (Rect) Transform

func (r Rect) Transform(ts Transform) (Rect, bool)

Transform is Rect::transform in tiny-skia-path path/src/rect.rs. It transforms the rectangle with the given Transform.

If the transform is a skew, the result is a bounding box around the skewed rectangle.

func (Rect) Width

func (r Rect) Width() float32

Width is Rect::width in tiny-skia-path path/src/rect.rs. It returns the width of the rectangle.

func (Rect) X

func (r Rect) X() float32

X is Rect::x in tiny-skia-path path/src/rect.rs. It returns the X position of the rectangle.

func (Rect) Y

func (r Rect) Y() float32

Y is Rect::y in tiny-skia-path path/src/rect.rs. It returns the Y position of the rectangle.

type Size

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

Size is Size in tiny-skia-path path/src/size.rs. It is a size.

The width and the height are guaranteed to be positive, not zero and finite.

func SizeFromWH

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

SizeFromWH is Size::from_wh in tiny-skia-path path/src/size.rs. It creates a new Size from a width and a height.

func (Size) ExpandTo

func (s Size) ExpandTo(to Size) Size

ExpandTo is Size::expand_to in tiny-skia-path path/src/size.rs. It expands the size to the given size.

func (Size) Height

func (s Size) Height() float32

Height is Size::height in tiny-skia-path path/src/size.rs. It returns the height.

func (Size) ScaleBy

func (s Size) ScaleBy(factor float32) (Size, bool)

ScaleBy is Size::scale_by in tiny-skia-path path/src/size.rs. It scales the size by the given factor.

func (Size) ScaleTo

func (s Size) ScaleTo(to Size) Size

ScaleTo is Size::scale_to in tiny-skia-path path/src/size.rs. It scales the size to the given size.

func (Size) ScaleToHeight

func (s Size) ScaleToHeight(newHeight float32) (Size, bool)

ScaleToHeight is Size::scale_to_height in tiny-skia-path path/src/size.rs. It scales the size to the given height.

func (Size) ScaleToWidth

func (s Size) ScaleToWidth(newWidth float32) (Size, bool)

ScaleToWidth is Size::scale_to_width in tiny-skia-path path/src/size.rs. It scales the size to the given width.

func (Size) ToIntSize

func (s Size) ToIntSize() IntSize

ToIntSize is Size::to_int_size in tiny-skia-path path/src/size.rs. It converts the size into an IntSize.

func (Size) ToNonZeroRect

func (s Size) ToNonZeroRect(x, y float32) NonZeroRect

ToNonZeroRect is Size::to_non_zero_rect in tiny-skia-path path/src/size.rs. It converts the size into a NonZeroRect at the given position.

func (Size) ToRect

func (s Size) ToRect(x, y float32) (Rect, bool)

ToRect is Size::to_rect in tiny-skia-path path/src/size.rs. It converts the size into a Rect at the given position.

func (Size) Width

func (s Size) Width() float32

Width is Size::width in tiny-skia-path path/src/size.rs. It returns the width.

type Stroke

type Stroke struct {
	// Width is the thickness of the stroke.
	//
	// It must be >= 0.
	//
	// When it is 0, the stroke is a hairline.
	//
	// Default: 1.0
	Width float32

	// MiterLimit is the limit at which a sharp corner is drawn beveled.
	//
	// Default: 4.0
	MiterLimit float32

	// LineCap is the line cap of the stroke.
	//
	// Default: Butt
	LineCap LineCap

	// LineJoin is the line join of the stroke.
	//
	// Default: Miter
	LineJoin LineJoin

	// Dash holds the properties of the stroke dash. Nil is the Rust None.
	//
	// Default: None
	Dash *StrokeDash
}

Stroke is Stroke in tiny-skia-path path/src/stroker.rs. It holds the properties of a stroke.

func DefaultStroke

func DefaultStroke() Stroke

DefaultStroke is the Default impl of Stroke in tiny-skia-path path/src/stroker.rs.

type StrokeDash

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

StrokeDash is StrokeDash in tiny-skia-path path/src/dash.rs. It holds the properties of a stroke dash.

It holds an array of pairs: the first number of a pair is an "on" interval, and the second one is an "off" interval. It also holds a dash offset and internal properties.

The type guarantees these facts:

  • The dash array always has an even number of values.
  • All values of the dash array are finite and >= 0.
  • The dash array has at least two values.
  • The sum of all values of the dash array is positive and finite.
  • The dash offset is finite.

func NewStrokeDash

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

NewStrokeDash is StrokeDash::new in tiny-skia-path path/src/dash.rs. It creates a new stroke dash.

Port: Rust takes ownership of the dash array. Go keeps dashArray, so do not change it after the call.

func (*StrokeDash) Array added in v0.18.0

func (d *StrokeDash) Array() []float32

Array returns the dash array of the dash. It is the slice that NewStrokeDash took, so do not change it. A writer of PDF or SVG writes the dashes of a stroke with it. It is not in tiny-skia (D69).

func (*StrokeDash) Offset added in v0.18.0

func (d *StrokeDash) Offset() float32

Offset returns the dash offset of the dash. NewStrokeDash moves the offset that it takes into the range from 0 to the sum of the dash array, so the value can differ from that offset. It gives the same dashes. It is not in tiny-skia (D69).

type Transform

type Transform struct {
	SX float32
	KX float32
	KY float32
	SY float32
	TX float32
	TY float32
}

Transform is Transform in tiny-skia-path path/src/transform.rs. It is an affine transformation matrix.

Unlike other types, a Transform is not guaranteed to be valid. This is a quirk of Skia. So Transform(0, 0, 0, 0, 0, 0) is allowed, though it is not valid. Values that are not finite are also not an error.

func DefaultTransform

func DefaultTransform() Transform

DefaultTransform is the Default impl of Transform in tiny-skia-path path/src/transform.rs. It returns the identity transform.

func IdentityTransform

func IdentityTransform() Transform

IdentityTransform is Transform::identity in tiny-skia-path path/src/transform.rs. It creates an identity transform.

func TransformFromBBox

func TransformFromBBox(bbox NonZeroRect) Transform

TransformFromBBox is Transform::from_bbox in tiny-skia-path path/src/transform.rs. It converts a rectangle into a bounding box Transform.

func TransformFromRotate

func TransformFromRotate(angle float32) Transform

TransformFromRotate is Transform::from_rotate in tiny-skia-path path/src/transform.rs. It creates a new rotating Transform.

The angle is in degrees.

func TransformFromRotateAt

func TransformFromRotateAt(angle, tx, ty float32) Transform

TransformFromRotateAt is Transform::from_rotate_at in tiny-skia-path path/src/transform.rs. It creates a new rotating Transform at the given position.

The angle is in degrees.

func TransformFromRow

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

TransformFromRow is Transform::from_row in tiny-skia-path path/src/transform.rs. It creates a new Transform.

We are using column-major-column-vector matrix notation, therefore it's ky-kx, not kx-ky.

func TransformFromScale

func TransformFromScale(sx, sy float32) Transform

TransformFromScale is Transform::from_scale in tiny-skia-path path/src/transform.rs. It creates a new scaling Transform.

func TransformFromSkew

func TransformFromSkew(kx, ky float32) Transform

TransformFromSkew is Transform::from_skew in tiny-skia-path path/src/transform.rs. It creates a new skewing Transform.

func TransformFromTranslate

func TransformFromTranslate(tx, ty float32) Transform

TransformFromTranslate is Transform::from_translate in tiny-skia-path path/src/transform.rs. It creates a new translating Transform.

func (Transform) GetScale

func (ts Transform) GetScale() (float32, float32)

GetScale is Transform::get_scale in tiny-skia-path path/src/transform.rs. It returns the scale part of the transform.

func (Transform) HasScale

func (ts Transform) HasScale() bool

HasScale is Transform::has_scale in tiny-skia-path path/src/transform.rs. It checks that the transform holds a scale part.

func (Transform) HasSkew

func (ts Transform) HasSkew() bool

HasSkew is Transform::has_skew in tiny-skia-path path/src/transform.rs. It checks that the transform holds a skew part.

func (Transform) HasTranslate

func (ts Transform) HasTranslate() bool

HasTranslate is Transform::has_translate in tiny-skia-path path/src/transform.rs. It checks that the transform holds a translate part.

func (Transform) Invert

func (ts Transform) Invert() (Transform, bool)

Invert is Transform::invert in tiny-skia-path path/src/transform.rs. It returns the inverted transform.

func (Transform) IsFinite

func (ts Transform) IsFinite() bool

IsFinite is Transform::is_finite in tiny-skia-path path/src/transform.rs. It checks that the transform is finite.

func (Transform) IsIdentity

func (ts Transform) IsIdentity() bool

IsIdentity is Transform::is_identity in tiny-skia-path path/src/transform.rs. It checks that the transform is the identity.

func (Transform) IsScale

func (ts Transform) IsScale() bool

IsScale is Transform::is_scale in tiny-skia-path path/src/transform.rs. It checks that the transform only scales.

func (Transform) IsScaleTranslate

func (ts Transform) IsScaleTranslate() bool

IsScaleTranslate is Transform::is_scale_translate in tiny-skia-path path/src/transform.rs. It checks that the transform holds only a scale and a translation.

func (Transform) IsSkew

func (ts Transform) IsSkew() bool

IsSkew is Transform::is_skew in tiny-skia-path path/src/transform.rs. It checks that the transform only skews.

func (Transform) IsTranslate

func (ts Transform) IsTranslate() bool

IsTranslate is Transform::is_translate in tiny-skia-path path/src/transform.rs. It checks that the transform only translates.

func (Transform) IsValid

func (ts Transform) IsValid() bool

IsValid is Transform::is_valid in tiny-skia-path path/src/transform.rs. It checks that the transform is finite and has a scale that is not zero.

func (Transform) MapPoint

func (ts Transform) MapPoint(point *Point)

MapPoint is Transform::map_point in tiny-skia-path path/src/transform.rs. It transforms a point with the transform.

func (Transform) MapPoints

func (ts Transform) MapPoints(points []Point)

MapPoints is Transform::map_points in tiny-skia-path path/src/transform.rs. It transforms a slice of points with the transform.

func (Transform) PostConcat

func (ts Transform) PostConcat(other Transform) Transform

PostConcat is Transform::post_concat in tiny-skia-path path/src/transform.rs. It post-concatenates the transform.

func (Transform) PostRotate

func (ts Transform) PostRotate(angle float32) Transform

PostRotate is Transform::post_rotate in tiny-skia-path path/src/transform.rs. It post-rotates the transform.

The angle is in degrees.

func (Transform) PostRotateAt

func (ts Transform) PostRotateAt(angle, tx, ty float32) Transform

PostRotateAt is Transform::post_rotate_at in tiny-skia-path path/src/transform.rs. It post-rotates the transform around the given position.

The angle is in degrees.

func (Transform) PostScale

func (ts Transform) PostScale(sx, sy float32) Transform

PostScale is Transform::post_scale in tiny-skia-path path/src/transform.rs. It post-scales the transform.

func (Transform) PostTranslate

func (ts Transform) PostTranslate(tx, ty float32) Transform

PostTranslate is Transform::post_translate in tiny-skia-path path/src/transform.rs. It post-translates the transform.

func (Transform) PreConcat

func (ts Transform) PreConcat(other Transform) Transform

PreConcat is Transform::pre_concat in tiny-skia-path path/src/transform.rs. It pre-concatenates the transform.

func (Transform) PreRotate

func (ts Transform) PreRotate(angle float32) Transform

PreRotate is Transform::pre_rotate in tiny-skia-path path/src/transform.rs. It pre-rotates the transform.

The angle is in degrees.

func (Transform) PreRotateAt

func (ts Transform) PreRotateAt(angle, tx, ty float32) Transform

PreRotateAt is Transform::pre_rotate_at in tiny-skia-path path/src/transform.rs. It pre-rotates the transform around the given position.

The angle is in degrees.

func (Transform) PreScale

func (ts Transform) PreScale(sx, sy float32) Transform

PreScale is Transform::pre_scale in tiny-skia-path path/src/transform.rs. It pre-scales the transform.

func (Transform) PreTranslate

func (ts Transform) PreTranslate(tx, ty float32) Transform

PreTranslate is Transform::pre_translate in tiny-skia-path path/src/transform.rs. It pre-translates the transform.

Jump to

Keyboard shortcuts

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