Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
throw `Length of replacements (${colorCount}) exceeds the maximum colors length (${this._maxColors})`;
}
// Fill with negative values
originals[colorCount * 3] = -1;
for (let i = 0; i < colorCount; i++) {
const pair = replacements[i];
// for original colors
let color = pair[0];
if (typeof color === 'number') {
color = hex2rgb(color);
}
else {
pair[0] = rgb2hex(color);
}
originals[i * 3] = color[0];
originals[(i * 3) + 1] = color[1];
originals[(i * 3) + 2] = color[2];
// for target colors
let targetColor = pair[1];
if (typeof targetColor === 'number') {
targetColor = hex2rgb(targetColor);
}
else {
pair[1] = rgb2hex(targetColor);
}
targets[i * 3] = targetColor[0];
roundColor: (color) =>
{
const step = CanvasTinter.cacheStepsPerColorChannel;
const rgbValues = hex2rgb(color);
rgbValues[0] = Math.min(255, (rgbValues[0] / step) * step);
rgbValues[1] = Math.min(255, (rgbValues[1] / step) * step);
rgbValues[2] = Math.min(255, (rgbValues[2] / step) * step);
return rgb2hex(rgbValues);
},
{
sprite.tint = fillColor;
}
else if (this.tint !== this._prevRectTint || fillColor !== this._prevRectFillColor)
{
const t1 = tempColor1;
const t2 = tempColor2;
hex2rgb(fillColor, t1);
hex2rgb(this.tint, t2);
t1[0] *= t2[0];
t1[1] *= t2[1];
t1[2] *= t2[2];
sprite.tint = rgb2hex(t1);
this._prevRectTint = this.tint;
this._prevRectFillColor = fillColor;
}
sprite.alpha = this.graphicsData[0].fillAlpha;
sprite.worldAlpha = this.worldAlpha * sprite.alpha;
sprite.blendMode = this.blendMode;
sprite._texture._frame.width = rect.width;
sprite._texture._frame.height = rect.height;
sprite.transform.worldTransform = this.transform.worldTransform;
sprite.anchor.set(-rect.x / rect.width, -rect.y / rect.height);
sprite._onAnchorUpdate();
set color(value) {
const arr = this.uniforms.ambientColor;
if (typeof value === 'number') {
hex2rgb(value, arr);
this._color = value;
}
else {
arr[0] = value[0];
arr[1] = value[1];
arr[2] = value[2];
arr[3] = value[3];
this._color = rgb2hex(arr);
}
}
get color() {
set newColor(value) {
let arr = this.uniforms.newColor;
if (typeof value === 'number') {
hex2rgb(value, arr);
this._newColor = value;
}
else {
arr[0] = value[0];
arr[1] = value[1];
arr[2] = value[2];
this._newColor = rgb2hex(arr);
}
}
get newColor() {
get color() {
return rgb2hex(this._tintFilter.uniforms.color);
}
set color(value) {
get lightColor() {
return rgb2hex(this.uniforms.lightColor);
}
set lightColor(value) {
get color() {
return rgb2hex(this.uniforms.outlineColor);
}
set color(value) {
set originalColor(value) {
let arr = this.uniforms.originalColor;
if (typeof value === 'number') {
hex2rgb(value, arr);
this._originalColor = value;
}
else {
arr[0] = value[0];
arr[1] = value[1];
arr[2] = value[2];
this._originalColor = rgb2hex(arr);
}
}
get originalColor() {