package paint
import "gioui.org/op/paint"
Package paint provides drawing operations for 2D graphics.
The PaintOp operation fills the current clip with the current brush, taking the current transformation into account. Drawing outside the current clip area is ignored.
The current brush is set by either a ColorOp for a constant color, or ImageOp for an image, or LinearGradientOp for gradients.
All color.NRGBA values are in the sRGB color space.
Index ¶
- func Fill(ops *op.Ops, c color.NRGBA)
- func FillShape(ops *op.Ops, c color.NRGBA, shape clip.Op)
- type ColorOp
- type ImageFilter
- type ImageOp
- func NewImageOp(src image.Image) ImageOp
- func (i ImageOp) Add(o *op.Ops)
- func (i ImageOp) Size() image.Point
- type LinearGradientOp
- type OpacityStack
- type PaintOp
Functions ¶
func Fill ¶
Fill paints an infinitely large plane with the provided color. It is intended to be used with a clip.Op already in place to limit the painted area. Use FillShape unless you need to paint several times within the same clip.Op.
func FillShape ¶
FillShape fills the clip shape with a color.
Types ¶
type ColorOp ¶
ColorOp sets the brush to a constant color.
func (ColorOp) Add ¶
type ImageFilter ¶
type ImageFilter byte
ImageFilter is the scaling filter for images.
const ( // FilterLinear uses linear interpolation for scaling. FilterLinear ImageFilter = iota // FilterNearest uses nearest neighbor interpolation for scaling. FilterNearest )
type ImageOp ¶
type ImageOp struct { Filter ImageFilter // contains filtered or unexported fields }
ImageOp sets the brush to an image.
func NewImageOp ¶
NewImageOp creates an ImageOp backed by src.
NewImageOp assumes the backing image is immutable, and may cache a copy of its contents in a GPU-friendly way. Create new ImageOps to ensure that changes to an image is reflected in the display of it.
func (ImageOp) Add ¶
func (ImageOp) Size ¶
type LinearGradientOp ¶
type LinearGradientOp struct { Stop1 f32.Point Color1 color.NRGBA Stop2 f32.Point Color2 color.NRGBA }
LinearGradientOp sets the brush to a gradient starting at stop1 with color1 and ending at stop2 with color2.
func (LinearGradientOp) Add ¶
func (c LinearGradientOp) Add(o *op.Ops)
type OpacityStack ¶
type OpacityStack struct {
// contains filtered or unexported fields
}
OpacityStack represents an opacity applied to all painting operations until Pop is called.
func PushOpacity ¶
func PushOpacity(o *op.Ops, opacity float32) OpacityStack
PushOpacity creates a drawing layer with an opacity in the range [0;1]. The layer includes every subsequent drawing operation until OpacityStack.Pop is called.
The layer is drawn in two steps. First, the layer operations are drawn to a separate image. Then, the image is blended on top of the frame, with the opacity used as the blending factor.
func (OpacityStack) Pop ¶
func (t OpacityStack) Pop()
type PaintOp ¶
type PaintOp struct { }
PaintOp fills the current clip area with the current brush.
func (PaintOp) Add ¶
Source Files ¶
doc.go paint.go
- Version
- v0.8.0 (latest)
- Published
- Jan 14, 2025
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 9 hours ago –
Tools for package owners.