Skip to content

Commit 754ae0a

Browse files
committed
poc
1 parent 20c5343 commit 754ae0a

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

poc/index.html

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<!doctype html>
2+
<html lang="fr">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<title>Rectangles (écrans) sur canvas</title>
7+
<style>
8+
html, body { height: 100%; margin: 0; }
9+
canvas { display: block; background: #0b0d10; }
10+
</style>
11+
</head>
12+
<body>
13+
<canvas id="c"></canvas>
14+
15+
<script>
16+
const canvas = document.getElementById("c");
17+
const ctx = canvas.getContext("2d");
18+
19+
function resize() {
20+
canvas.width = window.innerWidth;
21+
canvas.height = window.innerHeight;
22+
draw();
23+
}
24+
window.addEventListener("resize", resize);
25+
26+
// 3 rectangles "écrans" en coordonnées globales
27+
// (x, y, w, h)
28+
const outputs = [
29+
{ x: 0, y: 0, w: 480, h: 240 }, // écran 1
30+
{ x: 480, y: 48, w: 480, h: 240 }, // écran 2 (collé à droite)
31+
{ x: 960, y: 0, w: 480, h: 240 }, // écran 3 (collé en bas de l'écran 2)
32+
];
33+
34+
function drawGrid(step = 16) {
35+
ctx.save();
36+
ctx.globalAlpha = 0.25;
37+
ctx.strokeStyle = "#2b2f36";
38+
ctx.lineWidth = 1;
39+
40+
for (let x = 0; x <= canvas.width; x += step) {
41+
ctx.beginPath();
42+
ctx.moveTo(x, 0);
43+
ctx.lineTo(x, canvas.height);
44+
ctx.stroke();
45+
}
46+
for (let y = 0; y <= canvas.height; y += step) {
47+
ctx.beginPath();
48+
ctx.moveTo(0, y);
49+
ctx.lineTo(canvas.width, y);
50+
ctx.stroke();
51+
}
52+
ctx.restore();
53+
}
54+
55+
function draw() {
56+
ctx.clearRect(0, 0, canvas.width, canvas.height);
57+
drawGrid(16);
58+
59+
// Dessin des rectangles
60+
ctx.font = "14px system-ui, sans-serif";
61+
outputs.forEach((r, i) => {
62+
// remplissage
63+
ctx.fillStyle = "rgba(80, 160, 255, 0.18)";
64+
ctx.fillRect(r.x, r.y, r.w, r.h);
65+
66+
// bordure
67+
ctx.strokeStyle = "#a8c7ff";
68+
ctx.lineWidth = 2;
69+
ctx.strokeRect(r.x, r.y, r.w, r.h);
70+
71+
// label
72+
ctx.fillStyle = "#e8eefc";
73+
ctx.fillText(
74+
`Output ${i + 1} (${r.x},${r.y}) ${r.w}x${r.h}`,
75+
r.x + 10,
76+
r.y + 22
77+
);
78+
});
79+
}
80+
81+
resize();
82+
</script>
83+
</body>
84+
</html>

0 commit comments

Comments
 (0)