q3226257 发表于 2021-6-8 09:48
复制mv的到mz就好了~~~~~~~
Capture.PNG (517.18 KB, 下载次数: 47)
动态图片
Capture2.PNG (944.67 KB, 下载次数: 36)
静态图片
Capture3.PNG (679.62 KB, 下载次数: 55)
战斗
q3226257 发表于 2021-6-9 10:18
很明显,mv的实现是更改了图像的数据来实现hue的,
但是mz是通过滤镜实现的,所以你要改成mv那样,需要 ...
Bitmap.prototype.rotateHue = function(offset,bitmap) {
function rgbToHsl(r, g, b) {
var cmin = Math.min(r, g, b);
var cmax = Math.max(r, g, b);
var h = 0;
var s = 0;
var l = (cmin + cmax) / 2;
var delta = cmax - cmin;
if (delta > 0) {
if (r === cmax) {
h = 60 * (((g - b) / delta + 6) % 6);
} else if (g === cmax) {
h = 60 * ((b - r) / delta + 2);
} else {
h = 60 * ((r - g) / delta + 4);
}
s = delta / (255 - Math.abs(2 * l - 255));
}
return [h, s, l];
}
function hslToRgb(h, s, l) {
var c = (255 - Math.abs(2 * l - 255)) * s;
var x = c * (1 - Math.abs((h / 60) % 2 - 1));
var m = l - c / 2;
var cm = c + m;
var xm = x + m;
if (h < 60) {
return [cm, xm, m];
} else if (h < 120) {
return [xm, cm, m];
} else if (h < 180) {
return [m, cm, xm];
} else if (h < 240) {
return [m, xm, cm];
} else if (h < 300) {
return [xm, m, cm];
} else {
return [cm, m, xm];
}
}
if (offset && this.width > 0 && this.height > 0) {
offset = ((offset % 360) + 360) % 360;
console.log(offset);
var context = bitmap.context;
var imageData = context.getImageData(0, 0, this.width, this.height);
var pixels = imageData.data;
console.log(imageData)
for (var i = 0; i < pixels.length; i += 4) {
var hsl = rgbToHsl(pixels[i + 0], pixels[i + 1], pixels[i + 2]);
var h = hsl[0] + (hsl[0] + offset) % 360;
var s = hsl[1];
var l = hsl[2];
var rgb = hslToRgb(h, s, l);
pixels[i + 0] = rgb[0];
pixels[i + 1] = rgb[1];
pixels[i + 2] = rgb[2];
}
context.putImageData(imageData, 0, 0);
//this._setDirty();
}
};
var bitmap=ImageManager.loadSvActor("actor");
bitmap.rotateHue(by,bitmap);
Capturex.PNG (36.92 KB, 下载次数: 45)
MH-Pride 发表于 2021-6-11 00:44
Bitmap.prototype.rotateHue = function(offset,bitmap) {
function rgbToHsl(r, g, b) {
va ...
lisliz 发表于 2021-6-11 09:23
mz的核心脚本里有个ColorFilter,用来实现hue的,这东西比mv的要高效许多,不建议降级把mv的搬过来。不过我 ...
q3226257 发表于 2021-6-11 10:05
你抄代码要抄完啊,不知道就点进去看一下呗。。。
参数bitmap其实也没必要,你本来就是用bitmap.rotateHu ...
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |