#139 - fixed colorpicker

This commit is contained in:
Vilius 2019-04-22 22:36:18 +03:00
parent b23601527d
commit d86f2a5502
4 changed files with 26 additions and 10 deletions

6
dist/bundle.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "miniPaint",
"version": "4.2.0",
"version": "4.2.1",
"author": "Vilius L.",
"description": "Online graphics editing tool lets create, edit images using HTML5 technologies.",
"keywords": [

View File

@ -72,15 +72,30 @@ class GUI_colors_class {
}, false);
}
var changed = false;
var last_color = config.COLOR;
$("#main_color").spectrum({
showAlpha: true,
move: function(color) {
var rgba = color.toRgb();
move: function(color) {
_this.change_color(color.toHexString());
_this.change_alpha(rgba.a * 255);
_this.render_colors();
},
show: function() {
changed = false;
},
change: function(color) {
changed = true;
},
hide: function(color) {
if(changed == false) {
// revert
_this.change_color(last_color);
_this.render_colors();
}
else{
//changed
last_color = config.COLOR;
}
}
});
//colors

View File

@ -86,7 +86,8 @@ class Pick_color_class extends Base_tools_class {
}
//find color
var c = ctx.getImageData(mouse.x, mouse.y, 1, 1).data;
config.COLOR = this.Helper.rgbToHex(c[0], c[1], c[2]);
var hex = this.Helper.rgbToHex(c[0], c[1], c[2]);
this.Base_gui.GUI_colors.change_color(hex);
if (c[3] > 0) {
//set alpha