package clip
import "gioui.org/op/clip"
Package clip provides operations for defining areas that applies to operations such as paints and pointer handlers.
The current clip is initially the infinite set. Pushing an 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 ¶
- type Ellipse
- func (e Ellipse) Op(ops *op.Ops) Op
- func (e Ellipse) Path(o *op.Ops) PathSpec
- func (e Ellipse) Push(ops *op.Ops) Stack
- type Op
- type Outline
- type Path
- func (p *Path) Arc(f1, f2 f32.Point, angle float32)
- func (p *Path) ArcTo(f1, f2 f32.Point, angle float32)
- func (p *Path) Begin(o *op.Ops)
- func (p *Path) Close()
- func (p *Path) Cube(ctrl0, ctrl1, to f32.Point)
- func (p *Path) CubeTo(ctrl0, ctrl1, to f32.Point)
- func (p *Path) End() PathSpec
- func (p *Path) Line(delta f32.Point)
- func (p *Path) LineTo(to f32.Point)
- func (p *Path) Move(delta f32.Point)
- func (p *Path) MoveTo(to f32.Point)
- func (p *Path) Pos() f32.Point
- func (p *Path) Quad(ctrl, to f32.Point)
- func (p *Path) QuadTo(ctrl, to f32.Point)
- type PathSpec
- type RRect
- func UniformRRect(rect image.Rectangle, radius int) RRect
- func (rr RRect) Op(ops *op.Ops) Op
- func (rr RRect) Path(ops *op.Ops) PathSpec
- func (rr RRect) Push(ops *op.Ops) Stack
- type Rect
- type Stack
- type Stroke
Types ¶
type Ellipse ¶
Ellipse represents the largest axis-aligned ellipse that is contained in its bounds.
func (Ellipse) Op ¶
Op returns the op for the filled ellipse.
func (Ellipse) Path ¶
Path constructs a path for the ellipse.
func (Ellipse) Push ¶
Push the filled ellipse clip op 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) Push ¶
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 ¶
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 ¶
Arc is like ArcTo where f1 and f2 are relative to the current position.
func (*Path) ArcTo ¶
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 ¶
Begin the path, storing the path data and final Op into ops.
Caller must also call End to finish the drawing. Forgetting to call it will result in a "panic: cannot mix multi ops with single ones".
func (*Path) Close ¶
func (p *Path) Close()
Close closes the path contour.
func (*Path) Cube ¶
Cube records a cubic Bézier from the pen through two control points ending in to.
func (*Path) CubeTo ¶
CubeTo records a cubic Bézier from the pen through two control points ending in to, with absolute coordinates.
func (*Path) End ¶
End returns a PathSpec ready to use in clipping operations.
func (*Path) Line ¶
Line moves the pen by the amount specified by delta, recording a line.
func (*Path) LineTo ¶
LineTo moves the pen to the absolute point specified, recording a line.
func (*Path) Move ¶
Move moves the pen by the amount specified by delta.
func (*Path) MoveTo ¶
MoveTo moves the pen to the specified absolute coordinate.
func (*Path) Pos ¶
Pos returns the current pen position.
func (*Path) Quad ¶
Quad records a quadratic Bézier from the pen to end with the control point ctrl.
func (*Path) QuadTo ¶
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 ¶
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 ¶
UniformRRect returns an RRect with all corner radii set to the provided radius.
func (RRect) Op ¶
Op returns the op for the rounded rectangle.
func (RRect) Path ¶
Path returns the PathSpec for the rounded rectangle.
func (RRect) Push ¶
Push the rectangle clip on the clip stack.
type Rect ¶
Rect represents the clip area of a pixel-aligned rectangle.
func (Rect) Op ¶
Op returns the op for the rectangle.
func (Rect) Path ¶
Path returns the PathSpec for the rectangle.
func (Rect) Push ¶
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 ¶
Stroke represents a stroked path.
func (Stroke) Op ¶
Op returns a clip operation representing the stroke.
Source Files ¶
clip.go doc.go shapes.go
- Version
- v0.8.0 (latest)
- Published
- Jan 14, 2025
- Platform
- linux/amd64
- Imports
- 10 packages
- Last checked
- 9 hours ago –
Tools for package owners.