Files
LonaRPG-Online-Games/ModScripts/_Mods/NoerHome/Scripts/NoerHomeCatEffect.js
T
2026-10-29 21:59:06 +04:00

71 lines
1.9 KiB
JavaScript

(function (global) {
var COLORS = [
[255, 0, 0],
[255, 136, 0],
[255, 240, 0],
[48, 224, 48],
[48, 160, 255],
[96, 80, 255]
];
function clampInt(v, min, max) {
v = v | 0;
if (v < min) return min;
if (v > max) return max;
return v;
}
function exportNyanTrail(width, height, phase, vertical) {
width = clampInt(width, 1, 512);
height = clampInt(height, 1, 128);
phase = clampInt(phase, 0, 9999);
vertical = !!vertical;
var shift = phase * 2;
var out = [];
if (vertical) {
var stripeW = Math.max(1, Math.floor(width / COLORS.length));
for (var y = 0; y < height; y++) {
for (var x = 0; x < width; x++) {
var stripe = Math.floor(x / stripeW);
if (stripe >= COLORS.length) stripe = COLORS.length - 1;
var rgb = COLORS[stripe];
var notchLeft = ((((y + shift) / 4) | 0) % 3 === 1) && x === 0;
var notchRight = ((((y + shift) / 6) | 0) % 4 === 0) && x === width - 1;
if (notchLeft || notchRight) {
out.push(0, 0, 0, 0);
} else {
out.push(rgb[2], rgb[1], rgb[0], 255);
}
}
}
} else {
var stripeH = Math.max(1, Math.floor(height / COLORS.length));
for (var y = 0; y < height; y++) {
var stripe = Math.floor(y / stripeH);
if (stripe >= COLORS.length) stripe = COLORS.length - 1;
var rgb = COLORS[stripe];
for (var x = 0; x < width; x++) {
var notchBottom = ((((x + shift) / 4) | 0) % 3 === 1) && y === height - 1;
var notchTop = ((((x + shift) / 6) | 0) % 4 === 0) && y === 0;
if (notchBottom || notchTop) {
out.push(0, 0, 0, 0);
} else {
out.push(rgb[2], rgb[1], rgb[0], 255);
}
}
}
}
return out.join(",");
}
global.NoerHomeCatFX = {
exportNyanTrail: exportNyanTrail
};
})(this);