mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
fixed color sorting for desaturated colors
This commit is contained in:
parent
ac08775406
commit
a7ef57b6ee
@ -15,6 +15,8 @@
|
|||||||
ns.CurrentColorsService.prototype.init = function () {
|
ns.CurrentColorsService.prototype.init = function () {
|
||||||
$.subscribe(Events.PISKEL_RESET, this.onPiskelUpdated_.bind(this));
|
$.subscribe(Events.PISKEL_RESET, this.onPiskelUpdated_.bind(this));
|
||||||
$.subscribe(Events.TOOL_RELEASED, this.onPiskelUpdated_.bind(this));
|
$.subscribe(Events.TOOL_RELEASED, this.onPiskelUpdated_.bind(this));
|
||||||
|
|
||||||
|
// this.updateTimer = window.setInterval(this.updateCurrentColors_.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.CurrentColorsService.prototype.getCurrentColors = function () {
|
ns.CurrentColorsService.prototype.getCurrentColors = function () {
|
||||||
@ -34,7 +36,7 @@
|
|||||||
var layers = this.piskelController.getLayers();
|
var layers = this.piskelController.getLayers();
|
||||||
var frames = layers.map(function (l) {return l.getFrames();}).reduce(function (p, n) {return p.concat(n);});
|
var frames = layers.map(function (l) {return l.getFrames();}).reduce(function (p, n) {return p.concat(n);});
|
||||||
var colors = {};
|
var colors = {};
|
||||||
|
|
||||||
frames.forEach(function (f) {
|
frames.forEach(function (f) {
|
||||||
var frameColors = this.cachedFrameProcessor.get(f);
|
var frameColors = this.cachedFrameProcessor.get(f);
|
||||||
Object.keys(frameColors).slice(0, Constants.MAX_CURRENT_COLORS_DISPLAYED).forEach(function (color) {
|
Object.keys(frameColors).slice(0, Constants.MAX_CURRENT_COLORS_DISPLAYED).forEach(function (color) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var ns = $.namespace('pskl.service.color');
|
var ns = $.namespace('pskl.service.color');
|
||||||
|
|
||||||
var LOW_SAT = 0.3;
|
var LOW_SAT = 0.1;
|
||||||
var LOW_LUM = 0.1;
|
var LOW_LUM = 0.1;
|
||||||
var HI_LUM = 0.9;
|
var HI_LUM = 0.9;
|
||||||
|
|
||||||
@ -36,6 +36,8 @@
|
|||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
var desaturatedColors = colors.filter(function (c) {
|
var desaturatedColors = colors.filter(function (c) {
|
||||||
|
return brightColors.indexOf(c) === -1 && darkColors.indexOf(c) === -1;
|
||||||
|
}).filter(function (c) {
|
||||||
var hsl = this.colorsHslMap_[c];
|
var hsl = this.colorsHslMap_[c];
|
||||||
return hsl.s <= LOW_SAT;
|
return hsl.s <= LOW_SAT;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
@ -44,22 +46,20 @@
|
|||||||
brightColors = this.sortOnHslProperty_(brightColors, 'l');
|
brightColors = this.sortOnHslProperty_(brightColors, 'l');
|
||||||
desaturatedColors = this.sortOnHslProperty_(desaturatedColors, 'h');
|
desaturatedColors = this.sortOnHslProperty_(desaturatedColors, 'h');
|
||||||
|
|
||||||
var sortedColors = darkColors.concat(brightColors).concat(desaturatedColors);
|
var sortedColors = darkColors.concat(brightColors, desaturatedColors);
|
||||||
|
|
||||||
var regularColors = colors.filter(function (c) {
|
var regularColors = colors.filter(function (c) {
|
||||||
return sortedColors.indexOf(c) === -1;
|
return sortedColors.indexOf(c) === -1;
|
||||||
});
|
});
|
||||||
|
|
||||||
var regularColorsBags = [];
|
var regularColorsBags = HUE_BOUNDS.map(function (hue) {
|
||||||
for (var i = 0 ; i < HUE_BOUNDS.length ; i++) {
|
|
||||||
var hue = HUE_BOUNDS[i];
|
|
||||||
var bagColors = regularColors.filter(function (color) {
|
var bagColors = regularColors.filter(function (color) {
|
||||||
var hsl = this.colorsHslMap_[color];
|
var hsl = this.colorsHslMap_[color];
|
||||||
return (hsl.h >= hue && hsl.h < hue + HUE_STEP);
|
return (hsl.h >= hue && hsl.h < hue + HUE_STEP);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
regularColorsBags[i] = this.sortRegularColors_(bagColors);
|
return this.sortRegularColors_(bagColors);
|
||||||
}
|
}.bind(this));
|
||||||
|
|
||||||
return Array.prototype.concat.apply(sortedColors, regularColorsBags);
|
return Array.prototype.concat.apply(sortedColors, regularColorsBags);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user