mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
improved color key generation algorithm
This commit is contained in:
@@ -283,20 +283,12 @@
|
|||||||
_rgbToHex: function(r, g, b) {
|
_rgbToHex: function(r, g, b) {
|
||||||
return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
||||||
},
|
},
|
||||||
_hexToRgb: function(hex) {
|
|
||||||
var bigint = parseInt(hex, 16);
|
|
||||||
return {
|
|
||||||
r: (bigint >> 16) & 255,
|
|
||||||
g: (bigint >> 8) & 255,
|
|
||||||
b: bigint & 255
|
|
||||||
};
|
|
||||||
},
|
|
||||||
_getRandomColorKey: function() {
|
_getRandomColorKey: function() {
|
||||||
var r = (Math.random() * 255) | 0,
|
var randColor = (Math.random() * 0xFFFFFF << 0).toString(16);
|
||||||
g = (Math.random() * 255) | 0,
|
while (randColor.length < 6) {
|
||||||
b = (Math.random() * 255) | 0;
|
randColor = '0' + randColor;
|
||||||
|
}
|
||||||
return this._rgbToHex(r, g, b);
|
return randColor;
|
||||||
},
|
},
|
||||||
// o1 takes precedence over o2
|
// o1 takes precedence over o2
|
||||||
_merge: function(o1, o2) {
|
_merge: function(o1, o2) {
|
||||||
|
Reference in New Issue
Block a user