mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update vibrant
This commit is contained in:
parent
621d660be1
commit
fcbb3ccc58
3 changed files with 784 additions and 747 deletions
|
@ -16,12 +16,12 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
"ignore": [],
|
"ignore": [],
|
||||||
"version": "1.1.91",
|
"version": "1.1.92",
|
||||||
"_release": "1.1.91",
|
"_release": "1.1.92",
|
||||||
"_resolution": {
|
"_resolution": {
|
||||||
"type": "version",
|
"type": "version",
|
||||||
"tag": "1.1.91",
|
"tag": "1.1.92",
|
||||||
"commit": "f94b80f14bce6922acf1dbd749a60ad54e4abfd8"
|
"commit": "0a48f9a0b64a422c4466938b24aa983041a89f52"
|
||||||
},
|
},
|
||||||
"_source": "https://github.com/MediaBrowser/Emby.ApiClient.Javascript.git",
|
"_source": "https://github.com/MediaBrowser/Emby.ApiClient.Javascript.git",
|
||||||
"_target": "^1.1.51",
|
"_target": "^1.1.51",
|
||||||
|
|
|
@ -216,7 +216,7 @@
|
||||||
return connectUser;
|
return connectUser;
|
||||||
};
|
};
|
||||||
|
|
||||||
var minServerVersion = '3.0.5994';
|
var minServerVersion = '3.0.6040';
|
||||||
self.minServerVersion = function (val) {
|
self.minServerVersion = function (val) {
|
||||||
|
|
||||||
if (val) {
|
if (val) {
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
define([], function () {
|
define([], function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* quantize.js Copyright 2008 Nick Rabinowitz
|
* quantize.js Copyright 2008 Nick Rabinowitz
|
||||||
* Ported to node.js by Olivier Lesnicki
|
* Ported to node.js by Olivier Lesnicki
|
||||||
|
@ -11,7 +13,6 @@ define([], function () {
|
||||||
* Copyright 2010 Stanford Visualization Group
|
* Copyright 2010 Stanford Visualization Group
|
||||||
* Licensed under the BSD License: http://www.opensource.org/licenses/bsd-license.php
|
* Licensed under the BSD License: http://www.opensource.org/licenses/bsd-license.php
|
||||||
*/
|
*/
|
||||||
if (!pv) {
|
|
||||||
var pv = {
|
var pv = {
|
||||||
map: function (array, f) {
|
map: function (array, f) {
|
||||||
var o = {};
|
var o = {};
|
||||||
|
@ -35,8 +36,7 @@ if (!pv) {
|
||||||
max: function (array, f) {
|
max: function (array, f) {
|
||||||
return Math.max.apply(null, f ? pv.map(array, f) : array);
|
return Math.max.apply(null, f ? pv.map(array, f) : array);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic Javascript port of the MMCQ (modified median cut quantization)
|
* Basic Javascript port of the MMCQ (modified median cut quantization)
|
||||||
|
@ -90,12 +90,18 @@ var MMCQ = (function() {
|
||||||
sorted = false;
|
sorted = false;
|
||||||
},
|
},
|
||||||
peek: function (index) {
|
peek: function (index) {
|
||||||
if (!sorted) sort();
|
if (!sorted) {
|
||||||
if (index === undefined) index = contents.length - 1;
|
sort();
|
||||||
|
}
|
||||||
|
if (index === undefined) {
|
||||||
|
index = contents.length - 1;
|
||||||
|
}
|
||||||
return contents[index];
|
return contents[index];
|
||||||
},
|
},
|
||||||
pop: function () {
|
pop: function () {
|
||||||
if (!sorted) sort();
|
if (!sorted) {
|
||||||
|
sort();
|
||||||
|
}
|
||||||
return contents.pop();
|
return contents.pop();
|
||||||
},
|
},
|
||||||
size: function () {
|
size: function () {
|
||||||
|
@ -105,7 +111,9 @@ var MMCQ = (function() {
|
||||||
return contents.map(f);
|
return contents.map(f);
|
||||||
},
|
},
|
||||||
debug: function () {
|
debug: function () {
|
||||||
if (!sorted) sort();
|
if (!sorted) {
|
||||||
|
sort();
|
||||||
|
}
|
||||||
return contents;
|
return contents;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -204,8 +212,8 @@ var MMCQ = (function() {
|
||||||
return pv.naturalOrder(
|
return pv.naturalOrder(
|
||||||
a.vbox.count() * a.vbox.volume(),
|
a.vbox.count() * a.vbox.volume(),
|
||||||
b.vbox.count() * b.vbox.volume()
|
b.vbox.count() * b.vbox.volume()
|
||||||
)
|
);
|
||||||
});;
|
});
|
||||||
}
|
}
|
||||||
CMap.prototype = {
|
CMap.prototype = {
|
||||||
push: function (vbox) {
|
push: function (vbox) {
|
||||||
|
@ -216,7 +224,7 @@ var MMCQ = (function() {
|
||||||
},
|
},
|
||||||
palette: function () {
|
palette: function () {
|
||||||
return this.vboxes.map(function (vb) {
|
return this.vboxes.map(function (vb) {
|
||||||
return vb.color
|
return vb.color;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
size: function () {
|
size: function () {
|
||||||
|
@ -251,20 +259,22 @@ var MMCQ = (function() {
|
||||||
// XXX: won't work yet
|
// XXX: won't work yet
|
||||||
var vboxes = this.vboxes;
|
var vboxes = this.vboxes;
|
||||||
vboxes.sort(function (a, b) {
|
vboxes.sort(function (a, b) {
|
||||||
return pv.naturalOrder(pv.sum(a.color), pv.sum(b.color))
|
return pv.naturalOrder(pv.sum(a.color), pv.sum(b.color));
|
||||||
});
|
});
|
||||||
|
|
||||||
// force darkest color to black if everything < 5
|
// force darkest color to black if everything < 5
|
||||||
var lowest = vboxes[0].color;
|
var lowest = vboxes[0].color;
|
||||||
if (lowest[0] < 5 && lowest[1] < 5 && lowest[2] < 5)
|
if (lowest[0] < 5 && lowest[1] < 5 && lowest[2] < 5) {
|
||||||
vboxes[0].color = [0, 0, 0];
|
vboxes[0].color = [0, 0, 0];
|
||||||
|
}
|
||||||
|
|
||||||
// force lightest color to white if everything > 251
|
// force lightest color to white if everything > 251
|
||||||
var idx = vboxes.length - 1,
|
var idx = vboxes.length - 1,
|
||||||
highest = vboxes[idx].color;
|
highest = vboxes[idx].color;
|
||||||
if (highest[0] > 251 && highest[1] > 251 && highest[2] > 251)
|
if (highest[0] > 251 && highest[1] > 251 && highest[2] > 251) {
|
||||||
vboxes[idx].color = [255, 255, 255];
|
vboxes[idx].color = [255, 255, 255];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// histo (1-d array, giving the number of pixels in
|
// histo (1-d array, giving the number of pixels in
|
||||||
|
@ -297,33 +307,50 @@ var MMCQ = (function() {
|
||||||
rval = pixel[0] >> rshift;
|
rval = pixel[0] >> rshift;
|
||||||
gval = pixel[1] >> rshift;
|
gval = pixel[1] >> rshift;
|
||||||
bval = pixel[2] >> rshift;
|
bval = pixel[2] >> rshift;
|
||||||
if (rval < rmin) rmin = rval;
|
if (rval < rmin) {
|
||||||
else if (rval > rmax) rmax = rval;
|
rmin = rval;
|
||||||
if (gval < gmin) gmin = gval;
|
}
|
||||||
else if (gval > gmax) gmax = gval;
|
else if (rval > rmax) {
|
||||||
if (bval < bmin) bmin = bval;
|
rmax = rval;
|
||||||
else if (bval > bmax) bmax = bval;
|
}
|
||||||
|
if (gval < gmin) {
|
||||||
|
gmin = gval;
|
||||||
|
}
|
||||||
|
else if (gval > gmax) {
|
||||||
|
gmax = gval;
|
||||||
|
}
|
||||||
|
if (bval < bmin) {
|
||||||
|
bmin = bval;
|
||||||
|
}
|
||||||
|
else if (bval > bmax) {
|
||||||
|
bmax = bval;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return new VBox(rmin, rmax, gmin, gmax, bmin, bmax, histo);
|
return new VBox(rmin, rmax, gmin, gmax, bmin, bmax, histo);
|
||||||
}
|
}
|
||||||
|
|
||||||
function medianCutApply(histo, vbox) {
|
function medianCutApply(histo, vbox) {
|
||||||
if (!vbox.count()) return;
|
|
||||||
|
var vBoxCount = vbox.count();
|
||||||
|
|
||||||
|
if (!vBoxCount) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var rw = vbox.r2 - vbox.r1 + 1,
|
var rw = vbox.r2 - vbox.r1 + 1,
|
||||||
gw = vbox.g2 - vbox.g1 + 1,
|
gw = vbox.g2 - vbox.g1 + 1,
|
||||||
bw = vbox.b2 - vbox.b1 + 1,
|
bw = vbox.b2 - vbox.b1 + 1,
|
||||||
maxw = pv.max([rw, gw, bw]);
|
maxw = pv.max([rw, gw, bw]);
|
||||||
// only one pixel, no split
|
// only one pixel, no split
|
||||||
if (vbox.count() == 1) {
|
if (vBoxCount === 1) {
|
||||||
return [vbox.copy()]
|
return [vbox.copy()];
|
||||||
}
|
}
|
||||||
/* Find the partial sum arrays along the selected axis. */
|
/* Find the partial sum arrays along the selected axis. */
|
||||||
var total = 0,
|
var total = 0,
|
||||||
partialsum = [],
|
partialsum = [],
|
||||||
lookaheadsum = [],
|
lookaheadsum = [],
|
||||||
i, j, k, sum, index;
|
i, j, k, sum, index;
|
||||||
if (maxw == rw) {
|
if (maxw === rw) {
|
||||||
for (i = vbox.r1; i <= vbox.r2; i++) {
|
for (i = vbox.r1; i <= vbox.r2; i++) {
|
||||||
sum = 0;
|
sum = 0;
|
||||||
for (j = vbox.g1; j <= vbox.g2; j++) {
|
for (j = vbox.g1; j <= vbox.g2; j++) {
|
||||||
|
@ -335,7 +362,7 @@ var MMCQ = (function() {
|
||||||
total += sum;
|
total += sum;
|
||||||
partialsum[i] = total;
|
partialsum[i] = total;
|
||||||
}
|
}
|
||||||
} else if (maxw == gw) {
|
} else if (maxw === gw) {
|
||||||
for (i = vbox.g1; i <= vbox.g2; i++) {
|
for (i = vbox.g1; i <= vbox.g2; i++) {
|
||||||
sum = 0;
|
sum = 0;
|
||||||
for (j = vbox.r1; j <= vbox.r2; j++) {
|
for (j = vbox.r1; j <= vbox.r2; j++) {
|
||||||
|
@ -361,7 +388,7 @@ var MMCQ = (function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
partialsum.forEach(function (d, i) {
|
partialsum.forEach(function (d, i) {
|
||||||
lookaheadsum[i] = total - d
|
lookaheadsum[i] = total - d;
|
||||||
});
|
});
|
||||||
|
|
||||||
function doCut(color) {
|
function doCut(color) {
|
||||||
|
@ -374,25 +401,31 @@ var MMCQ = (function() {
|
||||||
vbox2 = vbox.copy();
|
vbox2 = vbox.copy();
|
||||||
left = i - vbox[dim1];
|
left = i - vbox[dim1];
|
||||||
right = vbox[dim2] - i;
|
right = vbox[dim2] - i;
|
||||||
if (left <= right)
|
if (left <= right) {
|
||||||
d2 = Math.min(vbox[dim2] - 1, ~~(i + right / 2));
|
d2 = Math.min(vbox[dim2] - 1, ~~(i + right / 2));
|
||||||
else d2 = Math.max(vbox[dim1], ~~ (i - 1 - left / 2));
|
}
|
||||||
|
else {
|
||||||
|
d2 = Math.max(vbox[dim1], ~~(i - 1 - left / 2));
|
||||||
|
}
|
||||||
// avoid 0-count boxes
|
// avoid 0-count boxes
|
||||||
while (!partialsum[d2]) d2++;
|
while (!partialsum[d2]) {
|
||||||
|
d2++;
|
||||||
|
}
|
||||||
count2 = lookaheadsum[d2];
|
count2 = lookaheadsum[d2];
|
||||||
while (!count2 && partialsum[d2 - 1]) count2 = lookaheadsum[--d2];
|
while (!count2 && partialsum[d2 - 1]) {
|
||||||
|
count2 = lookaheadsum[--d2];
|
||||||
|
}
|
||||||
// set dimensions
|
// set dimensions
|
||||||
vbox1[dim2] = d2;
|
vbox1[dim2] = d2;
|
||||||
vbox2[dim1] = vbox1[dim2] + 1;
|
vbox2[dim1] = vbox1[dim2] + 1;
|
||||||
// console.log('vbox counts:', vbox.count(), vbox1.count(), vbox2.count());
|
|
||||||
return [vbox1, vbox2];
|
return [vbox1, vbox2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// determine the cut planes
|
// determine the cut planes
|
||||||
return maxw == rw ? doCut('r') :
|
return maxw === rw ? doCut('r') :
|
||||||
maxw == gw ? doCut('g') :
|
maxw === gw ? doCut('g') :
|
||||||
doCut('b');
|
doCut('b');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,7 +444,7 @@ var MMCQ = (function() {
|
||||||
// check that we aren't below maxcolors already
|
// check that we aren't below maxcolors already
|
||||||
var nColors = 0;
|
var nColors = 0;
|
||||||
histo.forEach(function () {
|
histo.forEach(function () {
|
||||||
nColors++
|
nColors++;
|
||||||
});
|
});
|
||||||
if (nColors <= maxcolors) {
|
if (nColors <= maxcolors) {
|
||||||
// XXX: generate the new colors from the histo and return
|
// XXX: generate the new colors from the histo and return
|
||||||
|
@ -420,7 +453,7 @@ var MMCQ = (function() {
|
||||||
// get the beginning vbox from the colors
|
// get the beginning vbox from the colors
|
||||||
var vbox = vboxFromPixels(pixels, histo),
|
var vbox = vboxFromPixels(pixels, histo),
|
||||||
pq = new PQueue(function (a, b) {
|
pq = new PQueue(function (a, b) {
|
||||||
return pv.naturalOrder(a.count(), b.count())
|
return pv.naturalOrder(a.count(), b.count());
|
||||||
});
|
});
|
||||||
pq.push(vbox);
|
pq.push(vbox);
|
||||||
|
|
||||||
|
@ -451,7 +484,9 @@ var MMCQ = (function() {
|
||||||
lh.push(vbox2);
|
lh.push(vbox2);
|
||||||
ncolors++;
|
ncolors++;
|
||||||
}
|
}
|
||||||
if (ncolors >= target) return;
|
if (ncolors >= target) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (niters++ > maxIterations) {
|
if (niters++ > maxIterations) {
|
||||||
// console.log("infinite loop; perhaps too few pixels!");
|
// console.log("infinite loop; perhaps too few pixels!");
|
||||||
return;
|
return;
|
||||||
|
@ -465,7 +500,7 @@ var MMCQ = (function() {
|
||||||
|
|
||||||
// Re-sort by the product of pixel occupancy times the size in color space.
|
// Re-sort by the product of pixel occupancy times the size in color space.
|
||||||
var pq2 = new PQueue(function (a, b) {
|
var pq2 = new PQueue(function (a, b) {
|
||||||
return pv.naturalOrder(a.count() * a.volume(), b.count() * b.volume())
|
return pv.naturalOrder(a.count() * a.volume(), b.count() * b.volume());
|
||||||
});
|
});
|
||||||
while (pq.size()) {
|
while (pq.size()) {
|
||||||
pq2.push(pq.pop());
|
pq2.push(pq.pop());
|
||||||
|
@ -485,7 +520,7 @@ var MMCQ = (function() {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
quantize: quantize
|
quantize: quantize
|
||||||
}
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -520,10 +555,9 @@ window.Swatch = Swatch = (function () {
|
||||||
|
|
||||||
Swatch.prototype.getHsl = function () {
|
Swatch.prototype.getHsl = function () {
|
||||||
if (!this.hsl) {
|
if (!this.hsl) {
|
||||||
return this.hsl = Vibrant.rgbToHsl(this.rgb[0], this.rgb[1], this.rgb[2]);
|
this.hsl = Vibrant.rgbToHsl(this.rgb[0], this.rgb[1], this.rgb[2]);
|
||||||
} else {
|
|
||||||
return this.hsl;
|
|
||||||
}
|
}
|
||||||
|
return this.hsl;
|
||||||
};
|
};
|
||||||
|
|
||||||
Swatch.prototype.getPopulation = function () {
|
Swatch.prototype.getPopulation = function () {
|
||||||
|
@ -558,7 +592,8 @@ window.Swatch = Swatch = (function () {
|
||||||
|
|
||||||
Swatch.prototype._ensureTextColors = function () {
|
Swatch.prototype._ensureTextColors = function () {
|
||||||
if (!this.yiq) {
|
if (!this.yiq) {
|
||||||
return this.yiq = (this.rgb[0] * 299 + this.rgb[1] * 587 + this.rgb[2] * 114) / 1000;
|
this.yiq = (this.rgb[0] * 299 + this.rgb[1] * 587 + this.rgb[2] * 114) / 1000;
|
||||||
|
return this.yiq;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -661,7 +696,8 @@ window.Vibrant = Vibrant = (function () {
|
||||||
this.DarkVibrantSwatch = this.findColorVariation(this.TARGET_DARK_LUMA, 0, this.MAX_DARK_LUMA, this.TARGET_VIBRANT_SATURATION, this.MIN_VIBRANT_SATURATION, 1);
|
this.DarkVibrantSwatch = this.findColorVariation(this.TARGET_DARK_LUMA, 0, this.MAX_DARK_LUMA, this.TARGET_VIBRANT_SATURATION, this.MIN_VIBRANT_SATURATION, 1);
|
||||||
this.MutedSwatch = this.findColorVariation(this.TARGET_NORMAL_LUMA, this.MIN_NORMAL_LUMA, this.MAX_NORMAL_LUMA, this.TARGET_MUTED_SATURATION, 0, this.MAX_MUTED_SATURATION);
|
this.MutedSwatch = this.findColorVariation(this.TARGET_NORMAL_LUMA, this.MIN_NORMAL_LUMA, this.MAX_NORMAL_LUMA, this.TARGET_MUTED_SATURATION, 0, this.MAX_MUTED_SATURATION);
|
||||||
this.LightMutedSwatch = this.findColorVariation(this.TARGET_LIGHT_LUMA, this.MIN_LIGHT_LUMA, 1, this.TARGET_MUTED_SATURATION, 0, this.MAX_MUTED_SATURATION);
|
this.LightMutedSwatch = this.findColorVariation(this.TARGET_LIGHT_LUMA, this.MIN_LIGHT_LUMA, 1, this.TARGET_MUTED_SATURATION, 0, this.MAX_MUTED_SATURATION);
|
||||||
return this.DarkMutedSwatch = this.findColorVariation(this.TARGET_DARK_LUMA, 0, this.MAX_DARK_LUMA, this.TARGET_MUTED_SATURATION, 0, this.MAX_MUTED_SATURATION);
|
this.DarkMutedSwatch = this.findColorVariation(this.TARGET_DARK_LUMA, 0, this.MAX_DARK_LUMA, this.TARGET_MUTED_SATURATION, 0, this.MAX_MUTED_SATURATION);
|
||||||
|
return this.DarkMutedSwatch;
|
||||||
};
|
};
|
||||||
|
|
||||||
Vibrant.prototype.generateEmptySwatches = function () {
|
Vibrant.prototype.generateEmptySwatches = function () {
|
||||||
|
@ -677,7 +713,8 @@ window.Vibrant = Vibrant = (function () {
|
||||||
if (this.VibrantSwatch !== void 0) {
|
if (this.VibrantSwatch !== void 0) {
|
||||||
hsl = this.VibrantSwatch.getHsl();
|
hsl = this.VibrantSwatch.getHsl();
|
||||||
hsl[2] = this.TARGET_DARK_LUMA;
|
hsl[2] = this.TARGET_DARK_LUMA;
|
||||||
return this.DarkVibrantSwatch = new Swatch(Vibrant.hslToRgb(hsl[0], hsl[1], hsl[2]), 0);
|
this.DarkVibrantSwatch = new Swatch(Vibrant.hslToRgb(hsl[0], hsl[1], hsl[2]), 0);
|
||||||
|
return this.DarkVibrantSwatch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue