自陣色強調
by
cutfloss
7 hours ago [2026/05/07 18:24:18]
自陣の色が強調されて見えやすくなるぞ
@@ -8,46 +8,36 @@
if(!cvs) return;
const ctx = cvs.getContext('2d');
- /* 1. 自分の色と味方の色を特定する */
- /* myId や players は client-game.js のグローバル変数を使用 */
- const getMyTeamColors = () => {
+ /* 1. 自分とチームメイトの色をキャッシュ(負荷軽減のため) */
+ const getTeamColors = () => {
if(typeof players === 'undefined' || typeof myId === 'undefined') return [];
const me = players.find(p => p.id === myId);
if(!me) return [];
- /* 自分と同じチームのプレイヤーの色をリスト化 */
- return players.filter(p => p.team === me.team).map(p => p.color);
+ const team = me.team;
+ /* 同じチームのプレイヤーが使っている色を配列で返す */
+ return players.filter(p => p.team === team).map(p => p.color.toLowerCase());
};
- /* 2. 色を「パキッ」とさせる変換関数 */
- /* 明度を上げ、彩度を最大にする。敵との「差」を出すのが目的 */
- const boostColor = (hex) => {
- /* シンプルに白を混ぜるか、輝度を上げる処理 */
- return hex; // ここでは特定の色を「光らせる」処理に変える
- };
-
- /* 3. Canvasの塗りつぶし命令をハック(超軽量) */
+ /* 2. 描画命令の最小フック */
const originalFill = ctx.fill;
ctx.fill = function() {
- const teamColors = getMyTeamColors();
- const currentColor = this.fillStyle.toString().toLowerCase();
+ const teamColors = getTeamColors();
+ /* 現在設定されている色(fillStyle)を取得 */
+ const currentStyle = this.fillStyle.toString().toLowerCase();
- /* 現在塗ろうとしている色が「自分か味方の色」だったら、
- 透明度を上げて(0.3→0.6)見やすくし、影(Shadow)を強制追加する */
- const isAlly = teamColors.some(c => currentColor.includes(c.toLowerCase()));
+ /* 味方の色が含まれているか判定 */
+ const isAlly = teamColors.some(c => currentStyle.includes(c));
if (isAlly) {
this.save();
- this.globalAlpha = 0.6; // 味方の領地を濃くする
- if (typeof isLowPerformance !== 'undefined') {
- this.shadowColor = currentColor;
- this.shadowBlur = 15; // 味方の領地だけ発光させる
- }
+ this.globalAlpha = 0.8; /* 味方の陣地を濃く(通常0.3→0.8)して見えやすくする */
originalFill.apply(this, arguments);
this.restore();
} else {
+ /* 敵や背景はそのまま(globalAlphaはゲーム本体の設定に従う) */
originalFill.apply(this, arguments);
}
};
- alert('【色覚補正】自分と味方の領地を強調しました!\n(自分たちは濃く・発光、敵はそのまま)');
+ console.log('Ally Color Boost: Active (Minimal impact mode)');
})();
/*
* @title 自陣色強調
* @description 自陣の色が強調されて見えやすくなるぞ
* @private
*/
javascript:(function(){
const cvs = document.querySelector('canvas');
if(!cvs) return;
const ctx = cvs.getContext('2d');
/* 1. 自分とチームメイトの色をキャッシュ(負荷軽減のため) */
const getTeamColors = () => {
if(typeof players === 'undefined' || typeof myId === 'undefined') return [];
const me = players.find(p => p.id === myId);
if(!me) return [];
const team = me.team;
/* 同じチームのプレイヤーが使っている色を配列で返す */
return players.filter(p => p.team === team).map(p => p.color.toLowerCase());
};
/* 2. 描画命令の最小フック */
const originalFill = ctx.fill;
ctx.fill = function() {
const teamColors = getTeamColors();
/* 現在設定されている色(fillStyle)を取得 */
const currentStyle = this.fillStyle.toString().toLowerCase();
/* 味方の色が含まれているか判定 */
const isAlly = teamColors.some(c => currentStyle.includes(c));
if (isAlly) {
this.save();
this.globalAlpha = 0.8; /* 味方の陣地を濃く(通常0.3→0.8)して見えやすくする */
originalFill.apply(this, arguments);
this.restore();
} else {
/* 敵や背景はそのまま(globalAlphaはゲーム本体の設定に従う) */
originalFill.apply(this, arguments);
}
};
console.log('Ally Color Boost: Active (Minimal impact mode)');
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。