ステータスアップ
背景エフェクト / 動く素材トップ
記号が下から上へ抜け、上ほど速く薄くなる。
試して調整する#
判断#
向く場面: ゲーミング。上へ抜ける勢い。
避ける場面: 長文の背面や、写真そのものを主役にする画面。
つまみは元の実装が持っている項目そのままです。実際に文字を重ねた状態で速さと密度を詰めます。
組み込み条件#
依存: 素のCanvas 2D。外部ライブラリは要らない。
負荷: 1画面に1つ。画面外・非表示タブ・動きを減らす設定で止まる。
再利用: コピーした単一HTMLがそのまま動く。
単一HTMLをコピーする#
下のコードだけで実物サンプルと同じ画面が動きます。調整欄を動かすと、値を反映したコードへ更新されます。
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="robots" content="noindex,follow">
<title>ステータスアップ 実物サンプル</title>
<style>
:root {
color-scheme: light dark;
--ink-light:#1a2421; --mut-light:#5a6a72; --signal-light:#2a7ab8; --bg-light:#f4f8fb;
--ink-dark:#f4f8fb; --mut-dark:#a8bac7; --signal-dark:#48b8ff; --bg-dark:#07111f;
}
* { box-sizing:border-box; }
html,body { margin:0; min-height:100%; }
body { font-family:"Hiragino Sans","Yu Gothic UI",system-ui,sans-serif; transition:background .3s,color .3s; }
html[data-demo-theme="light"], html[data-demo-theme="light"] body {
background:var(--bg-light); color:var(--ink-light); --ink:var(--ink-light); --mut:var(--mut-light); --signal:var(--signal-light); }
html[data-demo-theme="dark"], html[data-demo-theme="dark"] body {
background:var(--bg-dark); color:var(--ink-dark); --ink:var(--ink-dark); --mut:var(--mut-dark); --signal:var(--signal-dark); }
@media (prefers-color-scheme:light) {
html:not([data-demo-theme]), html:not([data-demo-theme]) body {
background:var(--bg-light); color:var(--ink-light); --ink:var(--ink-light); --mut:var(--mut-light); --signal:var(--signal-light); } }
@media (prefers-color-scheme:dark) {
html:not([data-demo-theme]), html:not([data-demo-theme]) body {
background:var(--bg-dark); color:var(--ink-dark); --ink:var(--ink-dark); --mut:var(--mut-dark); --signal:var(--signal-dark); } }
.sample { position:relative; min-height:100dvh; overflow:hidden; isolation:isolate; display:grid; align-items:end; }
.effect { position:absolute; inset:0; z-index:0; }
.effect canvas { display:block; width:100%; height:100%; touch-action:manipulation; }
.copy { position:relative; z-index:1; width:min(42rem,100%); padding:clamp(2rem,7vw,6rem); }
.label { margin:0 0 1rem; color:var(--signal); font:600 .72rem/1.4 ui-monospace,Consolas,monospace; letter-spacing:.16em; }
h1 { margin:0; max-width:14ch; font-size:clamp(2rem,5.5vw,4.5rem); line-height:1.05; letter-spacing:-.04em; }
.lead { margin:1.5rem 0 0; max-width:36rem; color:var(--mut); font-size:clamp(.95rem,1.4vw,1.1rem); line-height:1.85; }
.readout { position:absolute; inset:1.5rem 1.5rem auto auto; margin:0; color:var(--mut); font:500 .68rem/1.6 ui-monospace,Consolas,monospace; letter-spacing:.1em; writing-mode:vertical-rl; z-index:2; }
.theme-toggle { position:absolute; inset:1.5rem auto auto 1.5rem; z-index:2; display:flex; gap:.25rem; }
.theme-toggle button {
min-block-size:36px; padding-inline:.75rem; font:600 .72rem/1 ui-monospace,Consolas,monospace;
letter-spacing:.08em; border:1px solid var(--mut); background:transparent; color:var(--ink); cursor:pointer; border-radius:4px; }
.theme-toggle button[aria-pressed="true"] { background:var(--signal); color:var(--bg-dark); border-color:var(--signal); }
@media (max-width:640px) { .copy{padding:2rem 1.25rem 3rem}.readout{display:none} }
.bare .copy, .bare .readout, .bare .theme-toggle { display:none; }
</style>
</head>
<body>
<script id="effect-config" type="application/json">{"status-up-alpha":1.0,"status-up-count":35,"status-up-hue":40,"status-up-theme":0}</script>
<script>if (/[?&]bare=1/.test(location.search)) document.documentElement.classList.add('bare');
if (/[?&]tap=1/.test(location.search)) { addEventListener('load', function () {
setTimeout(function () { [[0.5,0.5],[0.3,0.6],[0.7,0.4]].forEach(function (p, i) {
setTimeout(function () { document.dispatchEvent(new MouseEvent('click',
{clientX: innerWidth * p[0], clientY: innerHeight * p[1], bubbles: true})); }, i * 220);
}); }, 300); }); }</script>
<script>(function(){var m=location.hash.match(/[#&]cfg=([^&]*)/);if(!m)return;
try{JSON.parse(decodeURIComponent(m[1]));document.getElementById('effect-config').textContent=decodeURIComponent(m[1]);}catch(e){}})();</script>
<script>(function(){
var root=document.documentElement, cfgNode=document.getElementById('effect-config');
var themeKeys=["status-up-theme"];
function syncTheme(t){
root.setAttribute('data-demo-theme',t);
document.querySelectorAll('.theme-toggle button').forEach(function(b){
b.setAttribute('aria-pressed',b.dataset.theme===t?'true':'false');});
if(!themeKeys.length)return;
try{var cfg=JSON.parse(cfgNode.textContent||'{}');
themeKeys.forEach(function(k){cfg[k]=t==='dark'?0:1;});
cfgNode.textContent=JSON.stringify(cfg);}catch(e){}
}
var fixed="dark";
if(fixed){syncTheme(fixed);}else{var q=location.search.match(/[?&]theme=(light|dark)/); if(q) syncTheme(q[1]);}
addEventListener('DOMContentLoaded',function(){
document.querySelectorAll('.theme-toggle button').forEach(function(b){
b.addEventListener('click',function(){syncTheme(b.dataset.theme);});});});})();</script>
<main class="sample">
<div class="theme-toggle" aria-label="配色切替" hidden>
<button type="button" data-theme="light" aria-pressed="false">LIGHT</button>
<button type="button" data-theme="dark" aria-pressed="false">DARK</button>
</div>
<div class="effect" aria-hidden="true"><canvas id="effect-canvas"></canvas></div>
<div class="copy">
<p class="label">背景エフェクト</p>
<h1>ステータスアップ</h1>
<p class="lead">記号が下から上へ抜け、上ほど速く薄くなる。ゲーミング。上へ抜ける勢い。</p>
</div>
<p class="readout">単一HTML・動きを減らす設定に対応</p>
</main>
<script>
/* ---- ここから下は AK²Engine の実装をそのまま持ってきたもの ------------- */
/**
* AK²-Engine / effects/status-up.js
* =====================================
* ステータスアップエフェクト(StatusUpEffect)
*
* I字型の縦長の光の棒が画面下部からまっすぐ上へ上昇する。
* 上端は明るく、下方向へグラデーションで消えていく。
* ゲームのバフ・ステータスアップ・パワーアップ・達成感の演出に。
* 上昇炎粒(Ember)がゆらぎながら上昇するのに対し、
* こちらは直線的にまっすぐ上昇する。
*
* ── CSS 変数による設定 ─────────────────────────────
*
* --status-up-count
* 同時に存在できる最大バー数
* デフォルト: 35
* 推奨範囲: 10(控えめ)〜 70(派手)
* カードプレビュー用: 12〜20
*
* --status-up-alpha
* アルファ係数 0〜1
* デフォルト: 1.0(= 最大 0.9 の標準輝度)
* 推奨範囲: 0.4(淡い)〜 1.5(強烈)
*
* --status-up-hue
* バーの基本色相 0〜360
* デフォルト: 40(黄オレンジ)
* 推奨例: 28(オレンジ), 40(黄金), 60(黄), 120(緑・HP回復系)
*
* --status-up-theme
* 背景テーマ切替
* デフォルト: dark(lighter合成・黒背景向け)
* 白背景: light(source-over合成・濃いオレンジ)
*
* 使い方:
* AK2.register(new StatusUpEffect());
*/
class BgEffectStatusUp {
/** @type {object} コンストラクタオプション(CSS変数より優先) */
#options = {};
/** @param {{{ count?: number, alpha?: number, hue?: number, theme?: string }}} options */
constructor(options = {}) {
this.#options = options;
}
/** @type {number} */
#w = 0;
/** @type {number} */
#h = 0;
/** @type {Array<object>} */
#bars = [];
/** @type {number} 次の粒子生成タイマー(秒) */
#spawnTimer = 0;
/**
* 最大バー数 — CSS 変数 --status-up-count で上書き可
* デフォルト: 35 | 推奨: 10〜70
* @type {number}
*/
#count = 35;
/**
* アルファ係数 — CSS 変数 --status-up-alpha で上書き可
* デフォルト: 1.0 | 推奨: 0.4〜1.5
* @type {number}
*/
#alphaScale = 1.0;
/**
* 基本色相 — CSS 変数 --status-up-hue で上書き可
* デフォルト: 40(黄オレンジ)| 推奨: 0〜360
* @type {number}
*/
#hue = 40;
/**
* テーマ — CSS 変数 --status-up-theme で上書き可
* 'dark'(デフォルト)| 'light'(白背景用)
* @type {string}
*/
#theme = 'dark';
// ── AK²Engine インターフェイス ─────────────────
init(canvas, _ctx) {
this.#w = canvas.width;
this.#h = canvas.height;
const style = getComputedStyle(document.documentElement);
const n = parseInt(style.getPropertyValue('--status-up-count'));
const a = parseFloat(style.getPropertyValue('--status-up-alpha'));
const hue = parseFloat(style.getPropertyValue('--status-up-hue'));
const theme = style.getPropertyValue('--status-up-theme').trim();
if (n > 0) this.#count = n;
if (!isNaN(a)) this.#alphaScale = a;
if (!isNaN(hue)) this.#hue = hue;
if (theme === 'light') this.#theme = 'light';
// コンストラクタオプションは CSS 変数より優先(セクション個別指定に使用)
if (this.#options.count !== undefined) this.#count = this.#options.count;
if (this.#options.alpha !== undefined) this.#alphaScale = this.#options.alpha;
if (this.#options.hue !== undefined) this.#hue = this.#options.hue;
if (this.#options.theme !== undefined) this.#theme = this.#options.theme;
// 初期状態として画面内に分散配置
const initial = Math.ceil(this.#count * 0.6);
for (let i = 0; i < initial; i++) {
const b = this.#createBar();
// ランダムに上昇途中の状態から開始
b.life -= Math.random() * b.maxLife * 0.9;
this.#bars.push(b);
}
}
onResize(w, h) {
this.#w = w;
this.#h = h;
}
/**
* @param {number} dt - 前フレームからの経過ミリ秒
*/
update(dt) {
const dts = dt / 1000;
// 新しいバーを補充
this.#spawnTimer -= dts;
if (this.#spawnTimer <= 0 && this.#bars.length < this.#count) {
this.#bars.push(this.#createBar());
this.#spawnTimer = 0.05 + Math.random() * 0.12;
}
for (let i = this.#bars.length - 1; i >= 0; i--) {
const b = this.#bars[i];
b.life -= dts;
if (b.life <= 0) { this.#bars.splice(i, 1); continue; }
const progress = 1 - b.life / b.maxLife; // 0(誕生)→ 1(消滅)
// まっすぐ上昇(横揺れなし)
b.y -= b.vy * dts;
// アルファ:最初の15%でフェードイン、最後の25%でフェードアウト
const fadeIn = Math.min(1, progress / 0.15);
const fadeOut = progress < 0.75 ? 1 : Math.max(0, 1 - (progress - 0.75) / 0.25);
b.alpha = Math.min(fadeIn, fadeOut) * b.maxAlpha * this.#alphaScale;
}
}
/**
* @param {CanvasRenderingContext2D} ctx
*/
draw(ctx) {
if (this.#bars.length === 0) return;
ctx.save();
ctx.globalCompositeOperation = this.#theme === 'light' ? 'source-over' : 'lighter';
this.#bars.forEach(b => {
if (b.alpha < 0.01) return;
const hue = this.#hue;
const topY = b.y - b.h;
const bottomY = b.y;
if (this.#theme === 'light') {
// 白背景用: 濃いオレンジ/琥珀(source-over)
const gGlow = ctx.createLinearGradient(b.x, topY, b.x, bottomY);
gGlow.addColorStop(0, `hsla(${hue + 15}, 80%, 30%, ${b.alpha * 0.3})`);
gGlow.addColorStop(0.5, `hsla(${hue}, 80%, 25%, ${b.alpha * 0.15})`);
gGlow.addColorStop(1, `hsla(${hue - 10}, 70%, 20%, 0)`);
ctx.fillStyle = gGlow;
ctx.fillRect(b.x - b.w * 3, topY, b.w * 6, b.h);
const gCore = ctx.createLinearGradient(b.x, topY, b.x, bottomY);
gCore.addColorStop(0, `hsla(${hue + 20}, 90%, 40%, ${b.alpha})`);
gCore.addColorStop(0.30, `hsla(${hue + 10}, 90%, 35%, ${b.alpha * 0.9})`);
gCore.addColorStop(0.65, `hsla(${hue}, 90%, 30%, ${b.alpha * 0.6})`);
gCore.addColorStop(1, `hsla(${hue - 10}, 80%, 20%, 0)`);
ctx.fillStyle = gCore;
ctx.fillRect(b.x - b.w / 2, topY, b.w, b.h);
} else {
// ダーク背景用: lighter合成前提の明るい色
const gGlow = ctx.createLinearGradient(b.x, topY, b.x, bottomY);
gGlow.addColorStop(0, `hsla(${hue + 30}, 100%, 90%, ${b.alpha * 0.4})`);
gGlow.addColorStop(0.5, `hsla(${hue + 10}, 100%, 70%, ${b.alpha * 0.2})`);
gGlow.addColorStop(1, `hsla(${hue}, 100%, 55%, 0)`);
ctx.fillStyle = gGlow;
ctx.fillRect(b.x - b.w * 3, topY, b.w * 6, b.h);
const gCore = ctx.createLinearGradient(b.x, topY, b.x, bottomY);
gCore.addColorStop(0, `hsla(${hue + 40}, 100%, 98%, ${b.alpha})`);
gCore.addColorStop(0.25, `hsla(${hue + 20}, 100%, 85%, ${b.alpha * 0.95})`);
gCore.addColorStop(0.60, `hsla(${hue}, 100%, 65%, ${b.alpha * 0.7})`);
gCore.addColorStop(1, `hsla(${hue - 10}, 100%, 45%, 0)`);
ctx.fillStyle = gCore;
ctx.fillRect(b.x - b.w / 2, topY, b.w, b.h);
}
});
ctx.restore();
}
// ── 内部処理 ─────────────────────────────────
#createBar() {
const maxLife = 1.2 + Math.random() * 2.0;
return {
x: this.#w * (0.05 + Math.random() * 0.9), // 画面横幅いっぱいに分散
y: this.#h * (0.15 + Math.random() * 0.95), // ランダムな高さから出現
vy: 55 + Math.random() * 65, // 上昇速度 px/秒(均一な速さ)
w: 1.5 + Math.random() * 1.5, // バー幅(細い: 1.5〜3px)
h: 20 + Math.random() * 35, // バー高さ(I字の長さ)
maxAlpha: 0.35 + Math.random() * 0.15, // alpha を半分に抑制
life: maxLife,
maxLife,
alpha: 0,
};
}
}
// AK²Engine に登録
window.BgEffectStatusUp = BgEffectStatusUp;
/* ---- ここまで。以下は、この資料で回すための呼び出し ------------------- */
(function () {
var canvas = document.getElementById('effect-canvas');
var ctx = canvas.getContext('2d');
var cfgNode = document.getElementById('effect-config');
var reduced = matchMedia('(prefers-reduced-motion: reduce)');
var eff = null, raf = 0, last = 0, W = 1, H = 1, active = true;
var VARS = {"status-up-alpha": "--status-up-alpha", "status-up-count": "--status-up-count", "status-up-hue": "--status-up-hue", "status-up-theme": "--status-up-theme"};
function applyVars(cfg) {
Object.keys(VARS).forEach(function (k) {
if (cfg[k] !== undefined && cfg[k] !== null) {
document.documentElement.style.setProperty(VARS[k], String(cfg[k]));
}
});
}
function measure() {
var box = canvas.getBoundingClientRect();
W = Math.max(1, Math.round(box.width));
H = Math.max(1, Math.round(box.height));
}
function build(cfg) {
applyVars(cfg);
measure();
canvas.width = W; canvas.height = H; /* init は canvas.width を読む */
eff = new BgEffectStatusUp({});
if (eff.init) eff.init(canvas, ctx);
fit();
}
function fit() {
measure();
var dpr = Math.min(2, window.devicePixelRatio || 1);
canvas.width = Math.round(W * dpr);
canvas.height = Math.round(H * dpr);
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
if (eff && eff.onResize) eff.onResize(W, H);
}
function paint(dt) {
/* 描く直前に実寸を見る。読み込みの順によっては、最初の計測で幅0が返る
(Browser ペインで 1x958 の buffer になった。ResizeObserver だけでは
戻らないことがあるので、毎フレーム安く確かめる) */
var box = canvas.getBoundingClientRect();
if (Math.abs(Math.round(box.width) - W) > 1 || Math.abs(Math.round(box.height) - H) > 1) {
fit();
}
ctx.clearRect(0, 0, W, H);
if (!eff) return;
if (eff.update) eff.update(dt);
if (eff.draw) eff.draw(ctx);
}
function report() {
document.documentElement.dataset.materialActive = String(active);
document.documentElement.dataset.materialRunning = String(raf !== 0);
}
function stop() { if (raf) cancelAnimationFrame(raf); raf = 0; report(); }
function loop(time) {
if (!active || reduced.matches || document.hidden) { stop(); paint(16.67); return; }
var dt = last ? Math.min(60, time - last) : 16.67;
last = time;
paint(dt);
raf = requestAnimationFrame(loop);
report();
}
function start() {
stop(); last = 0;
if (active && !reduced.matches && !document.hidden) raf = requestAnimationFrame(loop);
else paint(16.67);
report();
}
addEventListener('message', function (e) {
var d = e.data || {};
if (d.type === 'material-config') {
cfgNode.textContent = JSON.stringify(d.values || {});
build(d.values || {});
start();
}
if (d.type === 'material-active') { active = d.active === true; start(); }
});
document.addEventListener('visibilitychange', start);
reduced.addEventListener('change', start);
new ResizeObserver(fit).observe(canvas);
addEventListener('pagehide', stop, {once: true});
build(JSON.parse(cfgNode.textContent));
start();
})();
</script>
</body>
</html>
AIエージェントへ渡す場合は、「このHTMLを対象ページのヒーロー背景へ組み込み、文字と主要ボタンを前面に残してください」と添えます。
組み込み時の確認#
prefers-reduced-motion: reduceで静止する- 画面外と非表示タブで描画が止まる
- 背景を止めても文字の階層と構図が成立する
- 文字とのコントラストを実際の配色で測る
- 装飾が主要操作の当たり判定を覆わない