Skip to content

Instantly share code, notes, and snippets.

@myaosato
Created June 14, 2025 01:45
Show Gist options
  • Select an option

  • Save myaosato/2f6a9d70c155b20ae0dcda0c3625cb85 to your computer and use it in GitHub Desktop.

Select an option

Save myaosato/2f6a9d70c155b20ae0dcda0c3625cb85 to your computer and use it in GitHub Desktop.
トーン
<!DOCTYPE html>
<html>
<head>
<title>TONE</title>
</head>
<body style="margin:0;text-align: center;">
<canvas id="canvas" width="700" height="700"></canvas>
<script>
/** @type {HTMLCanvasElement} */
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const tone = (s, l) => {
const x = 50 + s * 6;
const y = 700 - (50 + l * 6);
const r = 40;
//
for (let h = 0; h < 12; h++) {
const cx = x + r * Math.cos((h / 12) * Math.PI * 2);
const cy = y - r * Math.sin((h / 12) * Math.PI * 2);
const hc = 0; // - (10 + (100 - s) * 0.1);
const sc = (l - 50); // 補正をいれた。
//
ctx.save();
ctx.fillStyle = `hsl(${Math.round((h / 12) * 360 + hc)}deg ${Math.min(s + sc, 100)}% ${l}%)`;
ctx.translate(cx, cy);
ctx.beginPath();
ctx.arc(0, 0, r / 5, 0, 2 * Math.PI);
ctx.fill();
ctx.restore();
}
};
//
tone(80, 50);
tone(60, 40);
tone(60, 60);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment