@editframe/elements 0.15.0-beta.13 → 0.15.0-beta.15
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/elements/EFMedia.d.ts +5 -4
- package/dist/elements/EFMedia.js +111 -49
- package/dist/elements/EFWaveform.d.ts +0 -1
- package/dist/elements/EFWaveform.js +5 -26
- package/package.json +2 -2
- package/src/elements/EFMedia.ts +156 -58
- package/src/elements/EFWaveform.ts +5 -42
- package/types.json +1 -1
|
@@ -164,7 +164,7 @@ export class EFWaveform extends EFTemporal(TWMixin(LitElement)) {
|
|
|
164
164
|
const path = new Path2D();
|
|
165
165
|
|
|
166
166
|
frequencyData.forEach((value, i) => {
|
|
167
|
-
const normalizedValue =
|
|
167
|
+
const normalizedValue = value / 255;
|
|
168
168
|
const barHeight = normalizedValue * waveHeight;
|
|
169
169
|
const y = (waveHeight - barHeight) / 2;
|
|
170
170
|
const x = waveWidth * paddingOuter + i * (barWidth * (1 + paddingInner));
|
|
@@ -190,7 +190,7 @@ export class EFWaveform extends EFTemporal(TWMixin(LitElement)) {
|
|
|
190
190
|
const maxBricks = Math.floor(waveHeight / (boxSize + verticalGap)); // Account for gaps in height calculation
|
|
191
191
|
|
|
192
192
|
frequencyData.forEach((value, i) => {
|
|
193
|
-
const normalizedValue =
|
|
193
|
+
const normalizedValue = value / 255;
|
|
194
194
|
const brickCount = Math.floor(normalizedValue * maxBricks);
|
|
195
195
|
|
|
196
196
|
for (let j = 0; j < brickCount; j++) {
|
|
@@ -225,7 +225,7 @@ export class EFWaveform extends EFTemporal(TWMixin(LitElement)) {
|
|
|
225
225
|
const path = new Path2D();
|
|
226
226
|
|
|
227
227
|
frequencyData.forEach((value, i) => {
|
|
228
|
-
const normalizedValue =
|
|
228
|
+
const normalizedValue = value / 255;
|
|
229
229
|
const height = normalizedValue * waveHeight; // Use full wave height like in drawBars
|
|
230
230
|
const x = waveWidth * paddingOuter + i * (barWidth * (1 + paddingInner));
|
|
231
231
|
const y = (waveHeight - height) / 2; // Center vertically
|
|
@@ -238,42 +238,6 @@ export class EFWaveform extends EFTemporal(TWMixin(LitElement)) {
|
|
|
238
238
|
ctx.fill(path);
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
protected drawEqualizer(
|
|
242
|
-
ctx: CanvasRenderingContext2D,
|
|
243
|
-
frequencyData: Uint8Array,
|
|
244
|
-
) {
|
|
245
|
-
const canvas = ctx.canvas;
|
|
246
|
-
const waveWidth = canvas.width;
|
|
247
|
-
const waveHeight = canvas.height;
|
|
248
|
-
const baseline = waveHeight / 2;
|
|
249
|
-
const barWidth = (waveWidth / frequencyData.length) * 0.8;
|
|
250
|
-
|
|
251
|
-
ctx.clearRect(0, 0, waveWidth, waveHeight);
|
|
252
|
-
|
|
253
|
-
// Create paths for baseline and bars
|
|
254
|
-
const baselinePath = new Path2D();
|
|
255
|
-
const barsPath = new Path2D();
|
|
256
|
-
|
|
257
|
-
// Draw baseline
|
|
258
|
-
baselinePath.moveTo(0, baseline);
|
|
259
|
-
baselinePath.lineTo(waveWidth, baseline);
|
|
260
|
-
|
|
261
|
-
// Draw bars
|
|
262
|
-
frequencyData.forEach((value, i) => {
|
|
263
|
-
const height = (value / 255) * (waveHeight / 2);
|
|
264
|
-
const x = i * (waveWidth / frequencyData.length);
|
|
265
|
-
const y = baseline - height;
|
|
266
|
-
barsPath.rect(x, y, barWidth, Math.max(height * 2, 1));
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
// Render baseline
|
|
270
|
-
ctx.lineWidth = 2;
|
|
271
|
-
ctx.stroke(baselinePath);
|
|
272
|
-
|
|
273
|
-
// Render bars
|
|
274
|
-
ctx.fill(barsPath);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
241
|
protected drawLine(ctx: CanvasRenderingContext2D, frequencyData: Uint8Array) {
|
|
278
242
|
const canvas = ctx.canvas;
|
|
279
243
|
const waveWidth = canvas.width;
|
|
@@ -283,7 +247,7 @@ export class EFWaveform extends EFTemporal(TWMixin(LitElement)) {
|
|
|
283
247
|
const path = new Path2D();
|
|
284
248
|
|
|
285
249
|
// Sample fewer points to make sharp angles more visible
|
|
286
|
-
const sampleRate =
|
|
250
|
+
const sampleRate = 1; // Only use every 4th point
|
|
287
251
|
|
|
288
252
|
for (let i = 0; i < frequencyData.length; i += sampleRate) {
|
|
289
253
|
const x = (i / frequencyData.length) * waveWidth;
|
|
@@ -295,7 +259,6 @@ export class EFWaveform extends EFTemporal(TWMixin(LitElement)) {
|
|
|
295
259
|
path.lineTo(x, y);
|
|
296
260
|
}
|
|
297
261
|
}
|
|
298
|
-
|
|
299
262
|
// Ensure we draw to the end
|
|
300
263
|
const lastX = waveWidth;
|
|
301
264
|
const lastY =
|
|
@@ -351,7 +314,7 @@ export class EFWaveform extends EFTemporal(TWMixin(LitElement)) {
|
|
|
351
314
|
const path = new Path2D();
|
|
352
315
|
|
|
353
316
|
frequencyData.forEach((value, i) => {
|
|
354
|
-
const normalizedValue =
|
|
317
|
+
const normalizedValue = value / 255;
|
|
355
318
|
const x = i * (waveWidth / frequencyData.length);
|
|
356
319
|
const barHeight = normalizedValue * (waveHeight / 2); // Half height since we extend both ways
|
|
357
320
|
const y = baseline - barHeight;
|