mirror of
https://github.com/varkor/quiver.git
synced 2024-09-11 05:46:13 +03:00
Refactor non-UI code
This commit is contained in:
parent
92338d12fd
commit
1217d323e2
@ -60,4 +60,4 @@ Adjunctions:
|
||||
|
||||
## Thanks
|
||||
- [@cartesiancat](https://github.com/cartesiancat) for discussions about rendering aesthetic arrows.
|
||||
- [AndréC](https://tex.stackexchange.com/users/138900/andr%c3%a9c) for the custom TikZ `curve` setting.
|
||||
- [AndréC](https://tex.stackexchange.com/users/138900/andr%c3%a9c) for the custom TikZ `curve` style.
|
||||
|
14
src/arrow.js
14
src/arrow.js
@ -10,8 +10,7 @@ class QuiverSVG {
|
||||
// Create a top-level SVG. This will include all the edges and labels as children.
|
||||
// Note that we need to explicitly set the namespace attribute so that the SVG can be
|
||||
// treated as a standalone file, when we want to export it.
|
||||
const xmlns = "http://www.w3.org/2000/svg";
|
||||
this.element = new DOM.SVGElement("svg", { xmlns });
|
||||
this.element = new DOM.SVGElement("svg", { xmlns: DOM.SVGElement.NAMESPACE });
|
||||
}
|
||||
}
|
||||
|
||||
@ -474,12 +473,11 @@ class Arrow {
|
||||
fill: "none",
|
||||
stroke: "black",
|
||||
"stroke-width": stroke_width,
|
||||
// We'd prefer to use `round`, especially for dashed and dotted lines, but unfortunately
|
||||
// this doesn't work well with thicker edges. Ideally, we want a `round-butt` option,
|
||||
// specifying edges do not extend farther than the path.
|
||||
// We manually draw rounded ends for the overall path, but we avoid doing this for every
|
||||
// dash, as this would be very expensive.
|
||||
"stroke-linecap": "butt",
|
||||
// We use the default `stroke-linecap` option of `butt`. We'd prefer to use `round`,
|
||||
// especially for dashed and dotted lines, but unfortunately this doesn't work well with
|
||||
// thicker edges. Ideally, we want a `round-butt` option, specifying edges do not extend
|
||||
// farther than the path. We manually draw rounded ends for the overall path, but we
|
||||
// avoid doing this for every dash, as this would be very expensive.
|
||||
});
|
||||
|
||||
// When we draw squiggly arrows, we have straight line padding near the tail and head, which
|
||||
|
@ -99,6 +99,8 @@ class Bezier {
|
||||
/// number for the polygon with respect to the point. If the winding number is nonzero, then
|
||||
/// the point lies inside the polygon.
|
||||
/// This algorithm is based on the one at: http://geomalgorithms.com/a03-_inclusion.html.
|
||||
/// Technically, this shouldn't really be a method on `Bezier`, but it is currently always used
|
||||
/// for algorithms related to Bézier curves, so it's placed here for convenience.
|
||||
static point_inside_polygon(point, points) {
|
||||
// The displacement of a point from a line (calculated via the determinant of a 2x2 matrix).
|
||||
const displ = ([base, end], point) => {
|
||||
@ -254,7 +256,8 @@ class Bezier {
|
||||
}
|
||||
}
|
||||
|
||||
/// A point on a quadratic Bézier curve, which also records the angle of the curve at the point.
|
||||
/// A point on a quadratic Bézier curve, which also records the parameter `t` and the `angle` of the
|
||||
/// curve at the point.
|
||||
class BezierPoint extends Point {
|
||||
constructor(point, t, angle) {
|
||||
super(point.x, point.y);
|
||||
|
@ -2406,7 +2406,7 @@ class Panel {
|
||||
// and one for the unchecked version.
|
||||
const backgrounds = [];
|
||||
|
||||
const svg = new DOM.SVGElement("svg", { xmlns: "http://www.w3.org/2000/svg" }).element;
|
||||
const svg = new DOM.SVGElement("svg", { xmlns: DOM.SVGElement.NAMESPACE }).element;
|
||||
|
||||
const { shared, edge: { length, options, gap = null } } = properties(value, data);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user