- Canvas
- ~Canvas
- new Canvas(paint, [startPoint])
- .size :
Size
- .paint :
Paint
- .startPoint :
Point
- .draw([clear])
- .clear()
- .arc(center, radius, startAngle, endAngle, [anticlockwise])
- .arcTo(controlPoint1, controlPoint2, radius)
- .getBounds() ⇒
Array.<Point>
- .beginPath([paint]) ⇒
Canvas
- .bezierCurveTo(controlPoint1, controlPoint2, endPoint)
- .clearRect(start, size)
- .clip(path)
- .close()
- .ellipse(center, radiusX, radiusY, rotation, startAngle, endAngle)
- .isPointInPath(point) ⇒
boolean
- .isPointInStroke(point, start, end) ⇒
boolean
- .lineTo(point)
- .subpathAt(point) ⇒
Canvas
- .quadraticCurveTo(controlPoint, endPoint)
- .rect(startingPoint, size)
- .reset(start)
- .roundRect(startingPoint, size, radii)
- .transform(matrix)
- .translate(x, y)
- .addPath(path, [transform])
- ~Canvas
A canvas for drawing paths
Kind: inner class of Canvas
- ~Canvas
- new Canvas(paint, [startPoint])
- .size :
Size
- .paint :
Paint
- .startPoint :
Point
- .draw([clear])
- .clear()
- .arc(center, radius, startAngle, endAngle, [anticlockwise])
- .arcTo(controlPoint1, controlPoint2, radius)
- .getBounds() ⇒
Array.<Point>
- .beginPath([paint]) ⇒
Canvas
- .bezierCurveTo(controlPoint1, controlPoint2, endPoint)
- .clearRect(start, size)
- .clip(path)
- .close()
- .ellipse(center, radiusX, radiusY, rotation, startAngle, endAngle)
- .isPointInPath(point) ⇒
boolean
- .isPointInStroke(point, start, end) ⇒
boolean
- .lineTo(point)
- .subpathAt(point) ⇒
Canvas
- .quadraticCurveTo(controlPoint, endPoint)
- .rect(startingPoint, size)
- .reset(start)
- .roundRect(startingPoint, size, radii)
- .transform(matrix)
- .translate(x, y)
- .addPath(path, [transform])
Creates a new Canvas
Param | Type | Default | Description |
---|---|---|---|
paint | Paint |
The paint to use for rendering | |
[startPoint] | Point |
Point.zero() |
The starting point of the path |
Example
// Create a new canvas, with a stroke of red
const canvas = new Canvas(new Paint(Color.red));
The size of the canvas (The size of the terminal)
Kind: instance property of Canvas
Read only: true
The paint to use for rendering
Kind: instance property of Canvas
The starting point of the path
Kind: instance property of Canvas
Read only: true
Draws the current canvas to the terminal
Kind: instance method of Canvas
Param | Type | Default | Description |
---|---|---|---|
[clear] | boolean |
true |
Whether or not to clear the screen before rendering |
Without resetting the operations, clears the canvas
Kind: instance method of Canvas
Draws an arc
Kind: instance method of Canvas
Param | Type | Default | Description |
---|---|---|---|
center | Point |
The center-point of the arc | |
radius | number |
The radius of the arc | |
startAngle | number |
The angle to start at | |
endAngle | number |
The angle to end at | |
[anticlockwise] | boolean |
false |
Whether or not to draw the arc in an anticlockwise direction |
Draws an arc through two controls points
Kind: instance method of Canvas
Param | Type | Description |
---|---|---|
controlPoint1 | Point |
The first control point |
controlPoint2 | Point |
The second control point |
radius | number |
The radius of the arc |
Gets the bounds of the path, hoping that the path is closed
Kind: instance method of Canvas
Returns: Array.<Point>
- The points that make up the path bounds
Creates a new subpath at the current point
Kind: instance method of Canvas
Returns: Canvas
- The subpath
Param | Type | Default | Description |
---|---|---|---|
[paint] | Paint |
this.paint |
The paint to use for the subpath |
Draws a cubic bezier curve from the current point to the specified point
Kind: instance method of Canvas
Param | Type | Description |
---|---|---|
controlPoint1 | Point |
The first control point |
controlPoint2 | Point |
The second control point |
endPoint | Point |
The end point |
Clears a rectangle at the specified point in the screen
Kind: instance method of Canvas
Param | Type | Description |
---|---|---|
start | Point |
The top left corner of the rectangle |
size | Size |
The size of the rectangle |
Clears a path out of the current path (like a mask)
Kind: instance method of Canvas
Param | Type | Description |
---|---|---|
path | Canvas |
The path to clip to |
Closes the last opened subpath, or closes the path if no subpaths are open
Kind: instance method of Canvas
Draws an ellipse
Kind: instance method of Canvas
Param | Type | Description |
---|---|---|
center | Point |
The center of the ellipse |
radiusX | number |
The radius of the ellipse on the x axis |
radiusY | number |
The radius of the ellipse on the y axis |
rotation | number |
The rotation of the ellipse (in radians) |
startAngle | number |
The start angle of the ellipse (in radians) |
endAngle | number |
The end angle of the ellipse (in radians) |
Checks if the specified point is in the path
Kind: instance method of Canvas
Returns: boolean
- Whether or not the point is in the path
Param | Type | Description |
---|---|---|
point | Point |
The point to check |
Determines if the specified point is in the stroke
Kind: instance method of Canvas
Returns: boolean
- Whether or not the point is in the stroke
Param | Type | Description |
---|---|---|
point | Point |
The point to check |
start | Point |
The start point of the line |
end | Point |
The end point of the line |
Draws a line from the current point to the specified point
Kind: instance method of Canvas
Param | Type | Description |
---|---|---|
point | Point |
The point to draw a line to |
Moves the current point to the specified point
Kind: instance method of Canvas
Param | Type | Description |
---|---|---|
point | Point |
The point to move to |
Draws a quadratic bezier curve from the current point to the specified point
Kind: instance method of Canvas
Param | Type | Description |
---|---|---|
controlPoint | Point |
The control point |
endPoint | Point |
The end point |
Draws a rectangle
Kind: instance method of Canvas
Param | Type | Description |
---|---|---|
startingPoint | Point |
The starting point of the rectangle (top left) |
size | Size |
The size of the rectangle |
Resets the path, including all the operations
Kind: instance method of Canvas
Param | Type | Description |
---|---|---|
start | Point |
The new starting point |
Makes a rounded rectangle
Kind: instance method of Canvas
Param | Type | Description |
---|---|---|
startingPoint | Point |
The starting point |
size | Size |
The size of the rectangle |
radii | Array.<number> | number |
The radii of the corners. If it is a number, or number[1], it will be applied to all corners. If it is a number[2], the first element will apply to the top left and bottom right corners, and the second element will apply to the top right and bottom left corners. If it is a number[4], then the array will be applied to the top left, top right, bottom right, and bottom left corners, respectively. |
Transforms all the points in the path by the specified matrix
Kind: instance method of Canvas
Param | Type | Description |
---|---|---|
matrix | Matrix |
The matrix to transform the path by |
Translates all the points in the path by the specified amount
Kind: instance method of Canvas
Param | Type | Description |
---|---|---|
x | number |
The x value to translate by |
y | number |
The y value to translate by |
Adds a subpath to the path, and optionally applies a transform to it
Kind: instance method of Canvas
Param | Type | Description |
---|---|---|
path | Path |
The subpath to add |
[transform] | Matrix |
The optional transform to apply to the subpath |
- Geometry
- ~Point
- new Point(x, y)
- instance
- .x :
number
- .y :
number
- .transform(matrix)
- .equals(x, [y]) ⇒
boolean
- .x :
- static
- .center() ⇒
Point
- .centerFor(x, [y]) ⇒
Point
- .zero() ⇒
Point
- .inBounds(px, [y]) ⇒
boolean
- .of(psx, [y]) ⇒
Point
- .center() ⇒
- ~Matrix
- ~Size
- new Size(width, height)
- .width :
number
- .height :
number
- ~PointLike :
Point
|Size
|number
|Array.<number>
|Object
- ~Point
A point in 2D space
Kind: inner class of Geometry
- ~Point
- new Point(x, y)
- instance
- .x :
number
- .y :
number
- .transform(matrix)
- .equals(x, [y]) ⇒
boolean
- .x :
- static
- .center() ⇒
Point
- .centerFor(x, [y]) ⇒
Point
- .zero() ⇒
Point
- .inBounds(px, [y]) ⇒
boolean
- .of(psx, [y]) ⇒
Point
- .center() ⇒
Creates a new Point
Throws:
Error
If the arguments are invalid or out of bounds
Param | Type | Description |
---|---|---|
x | number |
The x coordinate. (Can be any number from 0 to process.stdout.columns) |
y | number |
The y coordinate. (Can be any number from 0 to process.stdout.rows) |
Example
// Create a new point at (10, 10)
const point = new Point(10, 10);
The x coordinate
Kind: instance property of Point
The y coordinate
Kind: instance property of Point
Transforms the point by the given matrix
Kind: instance method of Point
Param | Type | Description |
---|---|---|
matrix | Matrix |
The matrix to transform the point by |
Determines whether or not the point is equal to another point
Kind: instance method of Point
Returns: boolean
- Whether or not the points are equal
Param | Type | Description |
---|---|---|
x | PointLike |
The point to compare to, or the x coordinate |
[y] | number |
The y coordinate |
Creates a new point at the center of the terminal
Kind: static method of Point
Returns: Point
- The center point
Kind: static method of Point
Param | Type | Description |
---|---|---|
x | PointLike |
The point or size to center, or the x coordinate |
[y] | number |
The y coordinate |
Creates a new point at (0, 0)
Kind: static method of Point
Returns: Point
- A new point at (0, 0)
Determines whether or not the given point is within the bounds of the terminal
Kind: static method of Point
Returns: boolean
- Whether or not the point is within the bounds of the terminal
Throws:
Error
If the arguments are invalid
Param | Type | Description |
---|---|---|
px | PointLike |
The point or size to check, or the x coordinate |
[y] | number |
The y coordinate |
Creates a new point from the given point, size, array, or coordinates
Kind: static method of Point
Returns: Point
- The new point
Param | Type | Description |
---|---|---|
psx | Point | Size | number | Array.<number> | Object |
The point or size to create a new point from, or the x coordinate |
[y] | number |
The y coordinate |
A matrix for transforming points
Kind: inner class of Geometry
The identity matrix
Param | Type | Description |
---|---|---|
a | number |
The a value |
b | number |
The b value |
c | number |
The c value |
d | number |
The d value |
e | number |
The e value |
f | number |
The f value |
The a value
Kind: instance property of Matrix
The b value
Kind: instance property of Matrix
The c value
Kind: instance property of Matrix
The d value
Kind: instance property of Matrix
The e value
Kind: instance property of Matrix
The f value
Kind: instance property of Matrix
A size in 2D space
Kind: inner class of Geometry
- ~Size
- new Size(width, height)
- .width :
number
- .height :
number
Creates a new Size
Param | Type | Description |
---|---|---|
width | number |
The width |
height | number |
The height |
Example
// Create a new size of (10, 10)
const size = new Size(10, 10);
The width
Kind: instance property of Size
The height
Kind: instance property of Size
A point-like object. Can be a Point, Size, number, array, or object with x and y properties.
Kind: inner typedef of Geometry
- Paint
- ~Paint
- new Paint(strokeColor, fillColor)
- .strokeColor :
Color
|Gradient
- .fillColor :
Color
|Gradient
- .Mode :
enum
- ~Color
- new Color(r, g, b)
- instance
- static
- .fromNumber(num) ⇒
Color
- .fromNumber(num) ⇒
- ~LinearGradient ⇐
Gradient
- ~RadialGradient ⇐
Gradient
- ~ConicGradient ⇐
Gradient
- ~Paint
A paint object
Kind: inner class of Paint
- ~Paint
- new Paint(strokeColor, fillColor)
- .strokeColor :
Color
|Gradient
- .fillColor :
Color
|Gradient
- .Mode :
enum
Creates a new paint object
Param | Type |
---|---|
strokeColor | Color | Gradient |
fillColor | Color | Gradient |
Example
// Create a new paint object with a red stroke and a blue fill
const paint = new Paint(Color.Red, Color.Blue);
The stroke color
Kind: instance property of Paint
The fill color
Kind: instance property of Paint
Kind: instance enum of Paint
Properties
Name | Type |
---|---|
Clear | Symbol |
Paint | Symbol |
Gradient | Symbol |
A color object
Kind: inner class of Paint
- ~Color
- new Color(r, g, b)
- instance
- static
- .fromNumber(num) ⇒
Color
- .fromNumber(num) ⇒
Creates a new color object
Param | Type | Description |
---|---|---|
r | number |
Red |
g | number |
Blue |
b | number |
Green |
Example
// Create a new color object with the RGB values of (255, 0, 0)
const color = new Color(255, 0, 0);
Kind: instance property of Color
Read only: true
Black
Kind: instance property of Color
Read only: true
Red
Kind: instance property of Color
Read only: true
Green
Kind: instance property of Color
Read only: true
Blue
Kind: instance property of Color
Read only: true
White
Kind: instance property of Color
Read only: true
Do not paint
Kind: instance property of Color
Read only: true
Red
Kind: instance property of Color
Green
Kind: instance property of Color
Blue
Kind: instance property of Color
Creates a new color from the given number
Kind: instance method of Color
Creates a color from a number
Kind: static method of Color
Param | Type | Description |
---|---|---|
num | number |
Number to convert |
A linear gradient
Kind: inner class of Paint
Extends: Gradient
- ~LinearGradient ⇐
Gradient
Creates a new linear gradient
Param | Type | Description |
---|---|---|
angle | number |
The angle direction of the gradient (Radians) |
Example
// Create a new gradient that goes from red to blue
let gradient = new LinearGradient(0 /* The angle of the gradient in radians *\/);
gradient.addColorStop(0, Color.Red);
gradient.addColorStop(1, Color.Blue);
Gets the color for a point in the gradient
Kind: instance method of LinearGradient
Param | Type | Description |
---|---|---|
fillStart | Point |
The start point of the fill |
point | Point |
The point to get the color for |
fillEnd | Point |
The end point of the fill |
A radial gradient
Kind: inner class of Paint
Extends: Gradient
- ~RadialGradient ⇐
Gradient
Creates a new radial gradient
Example
// Create a new gradient that goes from red to blue
let gradient = new RadialGradient();
gradient.addColorStop(0, Color.Red);
gradient.addColorStop(1, Color.Blue);
Gets the color for a point in the gradient
Kind: instance method of RadialGradient
Param | Type | Description |
---|---|---|
fillStart | Point |
The start point of the fill |
point | Point |
The point to get the color for |
fillEnd | Point |
The end point of the fill |
A conic gradient
Kind: inner class of Paint
Extends: Gradient
- ~ConicGradient ⇐
Gradient
Creates a new conic gradient
Param | Type | Description |
---|---|---|
angle | number |
The angle direction of the gradient (Radians) |
Example
// Create a new gradient that goes from red to blue
let gradient = new ConicGradient(0 /* The angle of the gradient in radians *\/);
gradient.addColorStop(0, Color.Red);
gradient.addColorStop(1, Color.Blue);
Gets the color for a point in the gradient
Kind: instance method of ConicGradient
Param | Type | Description |
---|---|---|
fillStart | Point |
The start point of the fill |
point | Point |
The point to get the color for |
fillEnd | Point |
The end point of the fill |