vector

package
v2.7.0-alpha.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2024 License: Apache-2.0 Imports: 4 Imported by: 400

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrawFilledCircle added in v2.5.0

func DrawFilledCircle(dst *ebiten.Image, cx, cy, r float32, clr color.Color, antialias bool)

DrawFilledCircle fills a circle with the specified center position (cx, cy), the radius (r), width and color.

func DrawFilledRect added in v2.5.0

func DrawFilledRect(dst *ebiten.Image, x, y, width, height float32, clr color.Color, antialias bool)

DrawFilledRect fills a rectangle with the specified width and color.

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.

clr has be to be a solid (non-transparent) 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.

clr has be to be a solid (non-transparent) color.

func StrokeRect added in v2.5.0

func StrokeRect(dst *ebiten.Image, x, y, width, height float32, strokeWidth float32, clr color.Color, antialias bool)

StrokeRect strokes a rectangle with the specified width and color.

clr has be to be a solid (non-transparent) color.

Types

type Direction added in v2.2.0

type Direction int

Direction represents clockwise or counterclockwise.

const (
	Clockwise Direction = iota
	CounterClockwise
)

type LineCap added in v2.5.0

type LineCap int

LineCap represents the way in which how the ends of the stroke are rendered.

const (
	LineCapButt LineCap = iota
	LineCapRound
	LineCapSquare
)

type LineJoin added in v2.5.0

type LineJoin int

LineJoin represents the way in which how two segments are joined.

const (
	LineJoinMiter LineJoin = iota
	LineJoinBevel
	LineJoinRound
)

type Path

type Path struct {
	// contains filtered or unexported fields
}

Path represents a collection of path subpathments.

func (*Path) AppendVerticesAndIndicesForFilling 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 the fill rule NonZero or EvenOdd 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.

func (*Path) AppendVerticesAndIndicesForStroke 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 the FillAll fill rule (not NonZero or EvenOdd fill rule).

func (*Path) Arc added in v2.2.0

func (p *Path) Arc(x, y, radius, startAngle, endAngle float32, dir Direction)

Arc adds an arc to the path. (x, y) is the center of the arc.

func (*Path) ArcTo added in v2.2.0

func (p *Path) ArcTo(x1, y1, x2, y2, radius float32)

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 subpath to the first position of the current subpath, and marks the current subpath closed. Following operations for this path will start with a new subpath.

func (*Path) CubicTo

func (p *Path) CubicTo(x1, y1, x2, y2, x3, y3 float32)

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

func (p *Path) LineTo(x, y float32)

LineTo adds a line segment to the path, which starts from the last position of the current subpath and ends to the given position (x, y). If p doesn't have any subpaths or the last subpath is closed, LineTo sets (x, y) as the start position of a new subpath.

func (*Path) MoveTo

func (p *Path) MoveTo(x, y float32)

MoveTo starts a new subpath with the given position (x, y) without adding a subpath,

func (*Path) QuadTo

func (p *Path) QuadTo(x1, y1, x2, y2 float32)

QuadTo adds a quadratic Bézier curve to the path. (x1, y1) is the control point, and (x2, y2) is the destination.

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 subpath 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 LineJoiMiter.
	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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL