gioui.org: gioui.org/op/clip Index | Files

package clip

import "gioui.org/op/clip"

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.

Index

Package Files

clip.go doc.go shapes.go stroke.go

type Border Uses

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

Border represents the clip area of a rectangular border.

func (Border) Add Uses

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

Add the border clip.

func (Border) Op Uses

func (b Border) Op(ops *op.Ops) Op

Op returns the Op for the border.

type Op Uses

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 Uses

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

type Path Uses

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) Arc Uses

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

Arc 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 Uses

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

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

func (*Path) Cube Uses

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) Line Uses

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

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

func (*Path) LineTo Uses

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

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

func (*Path) Move Uses

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

Move moves the pen by the amount specified by delta.

func (*Path) MoveTo Uses

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

MoveTo moves the pen to the specified absolute coordinate.

func (*Path) Outline Uses

func (p *Path) Outline() Op

Outline closes the path and returns a clip operation that represents it.

func (*Path) Pos Uses

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

Pos returns the current pen position.

func (*Path) Quad Uses

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 Uses

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.

func (*Path) Stroke Uses

func (p *Path) Stroke(width float32, sty StrokeStyle) Op

Stroke returns a stroked path with the specified width and configuration. If the provided width is <= 0, the path won't be stroked.

type RRect Uses

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 Uses

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

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

func (RRect) Add Uses

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

Add the rectangle clip.

func (RRect) Op Uses

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

Op returns the op for the rounded rectangle.

type Rect Uses

type Rect image.Rectangle

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

func (Rect) Add Uses

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

Add the clip operation.

func (Rect) Op Uses

func (r Rect) Op() Op

Op returns the op for the rectangle.

type StrokeCap Uses

type StrokeCap uint8

StrokeCap describes the head or tail of a stroked path.

const (
    // 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 StrokeCap = iota

    // 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

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

type StrokeJoin Uses

type StrokeJoin uint8

StrokeJoin describes how stroked paths are collated.

const (
    // BevelJoin joins path segments with sharp bevels.
    BevelJoin StrokeJoin = iota

    // RoundJoin joins path segments with a round segment.
    RoundJoin
)

type StrokeStyle Uses

type StrokeStyle struct {
    Cap  StrokeCap
    Join StrokeJoin

    // Miter is the limit to apply to a miter joint.
    // The zero Miter disables the miter joint; setting Miter to +∞
    // unconditionally enables the miter joint.
    Miter float32
}

StrokeStyle describes how a stroked path should be drawn. The zero value of StrokeStyle represents bevel-joined and flat-capped strokes.

Package clip imports 7 packages (graph) and is imported by 35 packages. Updated 2020-11-29. Refresh now. Tools for package owners.