-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspeaker-matrix.html
More file actions
101 lines (87 loc) · 2.78 KB
/
speaker-matrix.html
File metadata and controls
101 lines (87 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Speaker Matrix</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
margin: 0;
font-family: sans-serif;
gap: 1rem;
}
canvas {
border: 4px solid #f5f5f5;
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}
</style>
</head>
<body>
<h1>Speaker Matrix</h1>
<canvas id="speakerCanvas"></canvas>
<button id="exportBtn"
style="padding: 10px 20px; font-size: 16px; background: #007acc; color: white; border: none; border-radius: 4px; cursor: pointer;">Export
as JPG</button>
<script>
const TILE_WIDTH = 240;
const TILE_HEIGHT = 240;
const COLUMNS = 4;
const ROWS = 2;
const imageUrls = [
'./assets/speakers/hannah-duo.jpg',
'./assets/speakers/asim-duo.jpg',
'./assets/speakers/sacha-duo.jpg',
'./assets/speakers/surya-duo.jpg',
'./assets/speakers/hellen-duo.jpg',
'./assets/speakers/jessica-eda-duo.jpg',
'./assets/speakers/chetan-duo.jpg',
'./assets/speakers/serges-duo.jpg',
];
const canvas = document.getElementById('speakerCanvas');
canvas.width = TILE_WIDTH * COLUMNS;
canvas.height = TILE_HEIGHT * ROWS;
const ctx = canvas.getContext('2d');
function drawMatrix(images) {
images.forEach((image, index) => {
const column = index % COLUMNS;
const row = Math.floor(index / COLUMNS);
const x = column * TILE_WIDTH;
const y = row * TILE_HEIGHT;
ctx.drawImage(image, x, y, TILE_WIDTH, TILE_HEIGHT);
});
}
async function loadImages(urls) {
const loaders = urls.map(
url =>
new Promise((resolve, reject) => {
const img = new Image();
img.crossOrigin = 'anonymous';
img.onload = () => resolve(img);
img.onerror = () => reject(new Error(`Failed to load ${url}`));
img.src = url;
})
);
return Promise.all(loaders);
}
loadImages(imageUrls)
.then(drawMatrix)
.catch(error => {
console.error(error);
ctx.fillStyle = '#f5f5f5';
ctx.font = '20px sans-serif';
ctx.fillText('Failed to load images', 20, TILE_HEIGHT);
});
// Export functionality
document.getElementById('exportBtn').addEventListener('click', function () {
const link = document.createElement('a');
link.download = 'speaker-matrix.jpg';
link.href = canvas.toDataURL('image/jpeg', 0.9);
link.click();
});
</script>
</body>
</html>