webgl2-sdf 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/index.min.js +1 -1
- package/node/bezier/is-cubic-obtuse.js +2 -2
- package/node/bezier/is-cubic-obtuse.js.map +1 -1
- package/node/bezier/is-quad-obtuse.js +2 -2
- package/node/bezier/is-quad-obtuse.js.map +1 -1
- package/node/bezier/split-by-deviation-from-straight-line-quad.js +3 -3
- package/node/bezier/split-by-deviation-from-straight-line-quad.js.map +1 -1
- package/node/bezier/split-into-line-segments.js +3 -3
- package/node/bezier/split-into-line-segments.js.map +1 -1
- package/node/generate-sdf.d.ts +3 -2
- package/node/generate-sdf.js +5 -6
- package/node/generate-sdf.js.map +1 -1
- package/node/index.d.ts +2 -0
- package/node/index.js +2 -0
- package/node/index.js.map +1 -1
- package/node/main-program.js +0 -1
- package/node/main-program.js.map +1 -1
- package/node/prepare-buffers.js +4 -6
- package/node/prepare-buffers.js.map +1 -1
- package/node/shaders/main.fragment.js +1 -1
- package/node/shaders/main.fragment.js.map +1 -1
- package/node/shaders/main.vertex.d.ts +1 -1
- package/node/shaders/main.vertex.js +1 -2
- package/node/shaders/main.vertex.js.map +1 -1
- package/node/types/gl-context.d.ts +0 -1
- package/node/types/program.d.ts +4 -2
- package/node/utils/calc-circs.js +3 -3
- package/node/utils/calc-circs.js.map +1 -1
- package/node/utils/clip-line-segment-to-grid.d.ts +2 -2
- package/node/utils/clip-line-segment-to-grid.js +2 -5
- package/node/utils/clip-line-segment-to-grid.js.map +1 -1
- package/node/utils/clip-line-segment-to-strips.d.ts +2 -3
- package/node/utils/clip-line-segment-to-strips.js +6 -58
- package/node/utils/clip-line-segment-to-strips.js.map +1 -1
- package/node/utils/create-empty-grid.d.ts +1 -1
- package/node/utils/create-empty-grid.js +1 -1
- package/node/utils/create-empty-grid.js.map +1 -1
- package/node/utils/find-close-cells.d.ts +1 -1
- package/node/utils/find-close-cells.js +17 -73
- package/node/utils/find-close-cells.js.map +1 -1
- package/node/utils/find-crossing-cells.d.ts +1 -1
- package/node/utils/find-crossing-cells.js +1 -16
- package/node/utils/find-crossing-cells.js.map +1 -1
- package/node/utils/jump-idx.js +21 -19
- package/node/utils/jump-idx.js.map +1 -1
- package/node/webgl-utils/free-gl-context.d.ts +3 -0
- package/node/webgl-utils/free-gl-context.js +26 -0
- package/node/webgl-utils/free-gl-context.js.map +1 -0
- package/node/webgl-utils/get-gl-context.d.ts +3 -3
- package/node/webgl-utils/get-gl-context.js +6 -9
- package/node/webgl-utils/get-gl-context.js.map +1 -1
- package/node/webgl-utils/set-attribute.d.ts +3 -3
- package/node/webgl-utils/set-attribute.js +1 -1
- package/node/webgl-utils/set-attribute.js.map +1 -1
- package/node/webgl-utils/set-uniform-block.d.ts +1 -1
- package/node/webgl-utils/set-uniform-block.js +1 -3
- package/node/webgl-utils/set-uniform-block.js.map +1 -1
- package/node/webgl-utils/set-uniform.d.ts +2 -2
- package/node/webgl-utils/use-program.d.ts +2 -2
- package/node/webgl-utils/use-program.js +14 -4
- package/node/webgl-utils/use-program.js.map +1 -1
- package/package.json +1 -1
- package/src/bezier/is-cubic-obtuse.ts +2 -2
- package/src/bezier/is-quad-obtuse.ts +2 -2
- package/src/bezier/split-by-deviation-from-straight-line-quad.ts +3 -3
- package/src/bezier/split-into-line-segments.ts +3 -3
- package/src/debug-shaders.ts +2 -2
- package/src/generate-sdf.ts +7 -5
- package/src/index.ts +2 -0
- package/src/main-program.ts +0 -1
- package/src/prepare-buffers.ts +5 -6
- package/src/shaders/main.fragment.ts +1 -1
- package/src/shaders/main.vertex.ts +1 -2
- package/src/types/gl-context.ts +0 -1
- package/src/types/program.ts +4 -2
- package/src/utils/calc-circs.ts +3 -5
- package/src/utils/clip-line-segment-to-grid.ts +3 -8
- package/src/utils/clip-line-segment-to-strips.ts +7 -74
- package/src/utils/create-empty-grid.ts +2 -2
- package/src/utils/find-close-cells.ts +31 -91
- package/src/utils/find-crossing-cells.ts +2 -19
- package/src/utils/jump-idx.ts +26 -21
- package/src/webgl-utils/free-gl-context.ts +35 -0
- package/src/webgl-utils/get-gl-context.ts +9 -12
- package/src/webgl-utils/set-attribute.ts +4 -4
- package/src/webgl-utils/set-uniform-block.ts +2 -4
- package/src/webgl-utils/set-uniform.ts +2 -2
- package/src/webgl-utils/use-program.ts +19 -8
- package/node/types/strip.d.ts +0 -8
- package/node/types/strip.js +0 -2
- package/node/types/strip.js.map +0 -1
- package/node/utils/create-empty-strips.d.ts +0 -7
- package/node/utils/create-empty-strips.js +0 -16
- package/node/utils/create-empty-strips.js.map +0 -1
- package/node/utils/distance-seg-to-p.d.ts +0 -5
- package/node/utils/distance-seg-to-p.js +0 -35
- package/node/utils/distance-seg-to-p.js.map +0 -1
- package/src/types/strip.ts +0 -11
- package/src/utils/create-empty-strips.ts +0 -21
- package/src/utils/path.ts +0 -137
package/src/utils/jump-idx.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { circsCache } from "./calc-circs";
|
|
1
|
+
import { circsCache } from "./calc-circs.js";
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { max, E } = Math;
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -14,10 +14,9 @@ function binarySearchRange<T>(
|
|
|
14
14
|
|
|
15
15
|
let mid = 0;
|
|
16
16
|
while (min <= max) {
|
|
17
|
-
mid = (min + max) >>> 1
|
|
17
|
+
mid = (min + max) >>> 1;
|
|
18
18
|
const midVal = circsCache[mid].from;
|
|
19
19
|
if (midVal === v) {
|
|
20
|
-
// return [min,mid,max];
|
|
21
20
|
return mid;
|
|
22
21
|
} else if (v > midVal) {
|
|
23
22
|
min = mid + 1;
|
|
@@ -26,11 +25,26 @@ function binarySearchRange<T>(
|
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
// return [min,mid,max];
|
|
30
28
|
return mid;
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
|
|
32
|
+
function jumpIdx(
|
|
33
|
+
c: number) {
|
|
34
|
+
|
|
35
|
+
let idx = binarySearchRange(c);
|
|
36
|
+
|
|
37
|
+
c = max(0, c);
|
|
38
|
+
if (idx === 0) { return 0; }
|
|
39
|
+
|
|
40
|
+
while (circsCache[idx].from === circsCache[idx - 1].from) {
|
|
41
|
+
idx--;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return idx;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
34
48
|
// const [Q,R] = [10.606601717798213, 35.531676008879735];
|
|
35
49
|
// const [A1,B1,F1] = [102.42126, 0.153169, -117.56077];
|
|
36
50
|
// const [A2,B2,C2,D2,F2] = [-0.000660087, 0.388148, 841.25744, -0.0529616, -1089.49916];
|
|
@@ -55,30 +69,21 @@ function binarySearchRange<T>(
|
|
|
55
69
|
// }
|
|
56
70
|
|
|
57
71
|
|
|
58
|
-
function jumpIdx(
|
|
59
|
-
c: number) {
|
|
60
|
-
|
|
61
|
-
let idx = binarySearchRange(c);
|
|
62
|
-
|
|
63
|
-
c = max(0, c);
|
|
64
|
-
while (idx !== 0 && circsCache[idx].from >= c) { idx--; }
|
|
65
|
-
while (idx < circsCache.length - 2 && circsCache[idx + 1].from < c) { idx++; }
|
|
66
|
-
|
|
67
|
-
return idx;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
72
|
export { jumpIdx }
|
|
72
73
|
|
|
73
74
|
|
|
74
75
|
// Quokka tests
|
|
75
|
-
//
|
|
76
|
+
// circsCache.slice(0,10);//?
|
|
77
|
+
// circsCache.slice(0,30).map(c => c.from);//?
|
|
78
|
+
// circsCache[5].from;//?
|
|
76
79
|
// circsCache[12].from;//?
|
|
77
80
|
// circsCache[15].from;//?
|
|
78
81
|
// // circsCache.length;//?
|
|
79
82
|
|
|
80
|
-
//
|
|
81
|
-
//
|
|
83
|
+
// jumpIdxOld(1.5811388300841898);//?
|
|
84
|
+
// const v = (53.08771209782213 - Math.SQRT2*24.09375)/24.09375;//?
|
|
85
|
+
// jumpIdx(v);//?
|
|
86
|
+
// circsCache[8].from;//?
|
|
82
87
|
// binarySearchRange(1.5811388300841898);//?
|
|
83
88
|
|
|
84
89
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { GlContext } from '../types/gl-context.js';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function freeGlContext(
|
|
5
|
+
glContext: GlContext | undefined) {
|
|
6
|
+
|
|
7
|
+
if (glContext === undefined) { return; }
|
|
8
|
+
|
|
9
|
+
const { gl, programs, textures } = glContext;
|
|
10
|
+
|
|
11
|
+
for (let key in programs) {
|
|
12
|
+
const { attributes, fragmentShader, vertexShader, uniformBlocks, program } = programs[key];
|
|
13
|
+
|
|
14
|
+
for (let key in uniformBlocks) {
|
|
15
|
+
const { buf } = uniformBlocks[key];
|
|
16
|
+
gl.deleteBuffer(buf);
|
|
17
|
+
}
|
|
18
|
+
for (let key in attributes) {
|
|
19
|
+
const { buf } = attributes[key];
|
|
20
|
+
gl.deleteBuffer(buf);
|
|
21
|
+
}
|
|
22
|
+
gl.deleteShader(fragmentShader);
|
|
23
|
+
gl.deleteShader(vertexShader);
|
|
24
|
+
gl.deleteProgram(program);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
for (let key in textures) {
|
|
28
|
+
const { tex } = textures[key];
|
|
29
|
+
gl.deleteTexture(tex);
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
export { freeGlContext }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Texture } from "../types/texture";
|
|
2
|
-
import type { Program } from "../types/program";
|
|
3
|
-
import type { GlContext } from "../types/gl-context";
|
|
1
|
+
import type { Texture } from "../types/texture.js";
|
|
2
|
+
import type { Program } from "../types/program.js";
|
|
3
|
+
import type { GlContext } from "../types/gl-context.js";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
const cache = new WeakMap<WebGL2RenderingContext, GlContext>();
|
|
@@ -13,7 +13,7 @@ const cache = new WeakMap<WebGL2RenderingContext, GlContext>();
|
|
|
13
13
|
* @param gl the `WebGL2RenderingContext` context to wrap
|
|
14
14
|
* @param callback
|
|
15
15
|
*/
|
|
16
|
-
function
|
|
16
|
+
function getWebGlContext(
|
|
17
17
|
gl: WebGL2RenderingContext): GlContext {
|
|
18
18
|
|
|
19
19
|
{
|
|
@@ -23,19 +23,17 @@ function getWebGLContext<T>(
|
|
|
23
23
|
|
|
24
24
|
const programs: { [index:string]: Program } = {};
|
|
25
25
|
const textures: { [index:string]: Texture } = {};
|
|
26
|
-
const framebufferStack: WebGLFramebuffer[] = [];
|
|
27
26
|
|
|
28
27
|
gl.canvas.addEventListener('webglcontextlost', e => {
|
|
29
|
-
|
|
28
|
+
onContextLoss();
|
|
30
29
|
e.preventDefault();
|
|
31
30
|
}, false);
|
|
32
31
|
|
|
33
32
|
const glContext: GlContext = {
|
|
34
33
|
gl,
|
|
35
|
-
onContextLoss
|
|
34
|
+
onContextLoss,
|
|
36
35
|
textures,
|
|
37
|
-
programs
|
|
38
|
-
framebufferStack
|
|
36
|
+
programs
|
|
39
37
|
};
|
|
40
38
|
|
|
41
39
|
cache.set(gl, glContext);
|
|
@@ -45,10 +43,9 @@ function getWebGLContext<T>(
|
|
|
45
43
|
|
|
46
44
|
////////////////////////
|
|
47
45
|
|
|
48
|
-
function
|
|
46
|
+
function onContextLoss() {
|
|
49
47
|
deleteAllProps(programs);
|
|
50
48
|
deleteAllProps(textures);
|
|
51
|
-
framebufferStack.length = 0;
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
51
|
|
|
@@ -58,4 +55,4 @@ function deleteAllProps(o: { [key:string] : unknown }) {
|
|
|
58
55
|
}
|
|
59
56
|
|
|
60
57
|
|
|
61
|
-
export {
|
|
58
|
+
export { getWebGlContext }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Program } from "../types/program";
|
|
2
|
-
import { GLattrType } from "../types/gl-type";
|
|
3
|
-
import { GLusage } from "../types/gl-usage";
|
|
1
|
+
import { Program } from "../types/program.js";
|
|
2
|
+
import { GLattrType } from "../types/gl-type.js";
|
|
3
|
+
import { GLusage } from "../types/gl-usage.js";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
const {
|
|
@@ -45,7 +45,7 @@ function setAttribute(
|
|
|
45
45
|
const { gl, attributes } = program;
|
|
46
46
|
|
|
47
47
|
const attr = attributes[name] = attributes[name] ?? {
|
|
48
|
-
buf: gl.createBuffer(),
|
|
48
|
+
buf: gl.createBuffer(),
|
|
49
49
|
loc: gl.getAttribLocation(program.program, name),
|
|
50
50
|
data: null
|
|
51
51
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Program } from "../types/program";
|
|
1
|
+
import { Program } from "../types/program.js";
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -34,10 +34,8 @@ function setUniformBlock(
|
|
|
34
34
|
|
|
35
35
|
const { buf } = uniformBlock;
|
|
36
36
|
|
|
37
|
-
gl.bufferData(gl.UNIFORM_BUFFER, buffer, gl.
|
|
38
|
-
// gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
37
|
+
gl.bufferData(gl.UNIFORM_BUFFER, buffer, gl.STATIC_DRAW);
|
|
39
38
|
gl.bindBufferBase(gl.UNIFORM_BUFFER, bindingPoint, buf);
|
|
40
|
-
// gl.bindBufferRange(gl.UNIFORM_BUFFER, bindingPoint, ubo, 0, sizeInBytes);
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Program } from "../types/program";
|
|
2
|
-
import type { Attribute } from "../types/attribute";
|
|
3
|
-
import type { UniformBlock } from "./uniform-block";
|
|
4
|
-
import type { GlContext } from "../types/gl-context";
|
|
5
|
-
import { compileShader } from "./compile-shader";
|
|
1
|
+
import type { Program } from "../types/program.js";
|
|
2
|
+
import type { Attribute } from "../types/attribute.js";
|
|
3
|
+
import type { UniformBlock } from "./uniform-block.js";
|
|
4
|
+
import type { GlContext } from "../types/gl-context.js";
|
|
5
|
+
import { compileShader } from "./compile-shader.js";
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -35,11 +35,22 @@ function initProgram(
|
|
|
35
35
|
const uniformBlocks: { [index:string]: UniformBlock } = {};
|
|
36
36
|
|
|
37
37
|
const program = gl.createProgram();
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const vertexShader = compileShader(gl, vert, gl.VERTEX_SHADER);
|
|
39
|
+
const fragmentShader = compileShader(gl, frag, gl.FRAGMENT_SHADER);
|
|
40
|
+
|
|
41
|
+
gl.attachShader(program, vertexShader);
|
|
42
|
+
gl.attachShader(program, fragmentShader);
|
|
40
43
|
gl.linkProgram(program);
|
|
41
44
|
|
|
42
|
-
programs[name] = {
|
|
45
|
+
programs[name] = {
|
|
46
|
+
gl,
|
|
47
|
+
program,
|
|
48
|
+
attributes,
|
|
49
|
+
uniforms,
|
|
50
|
+
uniformBlocks,
|
|
51
|
+
vertexShader,
|
|
52
|
+
fragmentShader
|
|
53
|
+
};
|
|
43
54
|
|
|
44
55
|
return programs[name];
|
|
45
56
|
}
|
package/node/types/strip.d.ts
DELETED
package/node/types/strip.js
DELETED
package/node/types/strip.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strip.js","sourceRoot":"","sources":["../../src/types/strip.ts"],"names":[],"mappings":""}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ROW_COUNT } from "../row-count";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @param count the number of strips
|
|
5
|
-
*/
|
|
6
|
-
// TODO - remove
|
|
7
|
-
function createEmptyStrips() {
|
|
8
|
-
const strips = [];
|
|
9
|
-
for (let v = 0; v < ROW_COUNT; v++) {
|
|
10
|
-
// TODO - simplify
|
|
11
|
-
strips.push({ lineSegs: [] });
|
|
12
|
-
}
|
|
13
|
-
return strips;
|
|
14
|
-
}
|
|
15
|
-
export { createEmptyStrips };
|
|
16
|
-
//# sourceMappingURL=create-empty-strips.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-empty-strips.js","sourceRoot":"","sources":["../../src/utils/create-empty-strips.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC;;;GAGG;AACH,gBAAgB;AAChB,SAAS,iBAAiB;IACtB,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,KAAK,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAC,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,kBAAkB;QAClB,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAGD,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const { min, max, sqrt } = Math;
|
|
2
|
-
/**
|
|
3
|
-
* Returns the minimum distance from the given line segment to the origin.
|
|
4
|
-
*/
|
|
5
|
-
function distanceSegToP(seg, p) {
|
|
6
|
-
const seg0 = seg[0];
|
|
7
|
-
const seg1 = seg[1];
|
|
8
|
-
const _x1 = seg0[0];
|
|
9
|
-
const _y1 = seg0[1];
|
|
10
|
-
const _x2 = seg1[0];
|
|
11
|
-
const _y2 = seg1[1];
|
|
12
|
-
const x = p[0];
|
|
13
|
-
const y = p[1];
|
|
14
|
-
const x1 = _x1 - x;
|
|
15
|
-
const y1 = _y1 - y;
|
|
16
|
-
const x2 = _x2 - x;
|
|
17
|
-
const y2 = _y2 - y;
|
|
18
|
-
// Vector from point 1 to point 2
|
|
19
|
-
const dx = x2 - x1;
|
|
20
|
-
const dy = y2 - y1;
|
|
21
|
-
const lengthSq = dx * dx + dy * dy;
|
|
22
|
-
// Calculate projection parameter t
|
|
23
|
-
// t represents where the closest point lies on the line segment
|
|
24
|
-
// t = 0 means closest point is at seg[0], t = 1 means closest point is at seg[1]
|
|
25
|
-
const t = max(0, min(1, -(x1 * dx + y1 * dy) / lengthSq));
|
|
26
|
-
// Find the closest point on the segment
|
|
27
|
-
const closestX = x1 + t * dx;
|
|
28
|
-
const closestY = y1 + t * dy;
|
|
29
|
-
// Return distance from origin to closest point
|
|
30
|
-
return sqrt(closestX * closestX + closestY * closestY);
|
|
31
|
-
}
|
|
32
|
-
export { distanceSegToP };
|
|
33
|
-
// Quokka tests
|
|
34
|
-
// distanceSegToOrigin([[0,1],[-1,-2]]);//?
|
|
35
|
-
//# sourceMappingURL=distance-seg-to-p.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"distance-seg-to-p.js","sourceRoot":"","sources":["../../src/utils/distance-seg-to-p.ts"],"names":[],"mappings":"AACA,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;AAGhC;;GAEG;AACH,SAAS,cAAc,CACf,GAAe,EACf,CAAW;IAEf,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAEpB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACf,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAEf,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;IACnB,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;IACnB,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;IACnB,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;IAEnB,iCAAiC;IACjC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IACnB,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAEnB,MAAM,QAAQ,GAAG,EAAE,GAAC,EAAE,GAAG,EAAE,GAAC,EAAE,CAAC;IAE/B,mCAAmC;IACnC,gEAAgE;IAChE,iFAAiF;IACjF,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAC,EAAE,GAAG,EAAE,GAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IAEtD,wCAAwC;IACxC,MAAM,QAAQ,GAAG,EAAE,GAAG,CAAC,GAAC,EAAE,CAAC;IAC3B,MAAM,QAAQ,GAAG,EAAE,GAAG,CAAC,GAAC,EAAE,CAAC;IAE3B,+CAA+C;IAC/C,OAAO,IAAI,CAAC,QAAQ,GAAC,QAAQ,GAAG,QAAQ,GAAC,QAAQ,CAAC,CAAC;AACvD,CAAC;AAGD,OAAO,EAAE,cAAc,EAAE,CAAA;AAEzB,eAAe;AACf,2CAA2C"}
|
package/src/types/strip.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ROW_COUNT } from "../row-count";
|
|
2
|
-
import { Strip } from "../types/strip";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @param count the number of strips
|
|
8
|
-
*/
|
|
9
|
-
// TODO - remove
|
|
10
|
-
function createEmptyStrips() {
|
|
11
|
-
const strips: Strip[] = [];
|
|
12
|
-
for (let v=0; v<ROW_COUNT; v++) {
|
|
13
|
-
// TODO - simplify
|
|
14
|
-
strips.push({ lineSegs: [] });
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return strips;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export { createEmptyStrips }
|
package/src/utils/path.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// /**
|
|
3
|
-
// * Find the point on a quadratic bezier curve at t where t is in the range [0, 1]
|
|
4
|
-
// */
|
|
5
|
-
// function pointOnQuadraticBezier (
|
|
6
|
-
// x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, t: number,
|
|
7
|
-
// pointOut: { x: number; y: number }) {
|
|
8
|
-
|
|
9
|
-
// const t2 = 1 - t
|
|
10
|
-
// pointOut.x = t2*t2*x0 + 2*t2*t*x1 + t*t*x2;
|
|
11
|
-
// pointOut.y = t2*t2*y0 + 2*t2*t*y1 + t*t*y2;
|
|
12
|
-
// }
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// /**
|
|
16
|
-
// * Find the point on a cubic bezier curve at t where t is in the range [0, 1]
|
|
17
|
-
// */
|
|
18
|
-
// function pointOnCubicBezier (
|
|
19
|
-
// x0: number, y0: number, x1: number, y1: number,
|
|
20
|
-
// x2: number, y2: number, x3: number, y3: number,
|
|
21
|
-
// t: number,
|
|
22
|
-
// pointOut: { x: number; y: number }) {
|
|
23
|
-
|
|
24
|
-
// const t2 = 1 - t;
|
|
25
|
-
// pointOut.x = t2*t2*t2*x0 + 3*t2*t2*t*x1 + 3*t2*t*t*x2 + t*t*t*x3;
|
|
26
|
-
// pointOut.y = t2*t2*t2*y0 + 3*t2*t2*t*y1 + 3*t2*t*t*y2 + t*t*t*y3;
|
|
27
|
-
// }
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// /**
|
|
31
|
-
// * Parse a path string into its constituent line/curve commands, invoking a callback for each.
|
|
32
|
-
// * @param {string} pathString - An SVG-like path string to parse; should only contain commands: M/L/Q/C/Z
|
|
33
|
-
// * @param {function(
|
|
34
|
-
// * command: 'L'|'Q'|'C',
|
|
35
|
-
// * startX: number,
|
|
36
|
-
// * startY: number,
|
|
37
|
-
// * endX: number,
|
|
38
|
-
// * endY: number,
|
|
39
|
-
// * ctrl1X?: number,
|
|
40
|
-
// * ctrl1Y?: number,
|
|
41
|
-
// * ctrl2X?: number,
|
|
42
|
-
// * ctrl2Y?: number
|
|
43
|
-
// * )} commandCallback - A callback function that will be called once for each parsed path command, passing the
|
|
44
|
-
// * command identifier (only L/Q/C commands) and its numeric arguments.
|
|
45
|
-
// */
|
|
46
|
-
// export function forEachPathCommand(
|
|
47
|
-
// pathString: string, commandCallback: Function) {
|
|
48
|
-
|
|
49
|
-
// const segmentRE = /([MLQCZ])([^MLQCZ]*)/g
|
|
50
|
-
// let match, firstX, firstY, prevX, prevY
|
|
51
|
-
// while ((match = segmentRE.exec(pathString))) {
|
|
52
|
-
// const args = match[2].split(/[,\s]+/)
|
|
53
|
-
// switch (match[1]) {
|
|
54
|
-
// case 'M':
|
|
55
|
-
// prevX = firstX = +args[0]
|
|
56
|
-
// prevY = firstY = +args[1]
|
|
57
|
-
// break
|
|
58
|
-
// case 'L':
|
|
59
|
-
// if (+args[0] !== prevX || +args[1] !== prevY) { // yup, some fonts have zero-length line commands
|
|
60
|
-
// commandCallback('L', prevX, prevY, (prevX = +args[0]), (prevY = +args[1]))
|
|
61
|
-
// }
|
|
62
|
-
// break
|
|
63
|
-
// case 'Q': {
|
|
64
|
-
// commandCallback('Q', prevX, prevY, (prevX = +args[2]), (prevY = +args[3]), +args[0], +args[1])
|
|
65
|
-
// break
|
|
66
|
-
// }
|
|
67
|
-
// case 'C': {
|
|
68
|
-
// commandCallback('C', prevX, prevY, (prevX = +args[4]), (prevY = +args[5]), +args[0], +args[1], +args[2], +args[3])
|
|
69
|
-
// break
|
|
70
|
-
// }
|
|
71
|
-
// case 'Z':
|
|
72
|
-
// if (prevX !== firstX || prevY !== firstY) {
|
|
73
|
-
// commandCallback('L', prevX, prevY, firstX, firstY)
|
|
74
|
-
// }
|
|
75
|
-
// break
|
|
76
|
-
// }
|
|
77
|
-
// }
|
|
78
|
-
// }
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
// /**
|
|
82
|
-
// * Convert a path string to a series of straight line segments
|
|
83
|
-
// * @param {string} pathString - An SVG-like path string to parse; should only contain commands: M/L/Q/C/Z
|
|
84
|
-
// * @param {function(x1:number, y1:number, x2:number, y2:number)} segmentCallback - A callback
|
|
85
|
-
// * function that will be called once for every line segment
|
|
86
|
-
// * @param {number} [curvePoints] - How many straight line segments to use when approximating a
|
|
87
|
-
// * bezier curve in the path. Defaults to 16.
|
|
88
|
-
// */
|
|
89
|
-
// export function pathToLineSegments (pathString: any, segmentCallback: any, curvePoints = 16) {
|
|
90
|
-
// const tempPoint = { x: 0, y: 0 }
|
|
91
|
-
// forEachPathCommand(
|
|
92
|
-
// pathString,
|
|
93
|
-
// (command: any, startX: any, startY: any, endX: any, endY: any,
|
|
94
|
-
// ctrl1X: any, ctrl1Y: any, ctrl2X: any, ctrl2Y: any) => {
|
|
95
|
-
|
|
96
|
-
// switch (command) {
|
|
97
|
-
// case 'L':
|
|
98
|
-
// segmentCallback(startX, startY, endX, endY);
|
|
99
|
-
// break;
|
|
100
|
-
// case 'Q': {
|
|
101
|
-
// let prevCurveX = startX
|
|
102
|
-
// let prevCurveY = startY
|
|
103
|
-
// for (let i = 1; i < curvePoints; i++) {
|
|
104
|
-
// pointOnQuadraticBezier(
|
|
105
|
-
// startX, startY,
|
|
106
|
-
// ctrl1X, ctrl1Y,
|
|
107
|
-
// endX, endY,
|
|
108
|
-
// i / (curvePoints - 1),
|
|
109
|
-
// tempPoint
|
|
110
|
-
// )
|
|
111
|
-
// segmentCallback(prevCurveX, prevCurveY, tempPoint.x, tempPoint.y)
|
|
112
|
-
// prevCurveX = tempPoint.x
|
|
113
|
-
// prevCurveY = tempPoint.y
|
|
114
|
-
// }
|
|
115
|
-
// break;
|
|
116
|
-
// }
|
|
117
|
-
// case 'C': {
|
|
118
|
-
// let prevCurveX = startX
|
|
119
|
-
// let prevCurveY = startY
|
|
120
|
-
// for (let i = 1; i < curvePoints; i++) {
|
|
121
|
-
// pointOnCubicBezier(
|
|
122
|
-
// startX, startY,
|
|
123
|
-
// ctrl1X, ctrl1Y,
|
|
124
|
-
// ctrl2X, ctrl2Y,
|
|
125
|
-
// endX, endY,
|
|
126
|
-
// i / (curvePoints - 1),
|
|
127
|
-
// tempPoint
|
|
128
|
-
// )
|
|
129
|
-
// segmentCallback(prevCurveX, prevCurveY, tempPoint.x, tempPoint.y)
|
|
130
|
-
// prevCurveX = tempPoint.x
|
|
131
|
-
// prevCurveY = tempPoint.y
|
|
132
|
-
// }
|
|
133
|
-
// break
|
|
134
|
-
// }
|
|
135
|
-
// }
|
|
136
|
-
// });
|
|
137
|
-
// }
|