Public
Edited
Aug 31, 2023
Insert cell
Insert cell
Bezier = require("bezier-js@2/bezier.js").catch(() => window.Bezier)

Insert cell
lineSegment = new Bezier.Segment([x1, y1], [x2, y2])
Insert cell
line = { p1: {x:0, y:175} };
Insert cell
{
var bezierCurve = new Bezier(125, 200, 250, 225, 275, 100);

var draw = function () {
this.drawSkeleton(bezierCurve);
this.drawCurve(bezierCurve);
var line = { p1: { x: 0, y: 175 }, p2: { x: 200, y: 25 } };
this.setColor("red");
this.drawLine(line.p1, line.p2);
this.setColor("black");
var intersections = bezierCurve.intersects(line);
intersections.forEach((t) => {
var intersectionPoint = bezierCurve.get(t);
console.log(line);
this.drawPoint(intersectionPoint);
});
};
//console.log(draw);
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more