Readonly
canvasPrivate
commandsPrivate
scopeCopies the contents of the CandyGraph canvas to another canvas. Returns the HTMLCanvasElement that was copied to.
The Viewport
of the CandyGraph
canvas that will be copied from.
Optional
destinationCanvas: HTMLCanvasElementThe canvas that will be copied to. If not provided, one will be created with the dimensions of destinationViewport
.
Optional
destinationViewport: ViewportIf not provided, one will be created that is positioned at [0, 0] and with the width and height of sourceViewport
.
Private
getPrivate
recursiveRenders the given Renderable(s) to the given Viewport with the provided CoordinateSystem.
// Create a viewport.
const viewport = { x: 0, y: 0, width: 384, height: 384 };
// Create a coordinate system.
const coords = new CartesianCoordinateSystem(
new LinearScale([0, 1], [32, viewport.width - 16]),
new LinearScale([0, 1], [32, viewport.height - 16])
);
// Render a line segment to the viewport.
cg.render(coords, viewport, new LineSegments(cg, [0, 0, 1, 1]));
// Render a couple more line segments to the viewport.
cg.render(coords, viewport, [new LineSegments(cg, [0.5, 0, 0.5, 1]), new LineSegments(cg, [0, 1, 1, 0])]);
Generated using TypeDoc
Clears the entire CandyGraph canvas.
Examples
Clear the canvas to solid white.
Clear the canvas to blue.
Clear the canvas to zero alpha for compositing with the page.