{
const { w, h } = {
w: width - 64,
h: 400
};
const plane = cartesianPlane(w, h);
points(plane, [
{ x: -4, y: -8, color: 'red' },
{ x: 3, y: 4, color: 'blue' },
{ x: 4, y: 3, color: 'red' },
{ x: 4, y: 2, color: 'yellow' }
]);
lines(plane, [
{ gradient: 5, offset: 2, color: 'red', type: 'd' },
{ gradient: 0, offset: 2, color: 'blue' },
{ gradient: Infinity, offset: 2 }
]);
segment(plane, {
points: [[-1, -9], [2, -9]],
type: 'd'
});
triangle(plane, {
name: 'Sample Triangle',
points: [[-4.0, -6.4], [2.0, 6.0], [4.0, -5.3]]
});
curves(
plane,
{
func: x => x * x,
domain: x => x >= 0
},
{
color: 'blue',
step: 0.01,
type: 'line',
inverse: true
}
);
curves(
plane,
{
func: x => 0.5 * x * x * x + 1.5 * x * x,
domain: x => true
},
{
color: 'purple',
step: 0.01,
type: 'point',
inverse: false
}
);
parallelogram(plane, {
name: 'sample parallelogram',
point: [-1, 4],
width: 2,
height: 2,
angle: 45
});
rectangle(plane, {
name: 'sample rectangle',
point: [-1, 0],
width: 2,
height: 2
});
square(plane, {
name: 'sample square',
point: [2, 0],
length: 2
});
circle(plane, {
center: [0, 0],
radius: 2,
startAngle: 0,
endAngle: Math.PI * 90
});
return plane.svg.node();
}