Constructor
new Plot(optionsopt)
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
An object containing configuration for Plot. Properties
|
Classes
Methods
add(shape)
Adds shapes to the plot.
Parameters:
Name | Type | Description |
---|---|---|
shape |
Line | Circle | Path | Point | Array | An object or array of objects to be added to the plot. |
Example
import { Plot, Line, Circle } from "@jakebeamish/penplotting";
const plot = new Plot({
backgroundColor: "#ffffff"
});
plot.generate = () => {
const line = Line.fromArray([0, 0, 100, 100]);
const circlesArray = [
new Circle(10, 10, 10),
new Circle(40, 40, 15),
new Circle(80, 80, 20)
];
plot.add([line, circlesArray]);
}
plot.draw();
addCirclesToSVG()
Adds the Circles in this Plot's circles array to it's SVG element.
addLinesToSVG()
Adds the Lines in this Plot's lines array to it's SVG element.
addPathsToSVG()
Adds the Paths in this Plot's paths array to it's SVG element.
(private) addSingleShape(shape)
Adds a single shape to the appropriate array. Used by Plot#add.
Parameters:
Name | Type | Description |
---|---|---|
shape |
Line | Path | Circle | Point |
appendSVG()
Appends this plot's SVG element to the document body.
clear()
Empty out any existing HTML UI and SVG document elements on the page, in order to regenerate a Plot.
createUI(timeTaken)
Creates HTML UI and adds it to the document body.
Parameters:
Name | Type | Description |
---|---|---|
timeTaken |
number |
deduplicateLines()
Removes duplicated Lines from this Plot's lines array.
downloadSVG()
Download the Plot as an SVG file.
draw()
Generates the SVG and UI and appends them to the document body. Must be called after defining a Plot.generate() function.
filename() → {string}
Returns:
- The file name to be used for the Plot's SVG file,
as a string in the format
Title_ffffffff_210x297mm.svg
- Type
- string
removeOverlappingLines()
Removes overlapping Lines from this Plot's lines array.
removeShortLines(minimumLength)
Removes Lines in this Plot's lines array that are shorter than a specified minimum length.
Parameters:
Name | Type | Description |
---|---|---|
minimumLength |
number |