clip

package
Version: v0.0.0-...-e5d8a4b Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: MIT, Unlicense Imports: 9 Imported by: 124

Documentation

Overview

Package clip provides operations for clipping paint operations. Drawing outside the current clip area is ignored.

The current clip is initially the infinite set. Pushing and Op sets the clip to the intersection of the current clip and pushed clip area. Popping the area restores the clip to its state before pushing.

General clipping areas are constructed with Path. Common cases such as rectangular clip areas also exist as convenient constructors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Circle

type Circle struct {
	Center f32.Point
	Radius float32
}

Circle represents the clip area of a circle.

func (Circle) Add deprecated

This method has been deprecated.
func (c Circle) Add(ops *op.Ops)

Add the circle clip to the clip state.

Deprecated: use Push instead.

func (Circle) Op

func (c Circle) Op(ops *op.Ops) Op

Op returns the op for the circle.

func (Circle) Path

func (c Circle) Path(ops *op.Ops) PathSpec

Path returns the PathSpec for the circle.

func (Circle) Push

func (c Circle) Push(ops *op.Ops) Stack

Push the circle clip on the clip stack.

type Op

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

Op represents a clip area. Op intersects the current clip area with itself.

func (Op) Add deprecated

This method has been deprecated.
func (p Op) Add(o *op.Ops)

Add is like Push except it doesn't save the current state on the stack.

Deprecated: use Push instead.

func (Op) Push

func (p Op) Push(o *op.Ops) Stack

Push saves the current clip state on the stack and updates the current state to the intersection of the current p.

type Outline

type Outline struct {
	Path PathSpec
}

Outline represents the area inside of a path, according to the non-zero winding rule.

func (Outline) Op

func (o Outline) Op() Op

Op returns a clip operation representing the outline.

type Path

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

Path constructs a Op clip path described by lines and Bézier curves, where drawing outside the Path is discarded. The inside-ness of a pixel is determines by the non-zero winding rule, similar to the SVG rule of the same name.

Path generates no garbage and can be used for dynamic paths; path data is stored directly in the Ops list supplied to Begin.

func (*Path) Arc

func (p *Path) Arc(f1, f2 f32.Point, angle float32)

Arc is like ArcTo where f1 and f2 are relative to the current position.

func (*Path) ArcTo

func (p *Path) ArcTo(f1, f2 f32.Point, angle float32)

ArcTo adds an elliptical arc to the path. The implied ellipse is defined by its focus points f1 and f2. The arc starts in the current point and ends angle radians along the ellipse boundary. The sign of angle determines the direction; positive being counter-clockwise, negative clockwise.

func (*Path) Begin

func (p *Path) Begin(o *op.Ops)

Begin the path, storing the path data and final Op into ops.

func (*Path) Close

func (p *Path) Close()

Close closes the path contour.

func (*Path) Cube

func (p *Path) Cube(ctrl0, ctrl1, to f32.Point)

Cube records a cubic Bézier from the pen through two control points ending in to.

func (*Path) CubeTo

func (p *Path) CubeTo(ctrl0, ctrl1, to f32.Point)

CubeTo records a cubic Bézier from the pen through two control points ending in to, with absolute coordinates.

func (*Path) End

func (p *Path) End() PathSpec

End returns a PathSpec ready to use in clipping operations.

func (*Path) Line

func (p *Path) Line(delta f32.Point)

Line moves the pen by the amount specified by delta, recording a line.

func (*Path) LineTo

func (p *Path) LineTo(to f32.Point)

LineTo moves the pen to the absolute point specified, recording a line.

func (*Path) Move

func (p *Path) Move(delta f32.Point)

Move moves the pen by the amount specified by delta.

func (*Path) MoveTo

func (p *Path) MoveTo(to f32.Point)

MoveTo moves the pen to the specified absolute coordinate.

func (*Path) Pos

func (p *Path) Pos() f32.Point

Pos returns the current pen position.

func (*Path) Quad

func (p *Path) Quad(ctrl, to f32.Point)

Quad records a quadratic Bézier from the pen to end with the control point ctrl.

func (*Path) QuadTo

func (p *Path) QuadTo(ctrl, to f32.Point)

QuadTo records a quadratic Bézier from the pen to end with the control point ctrl, with absolute coordinates.

type PathSpec

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

type RRect

type RRect struct {
	Rect f32.Rectangle
	// The corner radii.
	SE, SW, NW, NE float32
}

RRect represents the clip area of a rectangle with rounded corners.

Specify a square with corner radii equal to half the square size to construct a circular clip area.

func UniformRRect

func UniformRRect(rect f32.Rectangle, radius float32) RRect

UniformRRect returns an RRect with all corner radii set to the provided radius.

func (RRect) Add deprecated

This method has been deprecated.
func (rr RRect) Add(ops *op.Ops)

Add the rectangle clip to the clip state.

Deprecated: use Push instead.

func (RRect) Op

func (rr RRect) Op(ops *op.Ops) Op

Op returns the op for the rounded rectangle.

func (RRect) Path

func (rr RRect) Path(ops *op.Ops) PathSpec

Path returns the PathSpec for the rounded rectangle.

func (RRect) Push

func (rr RRect) Push(ops *op.Ops) Stack

Push the rectangle clip on the clip stack.

type Rect

type Rect image.Rectangle

Rect represents the clip area of a pixel-aligned rectangle.

func (Rect) Add deprecated

This method has been deprecated.
func (r Rect) Add(ops *op.Ops)

Add the rectangle clip to the clip state.

Deprecated: use Push instead.

func (Rect) Op

func (r Rect) Op() Op

Op returns the op for the rectangle.

func (Rect) Push

func (r Rect) Push(ops *op.Ops) Stack

Push the clip operation on the clip stack.

type Stack

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

Stack represents an Op pushed on the clip stack.

func (Stack) Pop

func (s Stack) Pop()

type Stroke

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

Stroke represents a stroked path.

func (Stroke) Op

func (s Stroke) Op() Op

Op returns a clip operation representing the stroke.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL