reframe-video 0.1.1 → 0.1.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.
@@ -85,6 +85,29 @@ function drawDisplayList(ctx, ops, images) {
85
85
  }
86
86
  break;
87
87
  }
88
+ case "path": {
89
+ const p = new Path2D(op.d);
90
+ if (op.fill) {
91
+ ctx.fillStyle = op.fill;
92
+ ctx.fill(p);
93
+ }
94
+ if (op.stroke && (op.strokeWidth ?? 1) > 0) {
95
+ ctx.strokeStyle = op.stroke;
96
+ ctx.lineWidth = op.strokeWidth ?? 1;
97
+ ctx.lineJoin = "round";
98
+ ctx.lineCap = "round";
99
+ if (op.progress < 1) {
100
+ const len = pathLength(op.d);
101
+ if (len > 0) {
102
+ ctx.setLineDash([len, len]);
103
+ ctx.lineDashOffset = len * (1 - op.progress);
104
+ }
105
+ }
106
+ ctx.stroke(p);
107
+ ctx.setLineDash([]);
108
+ }
109
+ break;
110
+ }
88
111
  case "text": {
89
112
  ctx.font = `${op.fontWeight} ${op.fontSize}px ${quoteFamily(op.fontFamily)}`;
90
113
  if (op.letterSpacing) ctx.letterSpacing = `${op.letterSpacing}px`;
@@ -102,6 +125,19 @@ function drawDisplayList(ctx, ops, images) {
102
125
  function quoteFamily(family) {
103
126
  return family.includes(" ") && !family.includes('"') ? `"${family}"` : family;
104
127
  }
128
+ var pathLengthCache = /* @__PURE__ */ new Map();
129
+ function pathLength(d) {
130
+ const hit = pathLengthCache.get(d);
131
+ if (hit !== void 0) return hit;
132
+ let len = 0;
133
+ if (typeof document !== "undefined") {
134
+ const el = document.createElementNS("http://www.w3.org/2000/svg", "path");
135
+ el.setAttribute("d", d);
136
+ len = el.getTotalLength();
137
+ }
138
+ pathLengthCache.set(d, len);
139
+ return len;
140
+ }
105
141
  export {
106
142
  drawDisplayList,
107
143
  renderFrame