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 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 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) 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 ####Some tips

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

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