그라데이션 메시 팔레트

Gradient mesh palette

여러 색을 점으로 흩뿌려 부드럽게 섞은 그라데이션. 하나의 방향이 아니라 여러 색이 안개처럼 번지며 뒤섞입니다.

다른 이름: Mesh gradient메시 그라디언트
···
html
<div class="wrap">
  <canvas id="cv" width="480" height="220"></canvas>
  <div class="sws" id="sws"></div>
</div>
css
.wrap{width:min(480px,94%);display:grid;gap:8px}
canvas{width:100%;height:auto;aspect-ratio:16/8;border-radius:16px;border:1px solid var(--line);display:block}
.sws{display:flex;gap:6px;justify-content:center}
.sws div{display:grid;gap:3px;justify-items:center}
.sws i{display:block;width:clamp(16px,4vmin,22px);height:clamp(16px,4vmin,22px);border-radius:6px;border:1px solid var(--line)}
.sws b{font:700 clamp(6px,1.6vmin,8px)/1 ui-monospace,monospace;color:var(--muted)}
js
var PALETTES = [
  ['#5b5bf7', '#f25c8a', '#18c29c', '#facc15'],
  ['#f97316', '#ec4899', '#8b5cf6', '#22d3ee'],
  ['#0ea5e9', '#a3e635', '#f43f5e', '#fbbf24'],
];
var idx = 0;
var cv = document.getElementById('cv'), ctx = cv.getContext('2d');
var W = cv.width, H = cv.height;
var sws = document.getElementById('sws');
function layout() {
  sws.innerHTML = PALETTES[idx].map(function (h, i) { return '<div><i id="s' + i + '"></i><b>' + h + '</b></div>'; }).join('');
}
layout();
var t = 0;
function pos(i, n) {
  var a = t * 0.4 + i * (Math.PI * 2 / n);
  return [W * (0.5 + 0.34 * Math.cos(a)), H * (0.5 + 0.34 * Math.sin(a * 1.3))];
}
function draw() {
  ctx.clearRect(0, 0, W, H);
  ctx.filter = 'blur(46px)';
  var colors = PALETTES[idx];
  colors.forEach(function (hex, i) {
    var p = pos(i, colors.length);
    var r = W * 0.5;
    var g = ctx.createRadialGradient(p[0], p[1], 0, p[0], p[1], r);
    g.addColorStop(0, hex);
    g.addColorStop(1, 'transparent');
    ctx.fillStyle = g;
    ctx.beginPath();
    ctx.arc(p[0], p[1], r, 0, Math.PI * 2);
    ctx.fill();
  });
}
(function tick() {
  t += 0.01;
  draw();
  requestAnimationFrame(tick);
})();
setInterval(function () { idx = (idx + 1) % PALETTES.length; layout(); }, 3400);

선형·원형 그라데이션은 색이 두세 개, 한 방향으로만 번집니다. 메시 그라데이션은 캔버스 위 여러 지점에 색을 하나씩 놓고 각각을 크게 블러 처리해서 겹치게 만듭니다 — 결과적으로 하나의 "방향"이 없는, 안개처럼 얼룩진 배경이 됩니다.

구현은 생각보다 단순합니다. 색 점마다 radial-gradient(중심색 → 투명)를 그리고 캔버스 전체에 blur 필터를 걸어 경계를 지웁니다. 점의 위치를 시간에 따라 천천히 움직이면 배경이 살아있는 것처럼 흘러갑니다.

정적 이미지 대신 매번 계산해서 그리므로, 같은 코드로 색 조합만 바꿔 끝없이 다른 배경을 만들 수 있습니다. 히어로 섹션 배경, 로딩 화면처럼 "생동감은 필요하지만 주의를 뺏으면 안 되는" 자리에 잘 맞습니다.

언제 쓰나

히어로 배경·로딩 화면처럼 시선을 뺏지 않으면서 생동감이 필요한 자리에 씁니다. 텍스트가 위에 올라가면 대비를 꼭 확인하세요.