new option forceAlpha

pull/53/head
peterd 8 years ago
parent bd230e47ff
commit bf9cf4bfb1

@ -55,7 +55,8 @@ $('.color').colorPicker({
scrollResize: true // toggle for reposition colorPicker on window.resize/scroll
gap: 4 // gap to right and bottom edge of view port if repositioned to fit
preventFocus: false // prevents default on focus of input fields (e.g. no keyboard on mobile)
body: document.body // the element where the events are attached to (touchstart, mousedown, pointerdown, focus, click, change)
body: document.body // the element where the events are attached to (touchstart, mousedown, pointerdown, focus, click, change),
forceAlpha: force printing alpha channel (undefined = auto; false = never print alpha)
});
```
####Some tips

@ -87,7 +87,7 @@
};
Colors.prototype.toString = function(colorMode, forceAlpha) {
return ColorConverter.color2text(colorMode || 'rgba', this.colors, forceAlpha);
return ColorConverter.color2text(colorMode.toLowerCase() || 'rgb', this.colors, forceAlpha);
};
// ------------------------------------------------------ //
@ -259,17 +259,15 @@
forceAlpha !== false && (forceAlpha || alpha !== 1),
RGB = colors.RND.rgb,
HSL = colors.RND.hsl,
mode = colorMode.toLowerCase().substr(0, 3),
shouldBeHex = mode === 'hex' && hasAlpha,
isHex = mode === 'hex' && !shouldBeHex,
isRgb = mode === 'rgb' || shouldBeHex,
shouldBeHex = colorMode === 'hex' && hasAlpha,
isHex = colorMode === 'hex' && !shouldBeHex,
isRgb = colorMode === 'rgb' || shouldBeHex,
innerText = isRgb ? RGB.r + ', ' + RGB.g + ', ' + RGB.b :
HSL.h + ', ' + HSL.s + '%, ' + HSL.l + '%',
text = isHex ? '#' + colors.HEX : (shouldBeHex ? 'rgb' : mode) +
(hasAlpha ? 'a' : '') + '(' + innerText +
(hasAlpha ? ', ' + alpha : '') + ')';
!isHex ? HSL.h + ', ' + HSL.s + '%, ' + HSL.l + '%' :
'#' + colors.HEX;
return text;
return isHex ? innerText : (shouldBeHex ? 'rgb' : colorMode) +
(hasAlpha ? 'a' : '') + '(' + innerText + (hasAlpha ? ', ' + alpha : '') + ')';
},
RGB2HEX: function(RGB) {

@ -200,7 +200,7 @@
HSL = colors.RND.hsl,
dark = '#222',
light = '#ddd',
colorText = _color.toString(_$trigger._colorMode),
colorText = _color.toString(_$trigger._colorMode, _options.forceAlpha),
HUEContrast = colors.HUELuminance > 0.22 ? dark : light,
alphaContrast = colors.rgbaMixBlack.luminance > 0.22 ? dark : light,
h = (1 - colors.hsv.h) * _$xy_slider._height,
@ -277,7 +277,8 @@
buildCallback: noop,
body: document.body,
scrollResize: true,
gap: 4
gap: 4,
// forceAlpha: undefined,
// css: '',
// cssAddon: '',
// margin: '',

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save