Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xProcess: function (val) {
- if (val === 0) return;
- const Aya = 0 <= val ? {
- r: [{ x: 0, y: 0 }, { x: 77, y: 26 }, { x: 179, y: 204 }, { x: 255, y: 255 }],
- g: [{ x: 0, y: 0 }, { x: 64, y: 38 }, { x: 191, y: 217 }, { x: 255, y: 255 }],
- b: [{ x: 0, y: 0 }, { x: 85, y: 102 }, { x: 170, y: 153 }, { x: 255, y: 204 }]
- } : {
- r: [{ x: 0, y: 0 }, { x: 77, y: 26 }, { x: 179, y: 51 }, { x: 242, y: 255 }],
- g: [{ x: 0, y: 0 }, { x: 64, y: 102 }, { x: 153, y: 153 }, { x: 255, y: 255 }],
- b: [{ x: 0, y: 0 }, { x: 77, y: 79 }, { x: 153, y: 153 }, { x: 255, y: 255 }]
- };
- val = Math.abs(val);
- var a;
- var b = {
- mh: 70,
- Aya
- };
- const c = val / 100;
- var d = h => {
- let l = h.x;
- return { x: l, y: (1 - c) * l + h.y * c };
- };
- class nza {
- constructor(a, b) {
- this.J3b = a;
- this.xs = b
- }
- interpolate(a) {
- var b = this.J3b;
- const c = this.xs;
- let d = 0,
- e = this.J3b.length - 1;
- for (; 1 < e - d;) {
- var f = e + d >> 1;
- b[f].x > a ? e = f : d = f
- }
- f = b[e];
- b = b[d];
- const g = f.x - b.x,
- h = (f.x - a) / g;
- a = (a - b.x) / g;
- return h * b.y + a * f.y + (c[d] * (h ** 3 - h) + c[e] * (a ** 3 - a)) * g ** 2 / 6;
- }
- }
- function Xr(a) {
- var b = a.length;
- const c = new Float64Array(b),
- d = new Float64Array(b);
- for (let e = 1; e < b - 1; e++) {
- const f = a[e - 1],
- g = a[e],
- h = a[e + 1],
- l = h.x - f.x,
- p = (g.x - f.x) / l,
- q = p * d[e - 1] + 2;
- c[e] = (6 * ((h.y - g.y) / (h.x - g.x) - (g.y - f.y) / (g.x - f.x)) / l - p * c[e - 1]) / q;
- d[e] = (p - 1) / q
- }
- for (b -= 2; 0 <= b; --b) d[b] = d[b] * d[b + 1] + c[b];
- return new nza(a, d);
- };
- a = Xr(Aya.r.map(d));
- const e = Xr(Aya.g.map(d));
- b = Xr(Aya.b.map(d));
- d = Array(32);
- const f = Array(32),
- g = Array(32);
- for (let h = 0; 32 > h; h++) {
- const l = 255 * h / 31;
- d[h] = Math.max(0, Math.min(255, a.interpolate(l))) / 255;
- f[h] = Math.max(0, Math.min(255, e.interpolate(l))) / 255;
- g[h] = Math.max(0, Math.min(255, b.interpolate(l))) / 255;
- }
- return { r: d, g: f, b: g };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement