diff --git a/docs/chapters/bsplines/basic.js b/docs/chapters/bsplines/basic.js index a25606f4..34475217 100644 --- a/docs/chapters/bsplines/basic.js +++ b/docs/chapters/bsplines/basic.js @@ -19,9 +19,6 @@ setup() { draw() { clear(); - setStroke(`lightgrey`); - drawGrid(20); - setStroke(this.parameters.showCurves ? `transparent` : `#CC00CC99`); for (let i=0, e=points.length-1, p, n; i - - + Finding self-intersections is effectively the same procedure, except that we're starting with a single curve, so we need to turn that into two separate curves first. This is trivially achieved by splitting at an inflection point, or if there are none, just splitting at `t=0.5` first, and then running the exact same algorithm as above, with all non-overlapping curve pairs getting removed at each iteration, and each successive step homing in on the curve's self-intersection points. diff --git a/docs/chapters/curveintersection/curve-curve.js b/docs/chapters/curveintersection/curve-curve.js index 253793a3..cb374319 100644 --- a/docs/chapters/curveintersection/curve-curve.js +++ b/docs/chapters/curveintersection/curve-curve.js @@ -29,12 +29,6 @@ setupEventListening() { this.step++; redraw(); }); - - let reset = find(`.reset`); - if (reset) reset.listen([`click`,`touchstart`], evt => { - this.pairReset(); - redraw(); - }); } draw() { diff --git a/docs/chapters/drawing/handler.js b/docs/chapters/drawing/handler.js index 8c05d4dc..8600437e 100644 --- a/docs/chapters/drawing/handler.js +++ b/docs/chapters/drawing/handler.js @@ -30,8 +30,6 @@ module.exports = { draw: function(api, curve) { api.setPanelCount(1); api.reset(); - api.setColor('lightgrey'); - api.drawGrid(10,10); api.setColor('black'); diff --git a/docs/chapters/reordering/reorder.js b/docs/chapters/reordering/reorder.js index 44eed69a..17203f0b 100644 --- a/docs/chapters/reordering/reorder.js +++ b/docs/chapters/reordering/reorder.js @@ -23,8 +23,6 @@ bindButtons() { draw() { clear(); - setStroke(`lightgrey`); - drawGrid(20); this.drawCurve(); } diff --git a/docs/images/chapters/aligning/31655f24b7dd8b8871687b6610d9ac0e.png b/docs/images/chapters/aligning/31655f24b7dd8b8871687b6610d9ac0e.png index 7f450ed5..51501137 100644 Binary files a/docs/images/chapters/aligning/31655f24b7dd8b8871687b6610d9ac0e.png and b/docs/images/chapters/aligning/31655f24b7dd8b8871687b6610d9ac0e.png differ diff --git a/docs/images/chapters/aligning/b3ccd45a72c815388aee6515fe37a486.png b/docs/images/chapters/aligning/b3ccd45a72c815388aee6515fe37a486.png index cb47ae0d..09d2497f 100644 Binary files a/docs/images/chapters/aligning/b3ccd45a72c815388aee6515fe37a486.png and b/docs/images/chapters/aligning/b3ccd45a72c815388aee6515fe37a486.png differ diff --git a/docs/images/chapters/arclength/4b5d220d02b08f6c9aa19389255ef8bb.png b/docs/images/chapters/arclength/4b5d220d02b08f6c9aa19389255ef8bb.png index bc634bd8..98508780 100644 Binary files a/docs/images/chapters/arclength/4b5d220d02b08f6c9aa19389255ef8bb.png and b/docs/images/chapters/arclength/4b5d220d02b08f6c9aa19389255ef8bb.png differ diff --git a/docs/images/chapters/arclength/4bffba7dda2a3556cf5b2ae7392083c6.png b/docs/images/chapters/arclength/4bffba7dda2a3556cf5b2ae7392083c6.png index 2da51394..031f5d45 100644 Binary files a/docs/images/chapters/arclength/4bffba7dda2a3556cf5b2ae7392083c6.png and b/docs/images/chapters/arclength/4bffba7dda2a3556cf5b2ae7392083c6.png differ diff --git a/docs/images/chapters/arclength/dc74a2f2da19470b8d721ece5f3ce268.png b/docs/images/chapters/arclength/dc74a2f2da19470b8d721ece5f3ce268.png index a4f87877..cb152f45 100644 Binary files a/docs/images/chapters/arclength/dc74a2f2da19470b8d721ece5f3ce268.png and b/docs/images/chapters/arclength/dc74a2f2da19470b8d721ece5f3ce268.png differ diff --git a/docs/images/chapters/bsplines/0215dc106e4ad51afe043c0176a595f6.png b/docs/images/chapters/bsplines/0215dc106e4ad51afe043c0176a595f6.png new file mode 100644 index 00000000..d3d4d566 Binary files /dev/null and b/docs/images/chapters/bsplines/0215dc106e4ad51afe043c0176a595f6.png differ diff --git a/docs/images/chapters/bsplines/0d9c2186423466a32bb8fbd187409f82.png b/docs/images/chapters/bsplines/0d9c2186423466a32bb8fbd187409f82.png new file mode 100644 index 00000000..a67c5b4d Binary files /dev/null and b/docs/images/chapters/bsplines/0d9c2186423466a32bb8fbd187409f82.png differ diff --git a/docs/images/chapters/bsplines/3cfaf7bf5e950072437cfe70391155fa.png b/docs/images/chapters/bsplines/3cfaf7bf5e950072437cfe70391155fa.png deleted file mode 100644 index 9ec21a2e..00000000 Binary files a/docs/images/chapters/bsplines/3cfaf7bf5e950072437cfe70391155fa.png and /dev/null differ diff --git a/docs/images/chapters/bsplines/41167c64c51386414c6e62f0b45e6295.png b/docs/images/chapters/bsplines/41167c64c51386414c6e62f0b45e6295.png new file mode 100644 index 00000000..f6c17060 Binary files /dev/null and b/docs/images/chapters/bsplines/41167c64c51386414c6e62f0b45e6295.png differ diff --git a/docs/images/chapters/bsplines/48a30189e74658737b3a8b28bb816f8a.png b/docs/images/chapters/bsplines/48a30189e74658737b3a8b28bb816f8a.png new file mode 100644 index 00000000..2dfeffd2 Binary files /dev/null and b/docs/images/chapters/bsplines/48a30189e74658737b3a8b28bb816f8a.png differ diff --git a/docs/images/chapters/bsplines/61f28e4b071beeaf755f8826c529fe0a.png b/docs/images/chapters/bsplines/61f28e4b071beeaf755f8826c529fe0a.png deleted file mode 100644 index d9a987e5..00000000 Binary files a/docs/images/chapters/bsplines/61f28e4b071beeaf755f8826c529fe0a.png and /dev/null differ diff --git a/docs/images/chapters/bsplines/6ba59877389e2c856234403ecbd953f9.png b/docs/images/chapters/bsplines/6ba59877389e2c856234403ecbd953f9.png deleted file mode 100644 index 6e7fcddd..00000000 Binary files a/docs/images/chapters/bsplines/6ba59877389e2c856234403ecbd953f9.png and /dev/null differ diff --git a/docs/images/chapters/bsplines/9c4bbb753918e3cb8cbc5a770a2af9ee.png b/docs/images/chapters/bsplines/9c4bbb753918e3cb8cbc5a770a2af9ee.png deleted file mode 100644 index d1343d76..00000000 Binary files a/docs/images/chapters/bsplines/9c4bbb753918e3cb8cbc5a770a2af9ee.png and /dev/null differ diff --git a/docs/images/chapters/bsplines/ac9e15a627ed2bc88c5e1b73147b7991.png b/docs/images/chapters/bsplines/ac9e15a627ed2bc88c5e1b73147b7991.png deleted file mode 100644 index 56c9bbb2..00000000 Binary files a/docs/images/chapters/bsplines/ac9e15a627ed2bc88c5e1b73147b7991.png and /dev/null differ diff --git a/docs/images/chapters/bsplines/c7fe4f9cba8d4bc06436f4f238d202ce.png b/docs/images/chapters/bsplines/c7fe4f9cba8d4bc06436f4f238d202ce.png deleted file mode 100644 index d7bba96b..00000000 Binary files a/docs/images/chapters/bsplines/c7fe4f9cba8d4bc06436f4f238d202ce.png and /dev/null differ diff --git a/docs/images/chapters/bsplines/ceaef2fbee05a58aa11835925403b4cd.png b/docs/images/chapters/bsplines/ceaef2fbee05a58aa11835925403b4cd.png new file mode 100644 index 00000000..ec36e23f Binary files /dev/null and b/docs/images/chapters/bsplines/ceaef2fbee05a58aa11835925403b4cd.png differ diff --git a/docs/images/chapters/bsplines/e50d628696245ef68b691e28b2162d56.png b/docs/images/chapters/bsplines/e50d628696245ef68b691e28b2162d56.png deleted file mode 100644 index 4a191bbf..00000000 Binary files a/docs/images/chapters/bsplines/e50d628696245ef68b691e28b2162d56.png and /dev/null differ diff --git a/docs/images/chapters/bsplines/fe3a8ca5706f286d916e36699e237e51.png b/docs/images/chapters/bsplines/fe3a8ca5706f286d916e36699e237e51.png new file mode 100644 index 00000000..6c198f3f Binary files /dev/null and b/docs/images/chapters/bsplines/fe3a8ca5706f286d916e36699e237e51.png differ diff --git a/docs/images/chapters/catmullconv/aa46749b9469341d9249ca452390d875.png b/docs/images/chapters/catmullconv/aa46749b9469341d9249ca452390d875.png new file mode 100644 index 00000000..3bee31d8 Binary files /dev/null and b/docs/images/chapters/catmullconv/aa46749b9469341d9249ca452390d875.png differ diff --git a/docs/images/chapters/catmullconv/e1e640b29dd07f905c1555438511cad9.png b/docs/images/chapters/catmullconv/e1e640b29dd07f905c1555438511cad9.png deleted file mode 100644 index deae9682..00000000 Binary files a/docs/images/chapters/catmullconv/e1e640b29dd07f905c1555438511cad9.png and /dev/null differ diff --git a/docs/images/chapters/curvefitting/1307361f152242ab0263d81a469cf43b.png b/docs/images/chapters/curvefitting/1307361f152242ab0263d81a469cf43b.png deleted file mode 100644 index 94029b83..00000000 Binary files a/docs/images/chapters/curvefitting/1307361f152242ab0263d81a469cf43b.png and /dev/null differ diff --git a/docs/images/chapters/curvefitting/798f3d7151dfb2887c7881a08e65cdd3.png b/docs/images/chapters/curvefitting/798f3d7151dfb2887c7881a08e65cdd3.png new file mode 100644 index 00000000..2db623e2 Binary files /dev/null and b/docs/images/chapters/curvefitting/798f3d7151dfb2887c7881a08e65cdd3.png differ diff --git a/docs/images/chapters/curveintersection/390fe022c4e290a7a9d3814ae2936b77.png b/docs/images/chapters/curveintersection/e1f4f4dba7a338d342559bcfb0ea8e02.png similarity index 100% rename from docs/images/chapters/curveintersection/390fe022c4e290a7a9d3814ae2936b77.png rename to docs/images/chapters/curveintersection/e1f4f4dba7a338d342559bcfb0ea8e02.png diff --git a/docs/images/chapters/flattening/3deec756c96e53127cd1d615c61043ae.png b/docs/images/chapters/flattening/3deec756c96e53127cd1d615c61043ae.png index 67f6c04f..ca98b7fc 100644 Binary files a/docs/images/chapters/flattening/3deec756c96e53127cd1d615c61043ae.png and b/docs/images/chapters/flattening/3deec756c96e53127cd1d615c61043ae.png differ diff --git a/docs/images/chapters/flattening/e2bb7113d5cda2e3fd29bbc54fbe8841.png b/docs/images/chapters/flattening/e2bb7113d5cda2e3fd29bbc54fbe8841.png index ceb8a949..47fe5413 100644 Binary files a/docs/images/chapters/flattening/e2bb7113d5cda2e3fd29bbc54fbe8841.png and b/docs/images/chapters/flattening/e2bb7113d5cda2e3fd29bbc54fbe8841.png differ diff --git a/docs/images/chapters/pointcurves/eab6ea46fa93030e03ec0ef7deb571dc.png b/docs/images/chapters/pointcurves/eab6ea46fa93030e03ec0ef7deb571dc.png index a621fee8..b26b54e0 100644 Binary files a/docs/images/chapters/pointcurves/eab6ea46fa93030e03ec0ef7deb571dc.png and b/docs/images/chapters/pointcurves/eab6ea46fa93030e03ec0ef7deb571dc.png differ diff --git a/docs/images/chapters/reordering/71f47629388901b821976e034be159e4.png b/docs/images/chapters/reordering/71f47629388901b821976e034be159e4.png new file mode 100644 index 00000000..4eca9278 Binary files /dev/null and b/docs/images/chapters/reordering/71f47629388901b821976e034be159e4.png differ diff --git a/docs/images/chapters/reordering/81e559a69298ecc24c8edebe59e79647.png b/docs/images/chapters/reordering/81e559a69298ecc24c8edebe59e79647.png deleted file mode 100644 index a0a8954a..00000000 Binary files a/docs/images/chapters/reordering/81e559a69298ecc24c8edebe59e79647.png and /dev/null differ diff --git a/docs/images/chapters/reordering/b143027eacfe962c77fb052686f359a1.png b/docs/images/chapters/reordering/b143027eacfe962c77fb052686f359a1.png deleted file mode 100644 index 204c740e..00000000 Binary files a/docs/images/chapters/reordering/b143027eacfe962c77fb052686f359a1.png and /dev/null differ diff --git a/docs/images/chapters/tracing/52f815cefe99dabc47ca83d0b97b61fc.png b/docs/images/chapters/tracing/52f815cefe99dabc47ca83d0b97b61fc.png index e48b8507..9ea12998 100644 Binary files a/docs/images/chapters/tracing/52f815cefe99dabc47ca83d0b97b61fc.png and b/docs/images/chapters/tracing/52f815cefe99dabc47ca83d0b97b61fc.png differ diff --git a/docs/index.html b/docs/index.html index 6b1af686..4e5fdeb7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1582,7 +1582,7 @@ function drawCurve(points[], t): Scripts are disabled. Showing fallback image. - + @@ -3577,12 +3577,11 @@ lli = function(line1, line2): Scripts are disabled. Showing fallback image. - + - - +

@@ -4330,7 +4329,7 @@ for (coordinate, index) in LUT: Scripts are disabled. Showing fallback image. - + @@ -4362,7 +4361,7 @@ for (coordinate, index) in LUT: Scripts are disabled. Showing fallback image. - + @@ -5653,7 +5652,7 @@ for p = 1 to points.length-3 (inclusive): Scripts are disabled. Showing fallback image. - + @@ -5675,7 +5674,7 @@ for p = 1 to points.length-3 (inclusive): Scripts are disabled. Showing fallback image. - + @@ -5845,7 +5844,7 @@ for(let L = 1; L <= order; L++) { Scripts are disabled. Showing fallback image. - + @@ -5870,7 +5869,7 @@ for(let L = 1; L <= order; L++) { Scripts are disabled. Showing fallback image. - + @@ -5891,7 +5890,7 @@ for(let L = 1; L <= order; L++) { Scripts are disabled. Showing fallback image. - + @@ -5914,7 +5913,7 @@ for(let L = 1; L <= order; L++) { Scripts are disabled. Showing fallback image. - + diff --git a/docs/ja-JP/index.html b/docs/ja-JP/index.html index 9cd071ce..d31020e6 100644 --- a/docs/ja-JP/index.html +++ b/docs/ja-JP/index.html @@ -1417,7 +1417,7 @@ function drawCurve(points[], t): Scripts are disabled. Showing fallback image. - + @@ -3412,12 +3412,11 @@ lli = function(line1, line2): Scripts are disabled. Showing fallback image. - + - - +

@@ -4165,7 +4164,7 @@ for (coordinate, index) in LUT: Scripts are disabled. Showing fallback image. - + @@ -4197,7 +4196,7 @@ for (coordinate, index) in LUT: Scripts are disabled. Showing fallback image. - + @@ -5488,7 +5487,7 @@ for p = 1 to points.length-3 (inclusive): Scripts are disabled. Showing fallback image. - + @@ -5510,7 +5509,7 @@ for p = 1 to points.length-3 (inclusive): Scripts are disabled. Showing fallback image. - + @@ -5680,7 +5679,7 @@ for(let L = 1; L <= order; L++) { Scripts are disabled. Showing fallback image. - + @@ -5705,7 +5704,7 @@ for(let L = 1; L <= order; L++) { Scripts are disabled. Showing fallback image. - + @@ -5726,7 +5725,7 @@ for(let L = 1; L <= order; L++) { Scripts are disabled. Showing fallback image. - + @@ -5749,7 +5748,7 @@ for(let L = 1; L <= order; L++) { Scripts are disabled. Showing fallback image. - + diff --git a/docs/js/custom-element/api/graphics-api.js b/docs/js/custom-element/api/graphics-api.js index debedb94..83337533 100644 --- a/docs/js/custom-element/api/graphics-api.js +++ b/docs/js/custom-element/api/graphics-api.js @@ -254,7 +254,7 @@ class GraphicsAPI extends BaseAPI { label.innerHTML = propLabel; wrapper.append(label); slider.parentNode.replaceChild(wrapper, slider); - slider.setAttribute(`class`, `slider`); + slider.classList.add(`slider`); this._sliders[propname] = slider; wrapper.append(slider); let valueField = create(`label`); @@ -597,10 +597,12 @@ class GraphicsAPI extends BaseAPI { this.ctx.restoreStyle(); if (!preserveTransforms) this.resetTransform(); if (this._gridParams) { + this.ctx.cacheStyle(); this.setStroke(this._gridParams.color); this.translate(0.5, 0.5); this.drawGrid(this._gridParams.size); this.translate(-0.5, -0.5); + this.ctx.restoreStyle(); } } diff --git a/docs/js/custom-element/graphics-element.js b/docs/js/custom-element/graphics-element.js index 0916ad1f..7d666087 100644 --- a/docs/js/custom-element/graphics-element.js +++ b/docs/js/custom-element/graphics-element.js @@ -45,6 +45,8 @@ class GraphicsElement extends CustomElement { constructor() { super({ header: false, footer: false }); + this.originalHTML = this.outerHTML; + // Do we load immediately? if (isInViewport(this)) { this.loadSource(); @@ -76,10 +78,13 @@ class GraphicsElement extends CustomElement { getStyle() { return ` :host([hidden]) { display: none; } + :host { max-width: calc(2em + ${this.getAttribute(`width`)}px); } :host style { display: none; } + :host .top-title { display: flex; flex-direction: row; justify-content: space-between; } :host canvas { position: relative; z-index: 1; display: block; margin: auto; border-radius: 0; box-sizing: content-box!important; border: 1px solid lightgrey; } :host canvas:focus { border: 1px solid red; } - :host a.view-source { display: block; position:relative; top: -0.6em; margin-bottom: -0.2em; font-size: 60%; text-decoration: none; } + :host a.view-source { font-size: 60%; text-decoration: none; } + :host button.reset { font-size: 0.5em; } :host label { display: block; font-style:italic; font-size: 0.9em; text-align: right; } `; } @@ -183,7 +188,10 @@ class GraphicsElement extends CustomElement { rerender = true; } - const uid = `bg-uid-${Date.now()}-${`${Math.random()}`.replace(`0.`, ``)}`; + const uid = (this.uid = `bg-uid-${Date.now()}-${`${Math.random()}`.replace( + `0.`, + `` + )}`); window[uid] = this; // Step 1: fix the imports. This is ... a bit of work. @@ -244,6 +252,13 @@ class GraphicsElement extends CustomElement { if (rerender) this.render(); } + /** + * Reload this graphics element the brute force way. + */ + async reset() { + this.outerHTML = this.originalHTML; + } + /** * Hand the a reference to the "Example" instance that it built. */ @@ -308,12 +323,23 @@ class GraphicsElement extends CustomElement { if (this.canvas) slotParent.insertBefore(this.canvas, this._slot); if (this.label) slotParent.insertBefore(this.label, this._slot); - const a = document.createElement("a"); - a.classList.add("view-source"); + const toptitle = document.createElement(`div`); + toptitle.classList.add(`top-title`); + + const a = document.createElement(`a`); + a.classList.add(`view-source`); a.textContent = `view source`; a.href = this.src; a.target = `_blank`; - if (this.label) slotParent.insertBefore(a, this.canvas); + toptitle.append(a); + + const r = document.createElement(`button`); + r.classList.add(`reset`); + r.textContent = `reset`; + r.addEventListener(`click`, () => this.reset()); + toptitle.append(r); + + if (this.label) slotParent.insertBefore(toptitle, this.canvas); } } diff --git a/docs/zh-CN/index.html b/docs/zh-CN/index.html index 8391e944..492f4a4d 100644 --- a/docs/zh-CN/index.html +++ b/docs/zh-CN/index.html @@ -1389,7 +1389,7 @@ function drawCurve(points[], t): Scripts are disabled. Showing fallback image. - + @@ -3384,12 +3384,11 @@ lli = function(line1, line2): Scripts are disabled. Showing fallback image. - + - - +

@@ -4137,7 +4136,7 @@ for (coordinate, index) in LUT: Scripts are disabled. Showing fallback image. - + @@ -4169,7 +4168,7 @@ for (coordinate, index) in LUT: Scripts are disabled. Showing fallback image. - + @@ -5460,7 +5459,7 @@ for p = 1 to points.length-3 (inclusive): Scripts are disabled. Showing fallback image. - + @@ -5482,7 +5481,7 @@ for p = 1 to points.length-3 (inclusive): Scripts are disabled. Showing fallback image. - + @@ -5652,7 +5651,7 @@ for(let L = 1; L <= order; L++) { Scripts are disabled. Showing fallback image. - + @@ -5677,7 +5676,7 @@ for(let L = 1; L <= order; L++) { Scripts are disabled. Showing fallback image. - + @@ -5698,7 +5697,7 @@ for(let L = 1; L <= order; L++) { Scripts are disabled. Showing fallback image. - + @@ -5721,7 +5720,7 @@ for(let L = 1; L <= order; L++) { Scripts are disabled. Showing fallback image. - +