web-annotation-renderer 0.6.4 → 0.7.0
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/CHANGELOG.md +129 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +62 -61
- package/dist/index.js.map +1 -1
- package/dist/index10.cjs +1 -1
- package/dist/index10.cjs.map +1 -1
- package/dist/index10.js +160 -13
- package/dist/index10.js.map +1 -1
- package/dist/index11.cjs +1 -1
- package/dist/index11.cjs.map +1 -1
- package/dist/index11.js +13 -50
- package/dist/index11.js.map +1 -1
- package/dist/index12.cjs +1 -1
- package/dist/index12.cjs.map +1 -1
- package/dist/index12.js +48 -155
- package/dist/index12.js.map +1 -1
- package/dist/index13.cjs +1 -1
- package/dist/index13.cjs.map +1 -1
- package/dist/index13.js +150 -34
- package/dist/index13.js.map +1 -1
- package/dist/index14.cjs +1 -1
- package/dist/index14.cjs.map +1 -1
- package/dist/index14.js +32 -65
- package/dist/index14.js.map +1 -1
- package/dist/index15.cjs +1 -1
- package/dist/index15.cjs.map +1 -1
- package/dist/index15.js +66 -33
- package/dist/index15.js.map +1 -1
- package/dist/index16.cjs +1 -1
- package/dist/index16.cjs.map +1 -1
- package/dist/index16.js +35 -77
- package/dist/index16.js.map +1 -1
- package/dist/index17.cjs +1 -1
- package/dist/index17.cjs.map +1 -1
- package/dist/index17.js +53 -28
- package/dist/index17.js.map +1 -1
- package/dist/index18.cjs +1 -1
- package/dist/index18.cjs.map +1 -1
- package/dist/index18.js +28 -22
- package/dist/index18.js.map +1 -1
- package/dist/index19.cjs +1 -1
- package/dist/index19.cjs.map +1 -1
- package/dist/index19.js +22 -117
- package/dist/index19.js.map +1 -1
- package/dist/index2.cjs +1 -1
- package/dist/index2.cjs.map +1 -1
- package/dist/index2.js +94 -98
- package/dist/index2.js.map +1 -1
- package/dist/index20.cjs +1 -1
- package/dist/index20.cjs.map +1 -1
- package/dist/index20.js +137 -100
- package/dist/index20.js.map +1 -1
- package/dist/index21.cjs +1 -1
- package/dist/index21.cjs.map +1 -1
- package/dist/index21.js +34 -76
- package/dist/index21.js.map +1 -1
- package/dist/index22.cjs +1 -1
- package/dist/index22.cjs.map +1 -1
- package/dist/index22.js +35 -139
- package/dist/index22.js.map +1 -1
- package/dist/index23.cjs +1 -1
- package/dist/index23.cjs.map +1 -1
- package/dist/index23.js +37 -37
- package/dist/index23.js.map +1 -1
- package/dist/index24.cjs +1 -1
- package/dist/index24.cjs.map +1 -1
- package/dist/index24.js +69 -37
- package/dist/index24.js.map +1 -1
- package/dist/index25.cjs +1 -1
- package/dist/index25.cjs.map +1 -1
- package/dist/index25.js +40 -38
- package/dist/index25.js.map +1 -1
- package/dist/index26.cjs +1 -1
- package/dist/index26.cjs.map +1 -1
- package/dist/index26.js +4 -39
- package/dist/index26.js.map +1 -1
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +4 -4
- package/dist/index28.cjs +1 -1
- package/dist/index28.cjs.map +1 -1
- package/dist/index28.js +71 -5
- package/dist/index28.js.map +1 -1
- package/dist/index29.cjs +1 -1
- package/dist/index29.cjs.map +1 -1
- package/dist/index29.js +24 -69
- package/dist/index29.js.map +1 -1
- package/dist/index3.cjs +1 -1
- package/dist/index3.cjs.map +1 -1
- package/dist/index3.js +31 -31
- package/dist/index3.js.map +1 -1
- package/dist/index5.cjs +1 -1
- package/dist/index5.cjs.map +1 -1
- package/dist/index5.js +237 -190
- package/dist/index5.js.map +1 -1
- package/dist/index6.cjs +1 -1
- package/dist/index6.cjs.map +1 -1
- package/dist/index6.js +37 -19
- package/dist/index6.js.map +1 -1
- package/dist/index7.cjs +1 -1
- package/dist/index7.cjs.map +1 -1
- package/dist/index7.js +11 -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 +16 -125
- package/dist/index8.js.map +1 -1
- package/dist/index9.cjs +1 -1
- package/dist/index9.cjs.map +1 -1
- package/dist/index9.js +118 -201
- package/dist/index9.js.map +1 -1
- package/package.json +6 -3
package/dist/index28.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index28.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index28.cjs","sources":["../src/rough/roughPathExtractor.js"],"sourcesContent":["/**\n * RoughJS Path Extractor - Utility functions for hand-drawn style paths\n *\n * Wraps RoughJS Generator API to extract path data as points arrays,\n * compatible with the existing StrokeRenderer pipeline.\n *\n * @module rough/roughPathExtractor\n */\n\nimport rough from 'roughjs';\n\nconst generator = rough.generator();\n\n/**\n * Cubic bezier interpolation\n *\n * @param {Array} p0 - Start point [x, y]\n * @param {Array} p1 - Control point 1 [x, y]\n * @param {Array} p2 - Control point 2 [x, y]\n * @param {Array} p3 - End point [x, y]\n * @param {number} t - Interpolation factor (0-1)\n * @returns {Array} Interpolated point [x, y]\n */\nfunction bezierPoint(p0, p1, p2, p3, t) {\n const mt = 1 - t;\n return [\n mt ** 3 * p0[0] + 3 * mt ** 2 * t * p1[0] + 3 * mt * t ** 2 * p2[0] + t ** 3 * p3[0],\n mt ** 3 * p0[1] + 3 * mt ** 2 * t * p1[1] + 3 * mt * t ** 2 * p2[1] + t ** 3 * p3[1]\n ];\n}\n\n/**\n * Convert RoughJS ops array to points array\n *\n * Processes move, lineTo, and bcurveTo operations.\n * Bezier curves are linearized with 4 intermediate points.\n *\n * @param {Array} ops - Array of RoughJS op objects\n * @returns {Array} Array of [x, y] points\n */\nfunction opsToPoints(ops) {\n const points = [];\n let current = [0, 0];\n\n for (const { op, data } of ops) {\n switch (op) {\n case 'move':\n current = [data[0], data[1]];\n points.push([...current]);\n break;\n\n case 'lineTo':\n current = [data[0], data[1]];\n points.push([...current]);\n break;\n\n case 'bcurveTo': {\n const [cx1, cy1, cx2, cy2, x, y] = data;\n const p0 = current;\n const p1 = [cx1, cy1];\n const p2 = [cx2, cy2];\n const p3 = [x, y];\n\n for (let t = 0.25; t <= 1; t += 0.25) {\n points.push(bezierPoint(p0, p1, p2, p3, t));\n }\n current = [x, y];\n break;\n }\n }\n }\n\n return points;\n}\n\n/**\n * Extract points from a RoughJS drawable\n *\n * Collects all path operations from drawable.sets and converts to points.\n *\n * @param {Object} drawable - RoughJS drawable object\n * @returns {Array} Array of [x, y] points\n */\nfunction extractPoints(drawable) {\n const allPoints = [];\n\n for (const set of drawable.sets) {\n if (set.type === 'path') {\n allPoints.push(...opsToPoints(set.ops));\n }\n }\n\n return allPoints;\n}\n\n/**\n * Generate a hash seed from a string\n *\n * Produces a deterministic number from string input for reproducible randomness.\n *\n * @param {string} str - Input string (e.g., annotation ID)\n * @returns {number} Hash value for use as seed\n */\nexport function hashSeed(str) {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n hash = ((hash << 5) - hash) + str.charCodeAt(i);\n hash |= 0;\n }\n return Math.abs(hash);\n}\n\n/**\n * Convert a line to RoughJS style points\n *\n * @param {number} x1 - Start x coordinate\n * @param {number} y1 - Start y coordinate\n * @param {number} x2 - End x coordinate\n * @param {number} y2 - End y coordinate\n * @param {Object} [options={}] - RoughJS options\n * @param {number} [options.roughness=1.0] - Line irregularity (0=clean, 3+=very rough)\n * @param {number} [options.bowing=1.0] - Line curvature (0=straight, 2+=very curved)\n * @param {number} [options.seed] - Seed for reproducible randomness\n * @param {number} [options.curveFitting=0.95] - Curve fitting (0=loose, 1=tight)\n * @param {number} [options.curveStepCount=9] - Curve resolution (higher=smoother)\n * @param {number} [options.maxRandomnessOffset=2] - Max random offset\n * @param {boolean} [options.disableMultiStroke=false] - Disable double-stroke effect\n * @returns {Array} Array of [x, y] points with hand-drawn style\n */\nexport function roughLine(x1, y1, x2, y2, options = {}) {\n const drawable = generator.line(x1, y1, x2, y2, {\n roughness: options.roughness ?? 1.0,\n bowing: options.bowing ?? 1.0,\n seed: options.seed ?? Math.floor(Math.random() * 2 ** 31),\n curveFitting: options.curveFitting ?? 0.95,\n curveStepCount: options.curveStepCount ?? 9,\n maxRandomnessOffset: options.maxRandomnessOffset ?? 2,\n disableMultiStroke: options.disableMultiStroke ?? false,\n ...options\n });\n\n return extractPoints(drawable);\n}\n\n/**\n * Convert an ellipse to RoughJS style points\n *\n * @param {number} cx - Center x coordinate\n * @param {number} cy - Center y coordinate\n * @param {number} width - Ellipse width\n * @param {number} height - Ellipse height\n * @param {Object} [options={}] - RoughJS options\n * @param {number} [options.roughness=1.0] - Shape irregularity\n * @param {number} [options.bowing=1.0] - Line curvature\n * @param {number} [options.seed] - Seed for reproducible randomness\n * @param {number} [options.curveFitting=0.95] - Curve fitting (0=loose, 1=tight)\n * @param {number} [options.curveStepCount=9] - Curve resolution (higher=smoother)\n * @param {number} [options.maxRandomnessOffset=2] - Max random offset\n * @param {boolean} [options.disableMultiStroke=false] - Disable double-stroke effect\n * @returns {Array} Array of [x, y] points with hand-drawn style\n */\nexport function roughEllipse(cx, cy, width, height, options = {}) {\n const drawable = generator.ellipse(cx, cy, width, height, {\n roughness: options.roughness ?? 1.0,\n bowing: options.bowing ?? 1.0,\n seed: options.seed ?? Math.floor(Math.random() * 2 ** 31),\n curveFitting: options.curveFitting ?? 0.95,\n curveStepCount: options.curveStepCount ?? 9,\n maxRandomnessOffset: options.maxRandomnessOffset ?? 2,\n disableMultiStroke: options.disableMultiStroke ?? false,\n ...options\n });\n\n return extractPoints(drawable);\n}\n\n/**\n * Convert a linear path (multiple connected points) to RoughJS style\n *\n * @param {Array} points - Array of [x, y] points to connect\n * @param {Object} [options={}] - RoughJS options\n * @param {number} [options.roughness=1.0] - Path irregularity\n * @param {number} [options.bowing=1.0] - Line curvature\n * @param {number} [options.seed] - Seed for reproducible randomness\n * @returns {Array} Array of [x, y] points with hand-drawn style\n */\nexport function roughLinearPath(points, options = {}) {\n if (!points || points.length < 2) {\n return points || [];\n }\n\n const drawable = generator.linearPath(points, {\n roughness: options.roughness ?? 1.0,\n bowing: options.bowing ?? 1.0,\n seed: options.seed ?? Math.floor(Math.random() * 2 ** 31),\n ...options\n });\n\n return extractPoints(drawable);\n}\n\nexport default {\n roughLine,\n roughEllipse,\n roughLinearPath,\n hashSeed\n};\n"],"names":["generator","rough","bezierPoint","p0","p1","p2","p3","t","mt","opsToPoints","ops","points","current","op","data","cx1","cy1","cx2","cy2","x","y","extractPoints","drawable","allPoints","set","hashSeed","str","hash","i","roughLine","x1","y1","x2","y2","options","roughEllipse","cx","cy","width","height"],"mappings":"iHAWMA,EAAYC,EAAAA,QAAM,UAAS,EAYjC,SAASC,EAAYC,EAAIC,EAAIC,EAAIC,EAAIC,EAAG,CACtC,MAAMC,EAAK,EAAID,EACf,MAAO,CACLC,GAAM,EAAIL,EAAG,CAAC,EAAI,EAAIK,GAAM,EAAID,EAAIH,EAAG,CAAC,EAAI,EAAII,EAAKD,GAAK,EAAIF,EAAG,CAAC,EAAIE,GAAK,EAAID,EAAG,CAAC,EACnFE,GAAM,EAAIL,EAAG,CAAC,EAAI,EAAIK,GAAM,EAAID,EAAIH,EAAG,CAAC,EAAI,EAAII,EAAKD,GAAK,EAAIF,EAAG,CAAC,EAAIE,GAAK,EAAID,EAAG,CAAC,CACvF,CACA,CAWA,SAASG,EAAYC,EAAK,CACxB,MAAMC,EAAS,CAAA,EACf,IAAIC,EAAU,CAAC,EAAG,CAAC,EAEnB,SAAW,CAAE,GAAAC,EAAI,KAAAC,CAAI,IAAMJ,EACzB,OAAQG,EAAE,CACR,IAAK,OACHD,EAAU,CAACE,EAAK,CAAC,EAAGA,EAAK,CAAC,CAAC,EAC3BH,EAAO,KAAK,CAAC,GAAGC,CAAO,CAAC,EACxB,MAEF,IAAK,SACHA,EAAU,CAACE,EAAK,CAAC,EAAGA,EAAK,CAAC,CAAC,EAC3BH,EAAO,KAAK,CAAC,GAAGC,CAAO,CAAC,EACxB,MAEF,IAAK,WAAY,CACf,KAAM,CAACG,EAAKC,EAAKC,EAAKC,EAAKC,EAAGC,CAAC,EAAIN,EAC7BX,EAAKS,EACLR,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