Class Path

A vector graphics path, usually lives inside a Graphics.

Tables

Path.id name of this path
Path.subpaths tove.List of Subpaths in this Path

Methods

Path:addSubpath (t) Add a Subpath.
Path:animate (a, b, t) Animate between two Paths.
Path:clone () Create a deep copy.
Path:curveTo (cp1x, cp1y, cp2x, cp2y, x, y) Draw a cubic bezier curve to (x, y).
Path:getFillColor () Get fill color.
Path:getFillRule () Get fill rule.
Path:getLineColor () Get line color.
Path:getLineJoin () Get line join.
Path:getLineWidth () Get line width.
Path:getMiterLimit () Get miter limit.
Path:getOpacity () Get opacity.
Path:inside (x, y) Check if inside.
Path:lineTo (x, y) Draw a line to (x, y).
Path:moveTo (x, y) Move to position (x, y).
Path:nearest (x, y[, max[, min]]) Find nearest point.
Path:refine (k) Refine curves.
Path:rotate (w, k) Rotate elements.
Path:setFillColor (r[, g[, b[, a=1]]]) Set fill color.
Path:setFillRule (rule) Set fill rule.
Path:setLineColor (r[, g[, b[, a=1]]]) Set line color.
Path:setLineDashOffset (offset) Set line dash offset.
Path:setLineJoin (join) Set line join.
Path:setLineWidth (width) Set line width.
Path:setMiterLimit (miterLimit) Set miter limit.
Path:setOpacity (opacity) Set opacity.
Path:warp (f) Warp points.


Tables

Path.id
name of this path
Path.subpaths
tove.List of Subpaths in this Path

Methods

Path:addSubpath (t)
Add a Subpath. The new Subpath will be appended after other existing Subpaths.

Parameters:

Path:animate (a, b, t)
Animate between two Paths. Makes this Path to an interpolated inbetween.

Parameters:

  • a Path Path at t == 0
  • b Path Path at t == 1
  • t number interpolation (0 <= t <= 1)

See also:

Path:clone ()
Create a deep copy. This cloned copy will include new copies of all Subpaths.

Returns:

    Path cloned Path.
Path:curveTo (cp1x, cp1y, cp2x, cp2y, x, y)
Draw a cubic bezier curve to (x, y). See Bézier curves on Wikipedia.

Parameters:

  • cp1x number x coordinate of curve's first control point (P1)
  • cp1y number y coordinate of curve's first control point (P1)
  • cp2x number x coordinate of curve's second control point (P2)
  • cp2y number y coordinate of curve's second control point (P2)
  • x number x coordinate of curve's end position (P3)
  • y number y coordinate of curve's end position (P3)

Usage:

    g:moveTo(10, 20)
    g:curveTo(7, 5, 10, 3, 50, 30)
Path:getFillColor ()
Get fill color.

Returns:

    Paint current fill color, or nil if there is no fill
Path:getFillRule ()
Get fill rule.

Returns:

    string one of the names in tove.FillRule

See also:

Path:getLineColor ()
Get line color.

Returns:

    Paint current line color, or nil if there is no line
Path:getLineJoin ()
Get line join.

Returns:

    string one of the names in tove.LineJoin

See also:

Path:getLineWidth ()
Get line width.

Returns:

    number current line width

See also:

Path:getMiterLimit ()
Get miter limit.

Returns:

    number current miter limit

See also:

Path:getOpacity ()
Get opacity.

Returns:

    number Path's opacity

See also:

Path:inside (x, y)
Check if inside. Returns true if a given point is inside the Path.

Parameters:

  • x number x coordinate of point to test
  • y number y coordinate of point to test
Path:lineTo (x, y)
Draw a line to (x, y).

Parameters:

  • x number x coordinate of line's end position
  • y number y coordinate of line's end position

Usage:

    g:moveTo(10, 20)
    g:lineTo(5, 30)
Path:moveTo (x, y)
Move to position (x, y). Automatically starts a fresh Subpath if necessary.

Parameters:

  • x number new x coordinate
  • y number new y coordinate
Path:nearest (x, y[, max[, min]])
Find nearest point.

Parameters:

  • x number x component of point to search against
  • y number y component of point to search against
  • max number ignore curve points above this distance (optional)
  • min number return as soon as a distance smaller than this is found (optional)

Returns:

  1. number distance to nearest Subpath
  2. number t parameter describing nearest point on Subpath
  3. Subpath nearest Subpath

See also:

Path:refine (k)
Refine curves. Adds additional points without changing the shape.

Parameters:

  • k int scale number of points by this amount

Usage:

    p:refine(2) -- double number of points, same shape
Path:rotate (w, k)
Rotate elements. Will recusively left rotate elements in this Graphics such that items found at index k will get moved to index 0.

Parameters:

  • w string what to rotate: either "subpath", "point" or "curve"
  • k int how much to rotate

See also:

Path:setFillColor (r[, g[, b[, a=1]]])
Set fill color.

Parameters:

  • r number, string, Paint or nil red
  • g number green (optional)
  • b number blue (optional)
  • a number alpha (default 1)

Usage:

    g:setFillColor(0.8, 0, 0, 0.5)  -- transparent reddish
    g:setFillColor("#00ff00")  -- opaque green
    g:setFillColor(nil)  -- no fill
Path:setFillRule (rule)
Set fill rule. Defines the rule by which TÖVE knows which parts of a shape are solid and which are not.

Parameters:

See also:

Path:setLineColor (r[, g[, b[, a=1]]])
Set line color.

Parameters:

  • r number, string, Paint or nil red
  • g number green (optional)
  • b number blue (optional)
  • a number alpha (default 1)

See also:

Path:setLineDashOffset (offset)
Set line dash offset. See Mozilla for a good description of line dash offsets.

Parameters:

  • offset number new line dash offset
Path:setLineJoin (join)
Set line join.

Parameters:

See also:

Path:setLineWidth (width)
Set line width.

Parameters:

  • width number new line width

See also:

Path:setMiterLimit (miterLimit)
Set miter limit. See Mozilla for a good description of miter limits.

Parameters:

  • miterLimit number new miter limit
Path:setOpacity (opacity)
Set opacity. This will apply to the whole path indepentent of fill and line colors.

Parameters:

  • opacity number Path's opacity (between 0 and 1)

See also:

Path:warp (f)
Warp points.

Parameters:

  • f function takes (x, y, curvature) and returns the same

See also:

generated by LDoc 1.4.6 Last updated 2019-04-19 11:25:52