web-annotation-renderer 0.6.0 → 0.6.2
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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +52 -51
- package/dist/index.js.map +1 -1
- package/dist/index10.cjs +1 -1
- package/dist/index10.cjs.map +1 -1
- package/dist/index10.js +13 -210
- package/dist/index10.js.map +1 -1
- package/dist/index11.cjs +1 -1
- package/dist/index11.cjs.map +1 -1
- package/dist/index11.js +50 -13
- package/dist/index11.js.map +1 -1
- package/dist/index12.cjs +1 -1
- package/dist/index12.cjs.map +1 -1
- package/dist/index12.js +155 -48
- package/dist/index12.js.map +1 -1
- package/dist/index13.cjs +1 -1
- package/dist/index13.cjs.map +1 -1
- package/dist/index13.js +34 -169
- package/dist/index13.js.map +1 -1
- package/dist/index14.cjs +1 -1
- package/dist/index14.cjs.map +1 -1
- package/dist/index14.js +65 -28
- package/dist/index14.js.map +1 -1
- package/dist/index15.cjs +1 -1
- package/dist/index15.cjs.map +1 -1
- package/dist/index15.js +33 -71
- package/dist/index15.js.map +1 -1
- package/dist/index16.cjs +1 -1
- package/dist/index16.cjs.map +1 -1
- package/dist/index16.js +77 -22
- package/dist/index16.js.map +1 -1
- package/dist/index17.cjs +1 -1
- package/dist/index17.cjs.map +1 -1
- package/dist/index17.js +31 -52
- package/dist/index17.js.map +1 -1
- package/dist/index18.cjs +1 -1
- package/dist/index18.cjs.map +1 -1
- package/dist/index18.js +22 -23
- package/dist/index18.js.map +1 -1
- package/dist/index2.cjs +1 -1
- package/dist/index2.cjs.map +1 -1
- package/dist/index2.js +5 -6
- package/dist/index2.js.map +1 -1
- package/dist/index21.cjs +1 -1
- package/dist/index21.cjs.map +1 -1
- package/dist/index21.js +48 -27
- package/dist/index21.js.map +1 -1
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +1 -1
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +1 -1
- package/dist/index29.cjs +1 -1
- package/dist/index29.cjs.map +1 -1
- package/dist/index29.js +70 -4
- package/dist/index29.js.map +1 -1
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +1 -1
- package/dist/index30.cjs +2 -0
- package/dist/index30.cjs.map +1 -0
- package/dist/index30.js +8 -0
- package/dist/index30.js.map +1 -0
- package/dist/index31.cjs +2 -0
- package/dist/index31.cjs.map +1 -0
- package/dist/index31.js +995 -0
- package/dist/index31.js.map +1 -0
- package/dist/index5.cjs +1 -1
- package/dist/index5.cjs.map +1 -1
- package/dist/index5.js +189 -80
- package/dist/index5.js.map +1 -1
- package/dist/index6.cjs +1 -1
- package/dist/index6.cjs.map +1 -1
- package/dist/index6.js +18 -60
- package/dist/index6.js.map +1 -1
- package/dist/index7.cjs +1 -1
- package/dist/index7.cjs.map +1 -1
- package/dist/index7.js +17 -17
- package/dist/index7.js.map +1 -1
- package/dist/index8.cjs +1 -1
- package/dist/index8.cjs.map +1 -1
- package/dist/index8.js +125 -16
- package/dist/index8.js.map +1 -1
- package/dist/index9.cjs +1 -1
- package/dist/index9.cjs.map +1 -1
- package/dist/index9.js +201 -118
- package/dist/index9.js.map +1 -1
- package/package.json +4 -2
package/dist/index15.js
CHANGED
|
@@ -1,78 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const e = [];
|
|
7
|
-
for (let r = 0; r < n.length - 1; r++) {
|
|
8
|
-
const [a, o] = n[r], [g, m] = n[r + 1];
|
|
9
|
-
e.push([a, o]);
|
|
10
|
-
for (let s = 1; s <= t; s++) {
|
|
11
|
-
const c = s / (t + 1);
|
|
12
|
-
e.push([a + (g - a) * c, o + (m - o) * c]);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return e.push(n[n.length - 1]), e;
|
|
16
|
-
}
|
|
17
|
-
function F(n, t, e) {
|
|
18
|
-
return n.map(([r, a]) => [(t + r) * e, a * e]);
|
|
19
|
-
}
|
|
20
|
-
function A(n, t) {
|
|
21
|
-
const { id: e, start: r, end: a, content: o, x: g, y: m, fontSize: s } = n;
|
|
22
|
-
if (!o || o.length === 0)
|
|
1
|
+
import { roughLine as L, hashSeed as M } from "./index29.js";
|
|
2
|
+
const o = 1e3;
|
|
3
|
+
function R(h, n) {
|
|
4
|
+
const { id: e, start: r, end: g, quads: s } = h;
|
|
5
|
+
if (!s || s.length === 0)
|
|
23
6
|
return [];
|
|
24
|
-
const
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
for (let i = 0; i < p.length; i++) {
|
|
40
|
-
let f = p[i].points || [];
|
|
41
|
-
if (f.length < 2) continue;
|
|
42
|
-
P > 0 && (f = q(f, P));
|
|
43
|
-
let w = F(f, u, $), z = null;
|
|
44
|
-
(t.pressure?.taperIn > 0 || t.pressure?.taperOut > 0) && (z = X(w, t.pressure));
|
|
45
|
-
let d, D;
|
|
46
|
-
if (E === "parallel")
|
|
47
|
-
d = x, D = G;
|
|
48
|
-
else {
|
|
49
|
-
const C = S / O;
|
|
50
|
-
d = x + i * C, D = d + C;
|
|
7
|
+
const u = [], f = g - r, l = s.length, i = f / l, p = n.roughness ?? 1, S = n.bowing ?? 1, m = n.curveFitting ?? 0.95, q = n.curveStepCount ?? 9, C = n.maxRandomnessOffset ?? 2, b = n.disableMultiStroke ?? !1;
|
|
8
|
+
for (let t = 0; t < s.length; t++) {
|
|
9
|
+
const w = s[t], { x: a, y: k, w: v, h: x } = w, c = k + x, $ = L(
|
|
10
|
+
a * o,
|
|
11
|
+
c * o,
|
|
12
|
+
(a + v) * o,
|
|
13
|
+
c * o,
|
|
14
|
+
{
|
|
15
|
+
roughness: p,
|
|
16
|
+
bowing: S,
|
|
17
|
+
seed: M(`${e}-${t}`),
|
|
18
|
+
curveFitting: m,
|
|
19
|
+
curveStepCount: q,
|
|
20
|
+
maxRandomnessOffset: C,
|
|
21
|
+
disableMultiStroke: b
|
|
51
22
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
color: t.color || "rgba(220, 20, 60, 1.0)",
|
|
63
|
-
width: t.width || 2,
|
|
64
|
-
lineCap: t.lineCap || "round",
|
|
65
|
-
pressures: z,
|
|
66
|
-
uniformScale: !0
|
|
67
|
-
// Preserve aspect ratio when rendering
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
u += b + 0.18;
|
|
23
|
+
).map(([E, F]) => [E / o, F / o]), d = r + t * i, D = d + i;
|
|
24
|
+
u.push({
|
|
25
|
+
id: `${e}-${t}`,
|
|
26
|
+
points: $,
|
|
27
|
+
start: d,
|
|
28
|
+
end: D,
|
|
29
|
+
color: n.color || "rgba(0, 0, 255, 0.8)",
|
|
30
|
+
width: n.width || 2,
|
|
31
|
+
lineCap: n.lineCap || "round"
|
|
32
|
+
});
|
|
71
33
|
}
|
|
72
|
-
return
|
|
34
|
+
return u;
|
|
73
35
|
}
|
|
74
36
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
37
|
+
R as default,
|
|
38
|
+
R as underlineToStrokes
|
|
77
39
|
};
|
|
78
40
|
//# sourceMappingURL=index15.js.map
|
package/dist/index15.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index15.js","sources":["../src/converters/text.js"],"sourcesContent":["/**\n * Text Converter - Converts text annotations to stroke commands\n *\n * Transforms text content into stroke paths for each character,\n * using single-stroke font glyphs for smooth writing animation.\n *\n * @module converters/text\n */\n\nimport { applyPressure } from \"../pen/effects.js\";\nimport { resolveGlyph } from \"./glyphResolver.js\";\n\n/**\n * Subdivide a path by adding intermediate points between existing points.\n * This creates smoother interpolation during progressive rendering.\n *\n * @param {Array<[number, number]>} points - Original path points\n * @param {number} subdivisions - Number of points to add between each pair (default: 2)\n * @returns {Array<[number, number]>} Subdivided path with more points\n */\nfunction subdividePath(points, subdivisions = 2) {\n if (points.length < 2 || subdivisions < 1) {\n return points;\n }\n\n const result = [];\n\n for (let i = 0; i < points.length - 1; i++) {\n const [x1, y1] = points[i];\n const [x2, y2] = points[i + 1];\n\n // Add the start point\n result.push([x1, y1]);\n\n // Add intermediate points\n for (let j = 1; j <= subdivisions; j++) {\n const t = j / (subdivisions + 1);\n result.push([x1 + (x2 - x1) * t, y1 + (y2 - y1) * t]);\n }\n }\n\n // Add the final point\n result.push(points[points.length - 1]);\n\n return result;\n}\n\n\n/**\n * Scales glyph points by fontSize scale factor\n *\n * Glyph points are in normalized space where:\n * - X is 0 to charWidth (already scaled within the glyph)\n * - Y is 0 to ~1.0 (baseline at 0.8, cap height at 0)\n *\n * This scales them to the target size, but does NOT add the base position.\n * The base position is stored separately to allow correct rendering with\n * mixed coordinate systems (position in page coords, offsets in uniform space).\n *\n * @param {Array<[number, number]>} points - Glyph points in normalized space\n * @param {number} offsetX - X offset from base position (character offset within text)\n * @param {number} scale - Scale factor based on fontSize\n * @returns {Array<[number, number]>} Scaled offset points (not absolute positions)\n */\nfunction scaleGlyphPoints(points, offsetX, scale) {\n // Scale points and add character offset (in uniform space)\n return points.map(([px, py]) => [(offsetX + px) * scale, py * scale]);\n}\n\n/**\n * Converts a text annotation to stroke commands\n *\n * Each character in the content becomes one or more strokes.\n * Characters are staggered in timing to create a writing effect.\n * Multi-path characters (like 'i', 'j', '!') use pathTiming to\n * control whether paths are drawn sequentially or in parallel.\n *\n * @param {Object} annotation - Text annotation object\n * @param {string} annotation.id - Unique identifier\n * @param {number} annotation.start - Start time in seconds\n * @param {number} annotation.end - End time in seconds\n * @param {string} annotation.content - Text content to render\n * @param {number} annotation.x - X position (normalized 0-1)\n * @param {number} annotation.y - Y position (normalized 0-1)\n * @param {number} [annotation.fontSize=16] - Font size in pixels\n * @param {Object} [annotation.style] - Optional style overrides\n * @param {Object} style - Resolved style configuration\n * @param {string} style.color - Stroke color\n * @param {number} style.width - Stroke width in pixels\n * @param {number} [style.fontSize=16] - Default font size\n * @param {string} [style.lineCap='round'] - Line cap style\n * @param {Object} [style.jitter] - Jitter configuration\n * @param {Object} [style.pressure] - Pressure configuration\n * @param {number} [style.subdivisions=2] - Path subdivision level\n * @returns {Array<Object>} Array of stroke commands\n */\nexport function textToStrokes(annotation, style) {\n const { id, start, end, content, x, y, fontSize: annotFontSize } = annotation;\n\n if (!content || content.length === 0) {\n return [];\n }\n\n const strokes = [];\n const totalDuration = end - start;\n const fontSize = annotFontSize || style.fontSize || 16;\n const subdivisions = style.subdivisions ?? 2;\n\n // Scale factor: convert fontSize (pixels) to normalized coordinates\n // Assuming a reference viewport of ~1000px\n const scale = fontSize / 1000;\n\n // Track character offset from base position (in glyph units, not page coords)\n let charOffsetX = 0;\n\n // Calculate timing per character\n const charCount = content.length;\n const charDuration = totalDuration / charCount;\n\n for (let charIndex = 0; charIndex < content.length; charIndex++) {\n const char = content[charIndex];\n const glyph = resolveGlyph(char);\n\n if (!glyph) {\n // Skip unknown characters, but advance position with default width\n charOffsetX += 0.5 + 0.18; // default width + spacing (in glyph units)\n continue;\n }\n\n const charWidth = glyph.width || 0.5;\n const charPaths = glyph.paths || [];\n const pathTiming = glyph.pathTiming || \"sequential\";\n\n // Skip if no paths (e.g., space character)\n if (charPaths.length === 0) {\n charOffsetX += charWidth + 0.18;\n continue;\n }\n\n // Calculate timing for this character's paths\n const charStart = start + charIndex * charDuration;\n const charEnd = charStart + charDuration;\n\n // Determine path timing based on pathTiming mode\n const pathCount = charPaths.length;\n\n for (let pathIndex = 0; pathIndex < charPaths.length; pathIndex++) {\n const pathData = charPaths[pathIndex];\n let rawPoints = pathData.points || [];\n\n if (rawPoints.length < 2) continue;\n\n // Apply path subdivision for smoother interpolation\n if (subdivisions > 0) {\n rawPoints = subdividePath(rawPoints, subdivisions);\n }\n\n // Scale glyph points (offset coordinates, not absolute)\n let points = scaleGlyphPoints(rawPoints, charOffsetX, scale);\n\n // Calculate pressure values if configured\n let pressures = null;\n if (style.pressure?.taperIn > 0 || style.pressure?.taperOut > 0) {\n pressures = applyPressure(points, style.pressure);\n }\n\n // Calculate path timing based on pathTiming mode\n let pathStart, pathEnd;\n\n if (pathTiming === \"parallel\") {\n // All paths drawn simultaneously during character duration\n pathStart = charStart;\n pathEnd = charEnd;\n } else {\n // Sequential: each path gets a portion of character duration\n const pathDuration = charDuration / pathCount;\n pathStart = charStart + pathIndex * pathDuration;\n pathEnd = pathStart + pathDuration;\n }\n\n strokes.push({\n id: `${id}-${charIndex}-${pathIndex}`,\n points, // Offset coordinates from baseX/baseY (uniform space)\n baseX: x, // Base X position (width-normalized page coords)\n baseY: y, // Base Y position (height-normalized page coords)\n start: pathStart,\n end: pathEnd,\n color: style.color || \"rgba(220, 20, 60, 1.0)\",\n width: style.width || 2,\n lineCap: style.lineCap || \"round\",\n pressures,\n uniformScale: true, // Preserve aspect ratio when rendering\n });\n }\n\n // Advance offset for next character (in glyph units)\n charOffsetX += charWidth + 0.18; // Add small spacing\n }\n\n return strokes;\n}\n\nexport default textToStrokes;\n"],"names":["subdividePath","points","subdivisions","result","i","x1","y1","x2","y2","j","t","scaleGlyphPoints","offsetX","scale","px","py","textToStrokes","annotation","style","id","start","end","content","x","y","annotFontSize","strokes","totalDuration","fontSize","charOffsetX","charCount","charDuration","charIndex","char","glyph","resolveGlyph","charWidth","charPaths","pathTiming","charStart","charEnd","pathCount","pathIndex","rawPoints","pressures","applyPressure","pathStart","pathEnd","pathDuration"],"mappings":";;AAoBA,SAASA,EAAcC,GAAQC,IAAe,GAAG;AAC/C,MAAID,EAAO,SAAS,KAAKC,IAAe;AACtC,WAAOD;AAGT,QAAME,IAAS,CAAA;AAEf,WAASC,IAAI,GAAGA,IAAIH,EAAO,SAAS,GAAGG,KAAK;A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cesContent":["/**\n * Underline Converter - Converts underline annotations to stroke commands\n *\n * Transforms quads into horizontal stroke paths at the bottom edge\n * that can be rendered progressively on canvas with hand-drawn style.\n *\n * @module converters/underline\n */\n\nimport { roughLine, hashSeed } from '../rough/roughPathExtractor.js';\n\nconst SCALE = 1000;\n\n/**\n * Converts an underline annotation to stroke commands\n *\n * Each quad in the annotation becomes a horizontal stroke at the\n * bottom edge of the quad. Multiple quads are staggered in timing.\n * Uses RoughJS for hand-drawn style.\n *\n * @param {Object} annotation - Underline annotation object\n * @param {string} annotation.id - Unique identifier\n * @param {number} annotation.start - Start time in seconds\n * @param {number} annotation.end - End time in seconds\n * @param {Array<{x: number, y: number, w: number, h: number}>} annotation.quads - Array of quads\n * @param {Object} [annotation.style] - Optional style overrides\n * @param {Object} style - Resolved style configuration\n * @param {string} style.color - Stroke color\n * @param {number} style.width - Stroke width in pixels\n * @param {string} [style.lineCap='round'] - Line cap style\n * @param {number} [style.roughness=1.0] - Hand-drawn roughness\n * @param {number} [style.bowing=1.0] - Line curvature\n * @returns {Array<Object>} Array of stroke commands\n */\nexport function underlineToStrokes(annotation, style) {\n const { id, start, end, quads } = annotation;\n\n if (!quads || quads.length === 0) {\n return [];\n }\n\n const strokes = [];\n const totalDuration = end - start;\n const quadCount = quads.length;\n const quadDuration = totalDuration / quadCount;\n\n const roughness = style.roughness ?? 1.0;\n const bowing = style.bowing ?? 1.0;\n const curveFitting = style.curveFitting ?? 0.95;\n const curveStepCount = style.curveStepCount ?? 9;\n const maxRandomnessOffset = style.maxRandomnessOffset ?? 2;\n const disableMultiStroke = style.disableMultiStroke ?? false;\n\n for (let i = 0; i < quads.length; i++) {\n const quad = quads[i];\n const { x, y, w, h } = quad;\n\n const lineY = y + h;\n\n const roughPoints = roughLine(\n x * SCALE,\n lineY * SCALE,\n (x + w) * SCALE,\n lineY * SCALE,\n {\n roughness,\n bowing,\n seed: hashSeed(`${id}-${i}`),\n curveFitting,\n curveStepCount,\n maxRandomnessOffset,\n disableMultiStroke\n }\n );\n\n const points = roughPoints.map(([px, py]) => [px / SCALE, py / SCALE]);\n\n const quadStart = start + i * quadDuration;\n const quadEnd = quadStart + quadDuration;\n\n strokes.push({\n id: `${id}-${i}`,\n points,\n start: quadStart,\n end: quadEnd,\n color: style.color || 'rgba(0, 0, 255, 0.8)',\n width: style.width || 2,\n lineCap: style.lineCap || 'round'\n });\n }\n\n return strokes;\n}\n\nexport default underlineToStrokes;\n"],"names":["SCALE","underlineToStrokes","annotation","style","id","start","end","quads","strokes","totalDuration","quadCount","quadDuration","roughness","bowing","curveFitting","curveStepCount","maxRandomnessOffset","disableMultiStroke","i","quad","x","y","w","h","lineY","points","roughLine","hashSeed","px","py","quadStart","quadEnd"],"mappings":";AAWA,MAAMA,IAAQ;AAuBP,SAASC,EAAmBC,GAAYC,GAAO;AACpD,QAAM,EAAE,IAAAC,GAAI,OAAAC,GAAO,KAAAC,GAAK,OAAAC,EAAK,IAAKL;AAElC,MAAI,CAACK,KAASA,EAAM,WAAW;AAC7B,WAAO,CAAA;AAGT,QAAMC,IAAU,CAAA,GACVC,IAAgBH,IAAMD,GACtBK,IAAYH,EAAM,QAClBI,IAAeF,IAAgBC,GAE/BE,IAAYT,EAAM,aAAa,GAC/BU,IAASV,EAAM,UAAU,GACzBW,IAAeX,EAAM,gBAAgB,MACrCY,IAAiBZ,EAAM,kBAAkB,GACzCa,IAAsBb,EAAM,uBAAuB,GACnDc,IAAqBd,EAAM,sBAAsB;AAEvD,WAASe,IAAI,GAAGA,IAAIX,EAAM,QAAQW,KAAK;AACrC,UAAMC,IAAOZ,EAAMW,CAAC,GACd,EAAE,GAAAE,GAAG,GAAAC,GAAG,GAAAC,GAAG,GAAAC,EAAC,IAAKJ,GAEjBK,IAAQH,IAAIE,GAkBZE,IAhBcC;AAAA,MAClBN,IAAIpB;AAAA,MACJwB,IAAQxB;AAAA,OACPoB,IAAIE,KAAKtB;AAAA,MACVwB,IAAQxB;AAAA,MACR;AAAA,QACE,WAAAY;AAAA,QACA,QAAAC;AAAA,QACA,MAAMc,EAAS,GAAGvB,CAAE,IAAIc,CAAC,EAAE;AAAA,QAC3B,cAAAJ;AAAA,QACA,gBAAAC;AAAA,QACA,qBAAAC;AAAA,QACA,oBAAAC;AAAA,MACR;AAAA,IACA,EAE+B,IAAI,CAAC,CAACW,GAAIC,CAAE,MAAM,CAACD,IAAK5B,GAAO6B,IAAK7B,CAAK,CAAC,GAE/D8B,IAAYzB,IAAQa,IAAIP,GACxBoB,IAAUD,IAAYnB;AAE5B,IAAAH,EAAQ,KAAK;AAAA,MACX,IAAI,GAAGJ,CAAE,IAAIc,CAAC;AAAA,MACd,QAAAO;AAAA,MACA,OAAOK;AAAA,MACP,KAAKC;AAAA,MACL,OAAO5B,EAAM,SAAS;AAAA,MACtB,OAAOA,EAAM,SAAS;AAAA,MACtB,SAASA,EAAM,WAAW;AAAA,IAChC,CAAK;AAAA,EACH;AAEA,SAAOK;AACT;"}
|
package/dist/index16.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./index29.cjs"),t=1e3;function E(W,n){const{id:i,start:h,end:_,from_x:c,from_y:u,to_x:o,to_y:e}=W;if(typeof c!="number"||typeof u!="number"||typeof o!="number"||typeof e!="number")return[];const d=[],L=_-h,P=L*.7,$=L*.3,m=n.roughness??.8,S=n.bowing??.8,b=n.curveFitting??.95,M=n.curveStepCount??9,w=n.maxRandomnessOffset??2,C=n.disableMultiStroke??!1,k=r.roughLine(c*t,u*t,o*t,e*t,{roughness:m,bowing:S,seed:r.hashSeed(`${i}-line`),curveFitting:b,curveStepCount:M,maxRandomnessOffset:w,disableMultiStroke:C}).map(([s,a])=>[s/t,a/t]);d.push({id:`${i}-0`,points:k,start:h,end:h+P,color:n.color||"rgba(255, 0, 0, 0.8)",width:n.width||2,lineCap:n.lineCap||"round"});const x=Math.sqrt((o-c)**2+(e-u)**2),g=Math.min(x*.2,.03),p=Math.atan2(e-u,o-c),f=Math.PI/6,D=o-g*Math.cos(p-f),R=e-g*Math.sin(p-f),O=o-g*Math.cos(p+f),T=e-g*Math.sin(p+f),q=r.roughLine(o*t,e*t,D*t,R*t,{roughness:m,bowing:S,seed:r.hashSeed(`${i}-left`),curveFitting:b,curveStepCount:M,maxRandomnessOffset:w,disableMultiStroke:C}).map(([s,a])=>[s/t,a/t]),A=r.roughLine(o*t,e*t,O*t,T*t,{roughness:m,bowing:S,seed:r.hashSeed(`${i}-right`),curveFitting:b,curveStepCount:M,maxRandomnessOffset:w,disableMultiStroke:C}).map(([s,a])=>[s/t,a/t]),l=h+P,v=$/2;return d.push({id:`${i}-1`,points:q,start:l,end:l+v,color:n.color||"rgba(255, 0, 0, 0.8)",width:n.width||2,lineCap:n.lineCap||"round"}),d.push({id:`${i}-2`,points:A,start:l,end:l+v,color:n.color||"rgba(255, 0, 0, 0.8)",width:n.width||2,lineCap:n.lineCap||"round"}),d}exports.arrowToStrokes=E;exports.default=E;
|
|
2
2
|
//# sourceMappingURL=index16.cjs.map
|
package/dist/index16.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index16.cjs","sources":["../src/converters/
|
|
1
|
+
{"version":3,"file":"index16.cjs","sources":["../src/converters/arrow.js"],"sourcesContent":["/**\n * Arrow Converter - Converts arrow annotations to stroke commands\n *\n * Transforms arrow data into a line stroke with arrowhead strokes\n * that can be rendered progressively on canvas with hand-drawn style.\n *\n * @module converters/arrow\n */\n\nimport { roughLine, hashSeed } from '../rough/roughPathExtractor.js';\n\nconst SCALE = 1000;\n\n/**\n * Converts an arrow annotation to stroke commands\n *\n * Creates a main line stroke from source to target, followed by\n * two wing strokes forming the arrowhead. Line draws first (70%),\n * then arrowhead (30%).\n *\n * @param {Object} annotation - Arrow annotation object\n * @param {string} annotation.id - Unique identifier\n * @param {number} annotation.start - Start time in seconds\n * @param {number} annotation.end - End time in seconds\n * @param {number} annotation.from_x - Source x position (0-1 normalized)\n * @param {number} annotation.from_y - Source y position (0-1 normalized)\n * @param {number} annotation.to_x - Target x position (0-1 normalized)\n * @param {number} annotation.to_y - Target y position (0-1 normalized)\n * @param {Object} [annotation.style] - Optional style overrides\n * @param {Object} style - Resolved style configuration\n * @param {string} style.color - Stroke color\n * @param {number} style.width - Stroke width in pixels\n * @param {string} [style.lineCap='round'] - Line cap style\n * @returns {Array<Object>} Array of stroke commands\n */\nexport function arrowToStrokes(annotation, style) {\n const { id, start, end, from_x, from_y, to_x, to_y } = annotation;\n\n if (typeof from_x !== 'number' || typeof from_y !== 'number' ||\n typeof to_x !== 'number' || typeof to_y !== 'number') {\n return [];\n }\n\n const strokes = [];\n const totalDuration = end - start;\n const lineDuration = totalDuration * 0.7;\n const headDuration = totalDuration * 0.3;\n\n const roughness = style.roughness ?? 0.8;\n const bowing = style.bowing ?? 0.8;\n const curveFitting = style.curveFitting ?? 0.95;\n const curveStepCount = style.curveStepCount ?? 9;\n const maxRandomnessOffset = style.maxRandomnessOffset ?? 2;\n const disableMultiStroke = style.disableMultiStroke ?? false;\n\n // Main line stroke with RoughJS style\n const roughLinePoints = roughLine(\n from_x * SCALE,\n from_y * SCALE,\n to_x * SCALE,\n to_y * SCALE,\n {\n roughness,\n bowing,\n seed: hashSeed(`${id}-line`),\n curveFitting,\n curveStepCount,\n maxRandomnessOffset,\n disableMultiStroke\n }\n );\n\n const linePoints = roughLinePoints.map(([px, py]) => [px / SCALE, py / SCALE]);\n\n strokes.push({\n id: `${id}-0`,\n points: linePoints,\n start: start,\n end: start + lineDuration,\n color: style.color || 'rgba(255, 0, 0, 0.8)',\n width: style.width || 2,\n lineCap: style.lineCap || 'round'\n });\n\n // Arrow head calculation\n const lineLength = Math.sqrt((to_x - from_x) ** 2 + (to_y - from_y) ** 2);\n const headSize = Math.min(lineLength * 0.2, 0.03);\n const angle = Math.atan2(to_y - from_y, to_x - from_x);\n const headAngle = Math.PI / 6; // 30 degrees\n\n // Left wing end point\n const leftEndX = to_x - headSize * Math.cos(angle - headAngle);\n const leftEndY = to_y - headSize * Math.sin(angle - headAngle);\n\n // Right wing end point\n const rightEndX = to_x - headSize * Math.cos(angle + headAngle);\n const rightEndY = to_y - headSize * Math.sin(angle + headAngle);\n\n // Left wing with RoughJS style\n const roughLeftWing = roughLine(\n to_x * SCALE,\n to_y * SCALE,\n leftEndX * SCALE,\n leftEndY * SCALE,\n {\n roughness,\n bowing,\n seed: hashSeed(`${id}-left`),\n curveFitting,\n curveStepCount,\n maxRandomnessOffset,\n disableMultiStroke\n }\n );\n\n const leftWingPoints = roughLeftWing.map(([px, py]) => [px / SCALE, py / SCALE]);\n\n // Right wing with RoughJS style\n const roughRightWing = roughLine(\n to_x * SCALE,\n to_y * SCALE,\n rightEndX * SCALE,\n rightEndY * SCALE,\n {\n roughness,\n bowing,\n seed: hashSeed(`${id}-right`),\n curveFitting,\n curveStepCount,\n maxRandomnessOffset,\n disableMultiStroke\n }\n );\n\n const rightWingPoints = roughRightWing.map(([px, py]) => [px / SCALE, py / SCALE]);\n\n const headStart = start + lineDuration;\n const wingDuration = headDuration / 2;\n\n strokes.push({\n id: `${id}-1`,\n points: leftWingPoints,\n start: headStart,\n end: headStart + wingDuration,\n color: style.color || 'rgba(255, 0, 0, 0.8)',\n width: style.width || 2,\n lineCap: style.lineCap || 'round'\n });\n\n strokes.push({\n id: `${id}-2`,\n points: rightWingPoints,\n start: headStart,\n end: headStart + wingDuration,\n color: style.color || 'rgba(255, 0, 0, 0.8)',\n width: style.width || 2,\n lineCap: style.lineCap || 'round'\n });\n\n return strokes;\n}\n\nexport default arrowToStrokes;\n"],"names":["SCALE","arrowToStrokes","annotation","style","id","start","end","from_x","from_y","to_x","to_y","strokes","totalDuration","lineDuration","headDuration","roughness","bowing","curveFitting","curveStepCount","maxRandomnessOffset","disableMultiStroke","linePoints","roughLine","hashSeed","px","py","lineLength","headSize","angle","headAngle","leftEndX","leftEndY","rightEndX","rightEndY","leftWingPoints","rightWingPoints","headStart","wingDuration"],"mappings":"6IAWMA,EAAQ,IAwBP,SAASC,EAAeC,EAAYC,EAAO,CAChD,KAAM,CAAE,GAAAC,EAAI,MAAAC,EAAO,IAAAC,EAAK,OAAAC,EAAQ,OAAAC,EAAQ,KAAAC,EAAM,KAAAC,CAAI,EAAKR,EAEvD,GAAI,OAAOK,GAAW,UAAY,OAAOC,GAAW,UAChD,OAAOC,GAAS,UAAY,OAAOC,GAAS,SAC9C,MAAO,CAAA,EAGT,MAAMC,EAAU,CAAA,EACVC,EAAgBN,EAAMD,EACtBQ,EAAeD,EAAgB,GAC/BE,EAAeF,EAAgB,GAE/BG,EAAYZ,EAAM,WAAa,GAC/Ba,EAASb,EAAM,QAAU,GACzBc,EAAed,EAAM,cAAgB,IACrCe,EAAiBf,EAAM,gBAAkB,EACzCgB,EAAsBhB,EAAM,qBAAuB,EACnDiB,EAAqBjB,EAAM,oBAAsB,GAmBjDkB,EAhBkBC,EAAAA,UACtBf,EAASP,EACTQ,EAASR,EACTS,EAAOT,EACPU,EAAOV,EACP,CACE,UAAAe,EACA,OAAAC,EACA,KAAMO,EAAAA,SAAS,GAAGnB,CAAE,OAAO,EAC3B,aAAAa,EACA,eAAAC,EACA,oBAAAC,EACA,mBAAAC,CACN,CACA,EAEqC,IAAI,CAAC,CAACI,EAAIC,CAAE,IAAM,CAACD,EAAKxB,EAAOyB,EAAKzB,CAAK,CAAC,EAE7EW,EAAQ,KAAK,CACX,GAAI,GAAGP,CAAE,KACT,OAAQiB,EACR,MAAOhB,EACP,IAAKA,EAAQQ,EACb,MAAOV,EAAM,OAAS,uBACtB,MAAOA,EAAM,OAAS,EACtB,QAASA,EAAM,SAAW,OAC9B,CAAG,EAGD,MAAMuB,EAAa,KAAK,MAAMjB,EAAOF,IAAW,GAAKG,EAAOF,IAAW,CAAC,EAClEmB,EAAW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,GAAI,GAAGP,CAAE,KACT,OAAQ+B,EACR,MAAOC,EACP,IAAKA,EAAYC,EACjB,MAAOlC,EAAM,OAAS,uBACtB,MAAOA,EAAM,OAAS,EACtB,QAASA,EAAM,SAAW,OAC9B,CAAG,EAEMQ,CACT"}
|
package/dist/index16.js
CHANGED
|
@@ -1,27 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { roughLine as S, hashSeed as L } from "./index29.js";
|
|
2
|
+
const n = 1e3;
|
|
3
|
+
function T(x, t) {
|
|
4
|
+
const { id: r, start: a, end: E, from_x: c, from_y: h, to_x: o, to_y: i } = x;
|
|
5
|
+
if (typeof c != "number" || typeof h != "number" || typeof o != "number" || typeof i != "number")
|
|
4
6
|
return [];
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
const u = [], P = E - a, W = P * 0.7, k = P * 0.3, m = t.roughness ?? 0.8, l = t.bowing ?? 0.8, b = t.curveFitting ?? 0.95, w = t.curveStepCount ?? 9, M = t.maxRandomnessOffset ?? 2, C = t.disableMultiStroke ?? !1, v = S(
|
|
8
|
+
c * n,
|
|
9
|
+
h * n,
|
|
10
|
+
o * n,
|
|
11
|
+
i * n,
|
|
12
|
+
{
|
|
13
|
+
roughness: m,
|
|
14
|
+
bowing: l,
|
|
15
|
+
seed: L(`${r}-line`),
|
|
16
|
+
curveFitting: b,
|
|
17
|
+
curveStepCount: w,
|
|
18
|
+
maxRandomnessOffset: M,
|
|
19
|
+
disableMultiStroke: C
|
|
20
|
+
}
|
|
21
|
+
).map(([e, s]) => [e / n, s / n]);
|
|
22
|
+
u.push({
|
|
23
|
+
id: `${r}-0`,
|
|
24
|
+
points: v,
|
|
25
|
+
start: a,
|
|
26
|
+
end: a + W,
|
|
27
|
+
color: t.color || "rgba(255, 0, 0, 0.8)",
|
|
28
|
+
width: t.width || 2,
|
|
29
|
+
lineCap: t.lineCap || "round"
|
|
30
|
+
});
|
|
31
|
+
const D = Math.sqrt((o - c) ** 2 + (i - h) ** 2), d = Math.min(D * 0.2, 0.03), g = Math.atan2(i - h, o - c), p = Math.PI / 6, R = o - d * Math.cos(g - p), _ = i - d * Math.sin(g - p), A = o - d * Math.cos(g + p), F = i - d * Math.sin(g + p), O = S(
|
|
32
|
+
o * n,
|
|
33
|
+
i * n,
|
|
34
|
+
R * n,
|
|
35
|
+
_ * n,
|
|
36
|
+
{
|
|
37
|
+
roughness: m,
|
|
38
|
+
bowing: l,
|
|
39
|
+
seed: L(`${r}-left`),
|
|
40
|
+
curveFitting: b,
|
|
41
|
+
curveStepCount: w,
|
|
42
|
+
maxRandomnessOffset: M,
|
|
43
|
+
disableMultiStroke: C
|
|
44
|
+
}
|
|
45
|
+
).map(([e, s]) => [e / n, s / n]), X = S(
|
|
46
|
+
o * n,
|
|
47
|
+
i * n,
|
|
48
|
+
A * n,
|
|
49
|
+
F * n,
|
|
50
|
+
{
|
|
51
|
+
roughness: m,
|
|
52
|
+
bowing: l,
|
|
53
|
+
seed: L(`${r}-right`),
|
|
54
|
+
curveFitting: b,
|
|
55
|
+
curveStepCount: w,
|
|
56
|
+
maxRandomnessOffset: M,
|
|
57
|
+
disableMultiStroke: C
|
|
58
|
+
}
|
|
59
|
+
).map(([e, s]) => [e / n, s / n]), f = a + W, $ = k / 2;
|
|
60
|
+
return u.push({
|
|
61
|
+
id: `${r}-1`,
|
|
62
|
+
points: O,
|
|
63
|
+
start: f,
|
|
64
|
+
end: f + $,
|
|
65
|
+
color: t.color || "rgba(255, 0, 0, 0.8)",
|
|
66
|
+
width: t.width || 2,
|
|
67
|
+
lineCap: t.lineCap || "round"
|
|
68
|
+
}), u.push({
|
|
69
|
+
id: `${r}-2`,
|
|
70
|
+
points: X,
|
|
71
|
+
start: f,
|
|
72
|
+
end: f + $,
|
|
73
|
+
color: t.color || "rgba(255, 0, 0, 0.8)",
|
|
74
|
+
width: t.width || 2,
|
|
75
|
+
lineCap: t.lineCap || "round"
|
|
76
|
+
}), u;
|
|
22
77
|
}
|
|
23
78
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
79
|
+
T as arrowToStrokes,
|
|
80
|
+
T as default
|
|
26
81
|
};
|
|
27
82
|
//# sourceMappingURL=index16.js.map
|
package/dist/index16.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index16.js","sources":["../src/converters/
|
|
1
|
+
{"version":3,"file":"index16.js","sources":["../src/converters/arrow.js"],"sourcesContent":["/**\n * Arrow Converter - Converts arrow annotations to stroke commands\n *\n * Transforms arrow data into a line stroke with arrowhead strokes\n * that can be rendered progressively on canvas with hand-drawn style.\n *\n * @module converters/arrow\n */\n\nimport { roughLine, hashSeed } from '../rough/roughPathExtractor.js';\n\nconst SCALE = 1000;\n\n/**\n * Converts an arrow annotation to stroke commands\n *\n * Creates a main line stroke from source to target, followed by\n * two wing strokes forming the arrowhead. Line draws first (70%),\n * then arrowhead (30%).\n *\n * @param {Object} annotation - Arrow annotation object\n * @param {string} annotation.id - Unique identifier\n * @param {number} annotation.start - Start time in seconds\n * @param {number} annotation.end - End time in seconds\n * @param {number} annotation.from_x - Source x position (0-1 normalized)\n * @param {number} annotation.from_y - Source y position (0-1 normalized)\n * @param {number} annotation.to_x - Target x position (0-1 normalized)\n * @param {number} annotation.to_y - Target y position (0-1 normalized)\n * @param {Object} [annotation.style] - Optional style overrides\n * @param {Object} style - Resolved style configuration\n * @param {string} style.color - Stroke color\n * @param {number} style.width - Stroke width in pixels\n * @param {string} [style.lineCap='round'] - Line cap style\n * @returns {Array<Object>} Array of stroke commands\n */\nexport function arrowToStrokes(annotation, style) {\n const { id, start, end, from_x, from_y, to_x, to_y } = annotation;\n\n if (typeof from_x !== 'number' || typeof from_y !== 'number' ||\n typeof to_x !== 'number' || typeof to_y !== 'number') {\n return [];\n }\n\n const strokes = [];\n const totalDuration = end - start;\n const lineDuration = totalDuration * 0.7;\n const headDuration = totalDuration * 0.3;\n\n const roughness = style.roughness ?? 0.8;\n const bowing = style.bowing ?? 0.8;\n const curveFitting = style.curveFitting ?? 0.95;\n const curveStepCount = style.curveStepCount ?? 9;\n const maxRandomnessOffset = style.maxRandomnessOffset ?? 2;\n const disableMultiStroke = style.disableMultiStroke ?? false;\n\n // Main line stroke with RoughJS style\n const roughLinePoints = roughLine(\n from_x * SCALE,\n from_y * SCALE,\n to_x * SCALE,\n to_y * SCALE,\n {\n roughness,\n bowing,\n seed: hashSeed(`${id}-line`),\n curveFitting,\n curveStepCount,\n maxRandomnessOffset,\n disableMultiStroke\n }\n );\n\n const linePoints = roughLinePoints.map(([px, py]) => [px / SCALE, py / SCALE]);\n\n strokes.push({\n id: `${id}-0`,\n points: linePoints,\n start: start,\n end: start + lineDuration,\n color: style.color || 'rgba(255, 0, 0, 0.8)',\n width: style.width || 2,\n lineCap: style.lineCap || 'round'\n });\n\n // Arrow head calculation\n const lineLength = Math.sqrt((to_x - from_x) ** 2 + (to_y - from_y) ** 2);\n const headSize = Math.min(lineLength * 0.2, 0.03);\n const angle = Math.atan2(to_y - from_y, to_x - from_x);\n const headAngle = Math.PI / 6; // 30 degrees\n\n // Left wing end point\n const leftEndX = to_x - headSize * Math.cos(angle - headAngle);\n const leftEndY = to_y - headSize * Math.sin(angle - headAngle);\n\n // Right wing end point\n const rightEndX = to_x - headSize * Math.cos(angle + headAngle);\n const rightEndY = to_y - headSize * Math.sin(angle + headAngle);\n\n // Left wing with RoughJS style\n const roughLeftWing = roughLine(\n to_x * SCALE,\n to_y * SCALE,\n leftEndX * SCALE,\n leftEndY * SCALE,\n {\n roughness,\n bowing,\n seed: hashSeed(`${id}-left`),\n curveFitting,\n curveStepCount,\n maxRandomnessOffset,\n disableMultiStroke\n }\n );\n\n const leftWingPoints = roughLeftWing.map(([px, py]) => [px / SCALE, py / SCALE]);\n\n // Right wing with RoughJS style\n const roughRightWing = roughLine(\n to_x * SCALE,\n to_y * SCALE,\n rightEndX * SCALE,\n rightEndY * SCALE,\n {\n roughness,\n bowing,\n seed: hashSeed(`${id}-right`),\n curveFitting,\n curveStepCount,\n maxRandomnessOffset,\n disableMultiStroke\n }\n );\n\n const rightWingPoints = roughRightWing.map(([px, py]) => [px / SCALE, py / SCALE]);\n\n const headStart = start + lineDuration;\n const wingDuration = headDuration / 2;\n\n strokes.push({\n id: `${id}-1`,\n points: leftWingPoints,\n start: headStart,\n end: headStart + wingDuration,\n color: style.color || 'rgba(255, 0, 0, 0.8)',\n width: style.width || 2,\n lineCap: style.lineCap || 'round'\n });\n\n strokes.push({\n id: `${id}-2`,\n points: rightWingPoints,\n start: headStart,\n end: headStart + wingDuration,\n color: style.color || 'rgba(255, 0, 0, 0.8)',\n width: style.width || 2,\n lineCap: style.lineCap || 'round'\n });\n\n return strokes;\n}\n\nexport default arrowToStrokes;\n"],"names":["SCALE","arrowToStrokes","annotation","style","id","start","end","from_x","from_y","to_x","to_y","strokes","totalDuration","lineDuration","headDuration","roughness","bowing","curveFitting","curveStepCount","maxRandomnessOffset","disableMultiStroke","linePoints","roughLine","hashSeed","px","py","lineLength","headSize","angle","headAngle","leftEndX","leftEndY","rightEndX","rightEndY","leftWingPoints","rightWingPoints","headStart","wingDuration"],"mappings":";AAWA,MAAMA,IAAQ;AAwBP,SAASC,EAAeC,GAAYC,GAAO;AAChD,QAAM,EAAE,IAAAC,GAAI,OAAAC,GAAO,KAAAC,GAAK,QAAAC,GAAQ,QAAAC,GAAQ,MAAAC,GAAM,MAAAC,EAAI,IAAKR;AAEvD,MAAI,OAAOK,KAAW,YAAY,OAAOC,KAAW,YAChD,OAAOC,KAAS,YAAY,OAAOC,KAAS;AAC9C,WAAO,CAAA;AAGT,QAAMC,IAAU,CAAA,GACVC,IAAgBN,IAAMD,GACtBQ,IAAeD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OAAOA,EAAM,SAAS;AAAA,IACtB,SAASA,EAAM,WAAW;AAAA,EAC9B,CAAG,GAEMQ;AACT;"}
|
package/dist/index17.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("./index29.cjs"),e=1e3;function c(a,o){const{id:t,start:d,end:f,cx:n,cy:r,rx:u,ry:s}=a;if(typeof n!="number"||typeof r!="number"||typeof u!="number"||typeof s!="number")return[];const g=o.roughness??1,p=o.bowing??1,b=o.curveFitting??.95,h=o.curveStepCount??9,l=o.maxRandomnessOffset??2,m=o.disableMultiStroke??!1,S=i.roughEllipse(n*e,r*e,u*2*e,s*2*e,{roughness:g,bowing:p,seed:i.hashSeed(t),curveFitting:b,curveStepCount:h,maxRandomnessOffset:l,disableMultiStroke:m}).map(([v,x])=>[v/e,x/e]);return[{id:t,points:S,start:d,end:f,color:o.color||"rgba(255, 165, 0, 0.8)",width:o.width||3,lineCap:o.lineCap||"round"}]}exports.circleToStrokes=c;exports.default=c;
|
|
2
2
|
//# sourceMappingURL=index17.cjs.map
|
package/dist/index17.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index17.cjs","sources":["../src/converters/
|
|
1
|
+
{"version":3,"file":"index17.cjs","sources":["../src/converters/circle.js"],"sourcesContent":["/**\n * Circle Converter - Converts circle annotations to stroke commands\n *\n * Transforms circle/ellipse data into stroke paths that can be\n * rendered progressively on canvas with hand-drawn style.\n *\n * @module converters/circle\n */\n\nimport { roughEllipse, hashSeed } from '../rough/roughPathExtractor.js';\n\nconst SCALE = 1000;\n\n/**\n * Converts a circle annotation to stroke commands\n *\n * Generates an ellipse path that renders progressively around the perimeter.\n * Uses RoughJS for hand-drawn circle style.\n *\n * @param {Object} annotation - Circle annotation object\n * @param {string} annotation.id - Unique identifier\n * @param {number} annotation.start - Start time in seconds\n * @param {number} annotation.end - End time in seconds\n * @param {number} annotation.cx - Center x position (0-1 normalized)\n * @param {number} annotation.cy - Center y position (0-1 normalized)\n * @param {number} annotation.rx - Horizontal radius (0-1 normalized)\n * @param {number} annotation.ry - Vertical radius (0-1 normalized)\n * @param {Object} [annotation.style] - Optional style overrides\n * @param {Object} style - Resolved style configuration\n * @param {string} style.color - Stroke color\n * @param {number} style.width - Stroke width in pixels\n * @param {string} [style.lineCap='round'] - Line cap style\n * @param {number} [style.roughness=1.0] - Hand-drawn roughness\n * @param {number} [style.bowing=1.0] - Line curvature\n * @returns {Array<Object>} Array of stroke commands\n */\nexport function circleToStrokes(annotation, style) {\n const { id, start, end, cx, cy, rx, ry } = annotation;\n\n if (typeof cx !== 'number' || typeof cy !== 'number' ||\n typeof rx !== 'number' || typeof ry !== 'number') {\n return [];\n }\n\n const roughness = style.roughness ?? 1.0;\n const bowing = style.bowing ?? 1.0;\n const curveFitting = style.curveFitting ?? 0.95;\n const curveStepCount = style.curveStepCount ?? 9;\n const maxRandomnessOffset = style.maxRandomnessOffset ?? 2;\n const disableMultiStroke = style.disableMultiStroke ?? false;\n\n const roughPoints = roughEllipse(\n cx * SCALE,\n cy * SCALE,\n rx * 2 * SCALE,\n ry * 2 * SCALE,\n {\n roughness,\n bowing,\n seed: hashSeed(id),\n curveFitting,\n curveStepCount,\n maxRandomnessOffset,\n disableMultiStroke\n }\n );\n\n const points = roughPoints.map(([px, py]) => [px / SCALE, py / SCALE]);\n\n return [{\n id,\n points,\n start,\n end,\n color: style.color || 'rgba(255, 165, 0, 0.8)',\n width: style.width || 3,\n lineCap: style.lineCap || 'round'\n }];\n}\n\nexport default circleToStrokes;\n"],"names":["SCALE","circleToStrokes","annotation","style","id","start","end","cx","cy","rx","ry","roughness","bowing","curveFitting","curveStepCount","maxRandomnessOffset","disableMultiStroke","points","roughEllipse","hashSeed","px","py"],"mappings":"6IAWMA,EAAQ,IAyBP,SAASC,EAAgBC,EAAYC,EAAO,CACjD,KAAM,CAAE,GAAAC,EAAI,MAAAC,EAAO,IAAAC,EAAK,GAAAC,EAAI,GAAAC,EAAI,GAAAC,EAAI,GAAAC,CAAE,EAAKR,EAE3C,GAAI,OAAOK,GAAO,UAAY,OAAOC,GAAO,UACxC,OAAOC,GAAO,UAAY,OAAOC,GAAO,SAC1C,MAAO,CAAA,EAGT,MAAMC,EAAYR,EAAM,WAAa,EAC/BS,EAAST,EAAM,QAAU,EACzBU,EAAeV,EAAM,cAAgB,IACrCW,EAAiBX,EAAM,gBAAkB,EACzCY,EAAsBZ,EAAM,qBAAuB,EACnDa,EAAqBb,EAAM,oBAAsB,GAkBjDc,EAhBcC,EAAAA,aAClBX,EAAKP,EACLQ,EAAKR,EACLS,EAAK,EAAIT,EACTU,EAAK,EAAIV,EACT,CACE,UAAAW,EACA,OAAAC,EACA,KAAMO,EAAAA,SAASf,CAAE,EACjB,aAAAS,EACA,eAAAC,EACA,oBAAAC,EACA,mBAAAC,CACN,CACA,EAE6B,IAAI,CAAC,CAACI,EAAIC,CAAE,IAAM,CAACD,EAAKpB,EAAOqB,EAAKrB,CAAK,CAAC,EAErE,MAAO,CAAC,CACN,GAAAI,EACA,OAAAa,EACA,MAAAZ,EACA,IAAAC,EACA,MAAOH,EAAM,OAAS,yBACtB,MAAOA,EAAM,OAAS,EACtB,QAASA,EAAM,SAAW,OAC9B,CAAG,CACH"}
|
package/dist/index17.js
CHANGED
|
@@ -1,57 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { roughEllipse as x, hashSeed as C } from "./index29.js";
|
|
2
|
+
const n = 1e3;
|
|
3
|
+
function k(u, o) {
|
|
4
|
+
const { id: t, start: c, end: a, cx: e, cy: r, rx: s, ry: i } = u;
|
|
5
|
+
if (typeof e != "number" || typeof r != "number" || typeof s != "number" || typeof i != "number")
|
|
4
6
|
return [];
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
]
|
|
29
|
-
[n, o],
|
|
30
|
-
[
|
|
31
|
-
n - e * Math.cos(c + h),
|
|
32
|
-
o - e * Math.sin(c + h)
|
|
33
|
-
]
|
|
34
|
-
], d = a + f, w = D / 2;
|
|
35
|
-
return s.push({
|
|
36
|
-
id: `${u}-1`,
|
|
37
|
-
points: x,
|
|
38
|
-
start: d,
|
|
39
|
-
end: d + w,
|
|
40
|
-
color: t.color || "rgba(255, 0, 0, 0.8)",
|
|
41
|
-
width: t.width || 2,
|
|
42
|
-
lineCap: t.lineCap || "round"
|
|
43
|
-
}), s.push({
|
|
44
|
-
id: `${u}-2`,
|
|
45
|
-
points: P,
|
|
46
|
-
start: d,
|
|
47
|
-
end: d + w,
|
|
48
|
-
color: t.color || "rgba(255, 0, 0, 0.8)",
|
|
49
|
-
width: t.width || 2,
|
|
50
|
-
lineCap: t.lineCap || "round"
|
|
51
|
-
}), s;
|
|
7
|
+
const f = o.roughness ?? 1, p = o.bowing ?? 1, d = o.curveFitting ?? 0.95, m = o.curveStepCount ?? 9, g = o.maxRandomnessOffset ?? 2, b = o.disableMultiStroke ?? !1, h = x(
|
|
8
|
+
e * n,
|
|
9
|
+
r * n,
|
|
10
|
+
s * 2 * n,
|
|
11
|
+
i * 2 * n,
|
|
12
|
+
{
|
|
13
|
+
roughness: f,
|
|
14
|
+
bowing: p,
|
|
15
|
+
seed: C(t),
|
|
16
|
+
curveFitting: d,
|
|
17
|
+
curveStepCount: m,
|
|
18
|
+
maxRandomnessOffset: g,
|
|
19
|
+
disableMultiStroke: b
|
|
20
|
+
}
|
|
21
|
+
).map(([S, l]) => [S / n, l / n]);
|
|
22
|
+
return [{
|
|
23
|
+
id: t,
|
|
24
|
+
points: h,
|
|
25
|
+
start: c,
|
|
26
|
+
end: a,
|
|
27
|
+
color: o.color || "rgba(255, 165, 0, 0.8)",
|
|
28
|
+
width: o.width || 3,
|
|
29
|
+
lineCap: o.lineCap || "round"
|
|
30
|
+
}];
|
|
52
31
|
}
|
|
53
32
|
export {
|
|
54
|
-
|
|
55
|
-
|
|
33
|
+
k as circleToStrokes,
|
|
34
|
+
k as default
|
|
56
35
|
};
|
|
57
36
|
//# sourceMappingURL=index17.js.map
|
package/dist/index17.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index17.js","sources":["../src/converters/
|
|
1
|
+
{"version":3,"file":"index17.js","sources":["../src/converters/circle.js"],"sourcesContent":["/**\n * Circle Converter - Converts circle annotations to stroke commands\n *\n * Transforms circle/ellipse data into stroke paths that can be\n * rendered progressively on canvas with hand-drawn style.\n *\n * @module converters/circle\n */\n\nimport { roughEllipse, hashSeed } from '../rough/roughPathExtractor.js';\n\nconst SCALE = 1000;\n\n/**\n * Converts a circle annotation to stroke commands\n *\n * Generates an ellipse path that renders progressively around the perimeter.\n * Uses RoughJS for hand-drawn circle style.\n *\n * @param {Object} annotation - Circle annotation object\n * @param {string} annotation.id - Unique identifier\n * @param {number} annotation.start - Start time in seconds\n * @param {number} annotation.end - End time in seconds\n * @param {number} annotation.cx - Center x position (0-1 normalized)\n * @param {number} annotation.cy - Center y position (0-1 normalized)\n * @param {number} annotation.rx - Horizontal radius (0-1 normalized)\n * @param {number} annotation.ry - Vertical radius (0-1 normalized)\n * @param {Object} [annotation.style] - Optional style overrides\n * @param {Object} style - Resolved style configuration\n * @param {string} style.color - Stroke color\n * @param {number} style.width - Stroke width in pixels\n * @param {string} [style.lineCap='round'] - Line cap style\n * @param {number} [style.roughness=1.0] - Hand-drawn roughness\n * @param {number} [style.bowing=1.0] - Line curvature\n * @returns {Array<Object>} Array of stroke commands\n */\nexport function circleToStrokes(annotation, style) {\n const { id, start, end, cx, cy, rx, ry } = annotation;\n\n if (typeof cx !== 'number' || typeof cy !== 'number' ||\n typeof rx !== 'number' || typeof ry !== 'number') {\n return [];\n }\n\n const roughness = style.roughness ?? 1.0;\n const bowing = style.bowing ?? 1.0;\n const curveFitting = style.curveFitting ?? 0.95;\n const curveStepCount = style.curveStepCount ?? 9;\n const maxRandomnessOffset = style.maxRandomnessOffset ?? 2;\n const disableMultiStroke = style.disableMultiStroke ?? false;\n\n const roughPoints = roughEllipse(\n cx * SCALE,\n cy * SCALE,\n rx * 2 * SCALE,\n ry * 2 * SCALE,\n {\n roughness,\n bowing,\n seed: hashSeed(id),\n curveFitting,\n curveStepCount,\n maxRandomnessOffset,\n disableMultiStroke\n }\n );\n\n const points = roughPoints.map(([px, py]) => [px / SCALE, py / SCALE]);\n\n return [{\n id,\n points,\n start,\n end,\n color: style.color || 'rgba(255, 165, 0, 0.8)',\n width: style.width || 3,\n lineCap: style.lineCap || 'round'\n }];\n}\n\nexport default circleToStrokes;\n"],"names":["SCALE","circleToStrokes","annotation","style","id","start","end","cx","cy","rx","ry","roughness","bowing","curveFitting","curveStepCount","maxRandomnessOffset","disableMultiStroke","points","roughEllipse","hashSeed","px","py"],"mappings":";AAWA,MAAMA,IAAQ;AAyBP,SAASC,EAAgBC,GAAYC,GAAO;AACjD,QAAM,EAAE,IAAAC,GAAI,OAAAC,GAAO,KAAAC,GAAK,IAAAC,GAAI,IAAAC,GAAI,IAAAC,GAAI,IAAAC,EAAE,IAAKR;AAE3C,MAAI,OAAOK,KAAO,YAAY,OAAOC,KAAO,YACxC,OAAOC,KAAO,YAAY,OAAOC,KAAO;AAC1C,WAAO,CAAA;AAGT,QAAMC,IAAYR,EAAM,aAAa,GAC/BS,IAAST,EAAM,UAAU,GACzBU,IAAeV,EAAM,gBAAgB,MACrCW,IAAiBX,EAAM,kBAAkB,GACzCY,IAAsBZ,EAAM,uBAAuB,GACnDa,IAAqBb,EAAM,sBAAsB,IAkBjDc,IAhBcC;AAAA,IAClBX,IAAKP;AAAA,IACLQ,IAAKR;AAAA,IACLS,IAAK,IAAIT;AAAA,IACTU,IAAK,IAAIV;AAAA,IACT;AAAA,MACE,WAAAW;AAAA,MACA,QAAAC;AAAA,MACA,MAAMO,EAASf,CAAE;AAAA,MACjB,cAAAS;AAAA,MACA,gBAAAC;AAAA,MACA,qBAAAC;AAAA,MACA,oBAAAC;AAAA,IACN;AAAA,EACA,EAE6B,IAAI,CAAC,CAACI,GAAIC,CAAE,MAAM,CAACD,IAAKpB,GAAOqB,IAAKrB,CAAK,CAAC;AAErE,SAAO,CAAC;AAAA,IACN,IAAAI;AAAA,IACA,QAAAa;AAAA,IACA,OAAAZ;AAAA,IACA,KAAAC;AAAA,IACA,OAAOH,EAAM,SAAS;AAAA,IACtB,OAAOA,EAAM,SAAS;AAAA,IACtB,SAASA,EAAM,WAAW;AAAA,EAC9B,CAAG;AACH;"}
|
package/dist/index18.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(d,i){const{id:c,start:n,end:r,strokes:o}=d;if(!o||o.length===0)return[];const a=r-n;if(a<=0)return[];const f=o.reduce((t,e)=>Math.max(t,(e.timeOffset||0)+(e.duration||.5)),0)||1,s=a/f;return o.filter(t=>t.points&&t.points.length>=2).map((t,e)=>({id:`${c}-${e}`,points:t.points,start:n+(t.timeOffset||0)*s,end:Math.min(n+((t.timeOffset||0)+(t.duration||.5))*s,r),color:t.color||i.color||"#DC143C",width:t.width||i.width||2,lineCap:i.lineCap||"round"}))}exports.inkToStrokes=l;
|
|
2
2
|
//# sourceMappingURL=index18.cjs.map
|
package/dist/index18.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index18.cjs","sources":["../src/converters/
|
|
1
|
+
{"version":3,"file":"index18.cjs","sources":["../src/converters/ink.js"],"sourcesContent":["/**\n * Ink Annotation Converter\n *\n * Converts freehand ink annotations to renderer stroke commands.\n * Unlike other converters, ink does NOT use RoughJS — strokes are\n * already hand-drawn and only need timing mapped to the annotation window.\n *\n * @module converters/ink\n */\n\n/**\n * Convert ink annotation to renderer strokes\n *\n * Maps each sub-stroke's recorded timing (timeOffset + duration) to the\n * annotation's playback window [start, end] using a proportional timeScale.\n *\n * @param {Object} annotation - Ink annotation object\n * @param {string} annotation.id - Annotation ID\n * @param {number} annotation.start - Playback start time (seconds)\n * @param {number} annotation.end - Playback end time (seconds)\n * @param {Array} annotation.strokes - Sub-strokes with points and timing\n * @param {Object} style - Resolved style from StrokeRenderer config\n * @returns {Array} Renderer stroke commands\n */\nexport function inkToStrokes(annotation, style) {\n const { id, start, end, strokes: subStrokes } = annotation;\n if (!subStrokes || subStrokes.length === 0) return [];\n\n const totalDuration = end - start;\n if (totalDuration <= 0) return [];\n\n // Calculate recorded session length from stroke timing\n const sessionDuration = subStrokes.reduce(\n (max, s) => Math.max(max, (s.timeOffset || 0) + (s.duration || 0.5)),\n 0\n ) || 1;\n const timeScale = totalDuration / sessionDuration;\n\n return subStrokes\n .filter((sub) => sub.points && sub.points.length >= 2)\n .map((sub, i) => ({\n id: `${id}-${i}`,\n points: sub.points,\n start: start + (sub.timeOffset || 0) * timeScale,\n end: Math.min(\n start + ((sub.timeOffset || 0) + (sub.duration || 0.5)) * timeScale,\n end\n ),\n color: sub.color || style.color || '#DC143C',\n width: sub.width || style.width || 2,\n lineCap: style.lineCap || 'round',\n }));\n}\n"],"names":["inkToStrokes","annotation","style","id","start","end","subStrokes","totalDuration","sessionDuration","max","s","timeScale","sub","i"],"mappings":"gFAwBO,SAASA,EAAaC,EAAYC,EAAO,CAC9C,KAAM,CAAE,GAAAC,EAAI,MAAAC,EAAO,IAAAC,EAAK,QAASC,CAAU,EAAKL,EAChD,GAAI,CAACK,GAAcA,EAAW,SAAW,EAAG,MAAO,CAAA,EAEnD,MAAMC,EAAgBF,EAAMD,EAC5B,GAAIG,GAAiB,EAAG,MAAO,CAAA,EAG/B,MAAMC,EAAkBF,EAAW,OACjC,CAACG,EAAKC,IAAM,KAAK,IAAID,GAAMC,EAAE,YAAc,IAAMA,EAAE,UAAY,GAAI,EACnE,CACJ,GAAO,EACCC,EAAYJ,EAAgBC,EAElC,OAAOF,EACJ,OAAQM,GAAQA,EAAI,QAAUA,EAAI,OAAO,QAAU,CAAC,EACpD,IAAI,CAACA,EAAKC,KAAO,CAChB,GAAI,GAAGV,CAAE,IAAIU,CAAC,GACd,OAAQD,EAAI,OACZ,MAAOR,GAASQ,EAAI,YAAc,GAAKD,EACvC,IAAK,KAAK,IACRP,IAAUQ,EAAI,YAAc,IAAMA,EAAI,UAAY,KAAQD,EAC1DN,CACR,EACM,MAAOO,EAAI,OAASV,EAAM,OAAS,UACnC,MAAOU,EAAI,OAASV,EAAM,OAAS,EACnC,QAASA,EAAM,SAAW,OAChC,EAAM,CACN"}
|