Documentation
¶
Overview ¶
Package vector provides functions for vector graphics rendering.
This package is under experiments and the API might be changed with breaking backward compatibility.
Index ¶
- func DrawFilledCircle(dst *ebiten.Image, cx, cy, r float32, clr color.Color, antialias bool)deprecated
- func DrawFilledRect(dst *ebiten.Image, x, y, width, height float32, clr color.Color, ...)deprecated
- func FillCircle(dst *ebiten.Image, cx, cy, r float32, clr color.Color, antialias bool)
- func FillPath(dst *ebiten.Image, path *Path, fillOptions *FillOptions, ...)
- func FillRect(dst *ebiten.Image, x, y, width, height float32, clr color.Color, ...)
- func StrokeCircle(dst *ebiten.Image, cx, cy, r float32, strokeWidth float32, clr color.Color, ...)
- func StrokeLine(dst *ebiten.Image, x0, y0, x1, y1 float32, strokeWidth float32, ...)
- func StrokePath(dst *ebiten.Image, path *Path, strokeOptions *StrokeOptions, ...)
- func StrokeRect(dst *ebiten.Image, x, y, width, height float32, strokeWidth float32, ...)
- type AddPathOptions
- type AddStrokeOptions
- type Direction
- type DrawPathOptions
- type FillOptions
- type FillRule
- type LineCap
- type LineJoin
- type Path
- func (p *Path) AddPath(src *Path, options *AddPathOptions)
- func (p *Path) AddStroke(src *Path, options *AddStrokeOptions)
- func (p *Path) AppendVerticesAndIndicesForFilling(vertices []ebiten.Vertex, indices []uint16) ([]ebiten.Vertex, []uint16)deprecated
- func (p *Path) AppendVerticesAndIndicesForStroke(vertices []ebiten.Vertex, indices []uint16, op *StrokeOptions) ([]ebiten.Vertex, []uint16)deprecated
- func (p *Path) Arc(x, y, radius, startAngle, endAngle float32, dir Direction)
- func (p *Path) ArcTo(x1, y1, x2, y2, radius float32)
- func (p *Path) Bounds() image.Rectangle
- func (p *Path) Close()
- func (p *Path) CubicTo(x1, y1, x2, y2, x3, y3 float32)
- func (p *Path) LineTo(x, y float32)
- func (p *Path) MoveTo(x, y float32)
- func (p *Path) QuadTo(x1, y1, x2, y2 float32)
- func (p *Path) Reset()
- type StrokeOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DrawFilledCircle
deprecated
added in
v2.5.0
func FillCircle ¶ added in v2.9.0
FillCircle fills a circle with the specified center position (cx, cy), the radius (r), width and color.
func FillPath ¶ added in v2.9.0
func FillPath(dst *ebiten.Image, path *Path, fillOptions *FillOptions, drawPathOptions *DrawPathOptions)
FillPath fills the specified path with the specified options.
func StrokeCircle ¶ added in v2.5.0
func StrokeCircle(dst *ebiten.Image, cx, cy, r float32, strokeWidth float32, clr color.Color, antialias bool)
StrokeCircle strokes a circle with the specified center position (cx, cy), the radius (r), width and color.
func StrokeLine ¶ added in v2.5.0
func StrokeLine(dst *ebiten.Image, x0, y0, x1, y1 float32, strokeWidth float32, clr color.Color, antialias bool)
StrokeLine strokes a line (x0, y0)-(x1, y1) with the specified width and color.
func StrokePath ¶ added in v2.9.0
func StrokePath(dst *ebiten.Image, path *Path, strokeOptions *StrokeOptions, drawPathOptions *DrawPathOptions)
StrokePath strokes the specified path with the specified options.
Types ¶
type AddPathOptions ¶ added in v2.9.0
type AddPathOptions struct {
// GeoM is a geometry matrix to apply to the path.
//
// The default (zero) value is an identity matrix.
GeoM ebiten.GeoM
}
AddPathOptions is options for Path.AddPath.
type AddStrokeOptions ¶ added in v2.9.0
type AddStrokeOptions struct {
// StrokeOptions is options for the stroke.
StrokeOptions
// GeoM is a geometry matrix to apply to the path.
//
// The default (zero) value is an identity matrix.
GeoM ebiten.GeoM
}
AddStrokeOptions is options for Path.AddStroke.
type Direction ¶ added in v2.2.0
type Direction int
Direction represents clockwise or counterclockwise.
type DrawPathOptions ¶ added in v2.9.0
type DrawPathOptions struct {
// AntiAlias is whether the path is drawn with anti-aliasing.
// The default (zero) value is false.
AntiAlias bool
// ColorScale is the color scale to apply to the path.
// The default (zero) value is identity, which is (1, 1, 1, 1) (white).
ColorScale ebiten.ColorScale
// Blend is the blend mode to apply to the path.
// The default (zero) value is ebiten.BlendSourceOver.
Blend ebiten.Blend
}
DrawPathOptions is options to draw a path.
type FillOptions ¶
type FillOptions struct {
// FillRule is the rule whether an overlapped region is rendered or not.
// The default (zero) value is FillRuleNonZero.
FillRule FillRule
}
FillOptions is options to fill a path.
type FillRule ¶ added in v2.9.0
type FillRule int
FillRule is the rule whether an overlapped region is rendered or not.
const ( // FillRuleNonZero means that triangles are rendered based on the non-zero rule. // If and only if the number of overlaps is not 0, the region is rendered. FillRuleNonZero FillRule = iota // FillRuleEvenOdd means that triangles are rendered based on the even-odd rule. // If and only if the number of overlaps is odd, the region is rendered. FillRuleEvenOdd )
type LineCap ¶ added in v2.5.0
type LineCap int
LineCap represents the way in which how the ends of the stroke are rendered.
type LineJoin ¶ added in v2.5.0
type LineJoin int
LineJoin represents the way in which how two segments are joined.
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path represents a collection of vector graphics operations.
func (*Path) AddPath ¶ added in v2.9.0
func (p *Path) AddPath(src *Path, options *AddPathOptions)
AddPath adds the given path src to this path p as a sub-path.
func (*Path) AddStroke ¶ added in v2.9.0
func (p *Path) AddStroke(src *Path, options *AddStrokeOptions)
AddStroke adds a stroke path to the path p.
The added stroke path must be rendered with FileRuleNonZero.
func (*Path) AppendVerticesAndIndicesForFilling
deprecated
added in
v2.2.0
func (p *Path) AppendVerticesAndIndicesForFilling(vertices []ebiten.Vertex, indices []uint16) ([]ebiten.Vertex, []uint16)
AppendVerticesAndIndicesForFilling appends vertices and indices to fill this path and returns them.
AppendVerticesAndIndicesForFilling works in a similar way to the built-in append function. If the arguments are nils, AppendVerticesAndIndicesForFilling returns new slices.
The returned vertice's SrcX and SrcY are 0, and ColorR, ColorG, ColorB, and ColorA are 1.
The returned values are intended to be passed to DrawTriangles or DrawTrianglesShader with FileRuleNonZero or FillRuleEvenOdd in order to render a complex polygon like a concave polygon, a polygon with holes, or a self-intersecting polygon.
The returned vertices and indices should be rendered with a solid (non-transparent) color with the default Blend (source-over). Otherwise, there is no guarantee about the rendering result.
Deprecated: as of v2.9. Use FillPath instead.
func (*Path) AppendVerticesAndIndicesForStroke
deprecated
added in
v2.5.0
func (p *Path) AppendVerticesAndIndicesForStroke(vertices []ebiten.Vertex, indices []uint16, op *StrokeOptions) ([]ebiten.Vertex, []uint16)
AppendVerticesAndIndicesForStroke appends vertices and indices to render a stroke of this path and returns them. AppendVerticesAndIndicesForStroke works in a similar way to the built-in append function. If the arguments are nils, AppendVerticesAndIndicesForStroke returns new slices.
The returned vertice's SrcX and SrcY are 0, and ColorR, ColorG, ColorB, and ColorA are 1.
The returned values are intended to be passed to DrawTriangles or DrawTrianglesShader with a solid (non-transparent) color with FillRuleFillAll or FillRuleNonZero, not FileRuleEvenOdd.
Deprecated: as of v2.9. Use StrokePath or Path.AddStroke instead.
func (*Path) ArcTo ¶ added in v2.2.0
ArcTo adds an arc curve to the path. (x1, y1) is the first control point, and (x2, y2) is the second control point.
func (*Path) Close ¶ added in v2.5.0
func (p *Path) Close()
Close adds a new line from the last position of the current sub-path to the first position of the current sub-path, and marks the current sub-path closed. Following operations for this path will start with a new sub-path.
func (*Path) CubicTo ¶
CubicTo adds a cubic Bézier curve to the path. (x1, y1) and (x2, y2) are the control points, and (x3, y3) is the destination.
func (*Path) LineTo ¶
LineTo adds a line segment to the path, which starts from the last position of the current sub-path and ends to the given position (x, y). If p doesn't have any sub-paths or the last sub-path is closed, LineTo sets (x, y) as the start position of a new sub-path.
func (*Path) MoveTo ¶
MoveTo starts a new sub-path with the given position (x, y) without adding a sub-path,
type StrokeOptions ¶ added in v2.5.0
type StrokeOptions struct {
// Width is the stroke width in pixels.
//
// The default (zero) value is 0.
Width float32
// LineCap is the way in which how the ends of the stroke are rendered.
// Line caps are not rendered when the sub-path is marked as closed.
//
// The default (zero) value is [LineCapButt].
LineCap LineCap
// LineJoin is the way in which how two segments are joined.
//
// The default (zero) value is [LineJoinMiter].
LineJoin LineJoin
// MiterLimit is the miter limit for [LineJoinMiter].
// For details, see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit.
//
// The default (zero) value is 0.
MiterLimit float32
}
StrokeOptions is options to render a stroke.