Class Subpath

A vector graphics subpath (trajectory), usually lives inside a Path.

Functions

tove.newSubpath ([points]) Create new subpath.

Tables

Subpath.curves tove.List of Curves in this Subpath
Subpath.isClosed is this subpath closed?

Methods

Subpath:arc (x, y, r, startAngle, endAngle, ccw) Draw an arc.
Subpath:clone () Clone.
Subpath:curveTo (cp1x, cp1y, cp2x, cp2y, x, y) Draw a cubic bezier curve to (x, y).
Subpath:drawCircle (x, y, r) Draw a circle.
Subpath:drawEllipse (x, y, rx, ry) Draw an ellipse.
Subpath:drawRect (x, y, w, h, rx, ry) Draw a rectangle.
Subpath:invert () Invert.
Subpath:lineTo (x, y) Draw a line to (x, y).
Subpath:mould (t, x, y) Mould curve.
Subpath:moveTo (x, y) Move to position (x, y).
Subpath:nearest (x, y, dmax, dmin) Find nearest point.
Subpath:normal (t) Evaluate normal at t.
Subpath:position (t) Evaluate position at t.
Subpath:setPoints (points) Set points.
Subpath:transform (x[, y[, angle[, sy[, sy[, ox[, oy[, kx[, ky]]]]]]]]) Transform this Subpath.
Subpath:warp (f) Warp.


Functions

Methods
tove.newSubpath ([points])
Create new subpath.

Parameters:

  • points  {number,number,...} x and y components of points to use (optional)

Returns:

    Subpath new subpath

Tables

Subpath.curves
tove.List of Curves in this Subpath
Subpath.isClosed
is this subpath closed?

Methods

Subpath:arc (x, y, r, startAngle, endAngle, ccw)
Draw an arc.

Parameters:

  • x number x coordinate of centre of arc
  • y number y coordinate of centre of arc
  • r number radius of arc
  • startAngle number angle at which to start drawing
  • endAngle number angle at which to stop drawing
  • ccw bool true if drawing between given angles is counterclockwise
Subpath:clone ()
Clone. Creates a deep clone.

Returns:

    Subpath cloned subpath
Subpath: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)

Returns:

    Command curve command

Usage:

    subpath:moveTo(10, 20)
    subpath:curveTo(7, 5, 10, 3, 50, 30)
Subpath:drawCircle (x, y, r)
Draw a circle.

Parameters:

  • x number x coordinate of centre
  • y number y coordinate of centre
  • r number radius

Returns:

    Command circle command
Subpath:drawEllipse (x, y, rx, ry)
Draw an ellipse.

Parameters:

  • x number x coordinate of centre
  • y number y coordinate of centre
  • rx number horizontal radius
  • ry number vertical radius

Returns:

    Command ellipse command
Subpath:drawRect (x, y, w, h, rx, ry)
Draw a rectangle.

Parameters:

  • x number x coordinate of top left corner
  • y number y coordinate of top left corner
  • w number width
  • h number height
  • rx number horizontal roundness of corners
  • ry number vertical roundness of corners

Returns:

    Command rectangle command
Subpath:invert ()
Invert. Reverses orientation by reversing order of points. You can use this to create holes in a Path.
Subpath: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

Returns:

    Command line command

Usage:

    subpath:moveTo(10, 20)
    subpath:lineTo(5, 30)
Subpath:mould (t, x, y)
Mould curve. Moves a specific point on the curve to a new location and adapts the surrounding curve.

Parameters:

  • t number t of point on the curve which should be moved, 0 <= t < = number of curves
  • x number x coordinate of where to move
  • y number y coordinate of where to move
Subpath:moveTo (x, y)
Move to position (x, y).

Parameters:

  • x number new x coordinate
  • y number new y coordinate

Returns:

    Command move command
Subpath:nearest (x, y, dmax, dmin)
Find nearest point.

Parameters:

  • x number x component of point to search against
  • y number y component of point to search against
  • dmax number[opt=1e50] ignore curve points above this distance
  • dmin number[opt=1e-4] return as soon as a distance smaller than this is found

Returns:

  1. number t which produces closest distance
  2. number distance distance at given t
Subpath:normal (t)
Evaluate normal at t.

Parameters:

  • t number t at which to evaluate position. 0 < t < 1 will lie in the first curve, 1 < t < 2 will lie in the second curve, and so on.

Returns:

  1. number x component of normal
  2. number y component of normal
Subpath:position (t)
Evaluate position at t.

Parameters:

  • t number t at which to evaluate position. 0 < t < 1 will lie in the first curve, 1 < t < 2 will lie in the second curve, and so on.

Returns:

  1. number x position
  2. number y position
Subpath:setPoints (points)
Set points.

Parameters:

  • points {number,number,...} x and y coordinates of points to set
Subpath:transform (x[, y[, angle[, sy[, sy[, ox[, oy[, kx[, ky]]]]]]]])
Transform this Subpath.

Parameters:

  • x number or Translation move by x in x-axis, or a LÖVE Transform
  • y number move by y in y-axis (optional)
  • angle number applied rotation in radians (optional)
  • sy number scale factor in y (optional)
  • sy number scale factor in y (optional)
  • ox number x coordinate of origin (optional)
  • oy number y coordinate of origin (optional)
  • kx number skew in x-axis (optional)
  • ky number skew in y-axis (optional)

See also:

Usage:

    subpath:transform(0, 0, 0, sx, sy)  -- scale by (sx, sy)
Subpath:warp (f)
Warp.

Parameters:

  • f function warp function

See also:

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