stroke

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT, Unlicense Imports: 5 Imported by: 2

Documentation

Overview

Package stroke converts complex strokes to gioui.org/op/clip operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dashes

type Dashes struct {
	Phase  float32
	Dashes []float32
}

Dashes defines the dash pattern of a Stroke.

type Path

type Path struct {
	Segments []Segment
}

Path defines the shape of a Stroke.

type Segment

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

func ArcTo

func ArcTo(center f32.Point, angle float32) Segment

func CubeTo

func CubeTo(ctrl0, ctrl1, end f32.Point) Segment

func LineTo

func LineTo(p f32.Point) Segment

func MoveTo

func MoveTo(p f32.Point) Segment

func QuadTo

func QuadTo(ctrl, end f32.Point) Segment

type Stroke

type Stroke struct {
	Path  Path
	Width float32 // Width of the stroked path.

	// Miter is the limit to apply to a miter joint.
	Miter float32
	Cap   StrokeCap  // Cap describes the head or tail of a stroked path.
	Join  StrokeJoin // Join describes how stroked paths are collated.

	Dashes Dashes
}

Stroke defines a stroke.

func (Stroke) Op

func (s Stroke) Op(ops *op.Ops) clip.Op

Op returns a clip operation that approximates stroke.

type StrokeCap

type StrokeCap uint8

StrokeCap describes the head or tail of a stroked path.

const (
	// RoundCap caps stroked paths with a round cap, joining the right-hand and
	// left-hand sides of a stroked path with a half disc of diameter the
	// stroked path's width.
	RoundCap StrokeCap = iota

	// FlatCap caps stroked paths with a flat cap, joining the right-hand
	// and left-hand sides of a stroked path with a straight line.
	FlatCap

	// SquareCap caps stroked paths with a square cap, joining the right-hand
	// and left-hand sides of a stroked path with a half square of length
	// the stroked path's width.
	SquareCap

	// TriangularCap caps stroked paths with a triangular cap, joining the
	// right-hand and left-hand sides of a stroked path with a triangle
	// with height half of the stroked path's width.
	TriangularCap
)

type StrokeJoin

type StrokeJoin uint8

StrokeJoin describes how stroked paths are collated.

const (
	// RoundJoin joins path segments with a round segment.
	RoundJoin StrokeJoin = iota

	// BevelJoin joins path segments with sharp bevels.
	BevelJoin

	// MiterJoin joins path segments with a sharp corner.
	// It falls back to a bevel join if the miter limit is exceeded.
	MiterJoin
)

Jump to

Keyboard shortcuts

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