Back to / op / clip

Package clip

v0.0.0 (83673ec)
Latest Go to latest
Published: Jul 26, 2020 | Licenses: MIT , Unlicense | Module:


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

The current clip is initially the infinite set. An Op sets the clip to the intersection of the current clip and the clip area it represents. If you need to reset the current clip to its value before applying an Op, use op.StackOp.

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


Package Files

type Border

type Border struct {
	// Rect is the bounds of the border.
	Rect  f32.Rectangle
	Width float32
	// The corner radii.
	SE, SW, NW, NE float32

Border represents the clip area of a rectangular border.

func (Border) Add

func (rr Border) Add(ops *op.Ops)

Add the border clip.

type Op

type Op struct {
	// contains filtered or unexported fields

Op sets the current clip to the intersection of the existing clip with this clip.

If you need to reset the clip to its previous values after applying a Op, use op.StackOp.

func (Op) Add

func (p Op) Add(o *op.Ops)

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 even-odd 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) Begin

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

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

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) End

func (p *Path) End() Op

End the path and return a clip operation that represents it.

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) Move

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

MoveTo moves the pen to the given 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.

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 (RRect) Add

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

Add the rectangle clip.

type Rect

type Rect image.Rectangle

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

func (Rect) Add

func (r Rect) Add(ops *op.Ops)

Add the clip operation.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier