Initial commit

This commit is contained in:
Patrick Marsceill
2017-03-09 13:16:08 -05:00
commit b7b0d0d7bf
4147 changed files with 401224 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
var ranges = require('./ranges');
var channelWithDecimalPointPercentageTpl = '\\s*(?:\\.\\d+|_NUMBERS_(?:\\.\\d+)?)%\\s*',
channelWithDecimalPointTpl = channelWithDecimalPointPercentageTpl.replace('%', ''),
// Channels
percentageChannel = new RegExp(channelWithDecimalPointPercentageTpl.replace('_NUMBERS_', ranges['100'].source)),
eightBitChannel = new RegExp(channelWithDecimalPointTpl.replace('_NUMBERS_', ranges['255'].source)),
hueChannel = new RegExp(channelWithDecimalPointTpl.replace('_NUMBERS_', ranges['360'].source)),
alphaChannel = new RegExp(channelWithDecimalPointTpl.replace('_NUMBERS_', ranges['1'].source));
module.exports = {
eightBit: eightBitChannel,
hue: hueChannel,
percentage: percentageChannel,
alpha: alphaChannel
};
+47
View File
@@ -0,0 +1,47 @@
var colorNames = require('css-color-names');
var channels = require('./channels');
// Space templates
var opaqueSpaceTpl = '_space_\\(_1_,_2_,_3_\\)';
var alphaSpaceTpl = '_space_a\\(_1_,_2_,_3_,_a_\\)'.replace('_a_', channels.alpha.source);
var spaces = {
hex: /#(?:[0-9a-f]{6}|[0-9a-f]{3})(?![0-9a-f])/gi,
rgb: new RegExp(opaqueSpaceTpl
.replace('_space_', 'rgb')
.replace(/_[1-3]_/g, channels.eightBit.source), 'gi'),
rgba: new RegExp(alphaSpaceTpl
.replace('_space_', 'rgb')
.replace(/_[1-3]_/g, channels.eightBit.source), 'gi'),
hsv: new RegExp(opaqueSpaceTpl
.replace('_space_', 'hsv')
.replace('_1_', channels.hue.source)
.replace('_2_', channels.percentage.source)
.replace('_3_', channels.percentage.source), 'gi'),
hsva: new RegExp(alphaSpaceTpl
.replace('_space_', 'hsv')
.replace('_1_', channels.hue.source)
.replace('_2_', channels.percentage.source)
.replace('_3_', channels.percentage.source), 'gi'),
hsl: new RegExp(opaqueSpaceTpl
.replace('_space_', 'hsl')
.replace('_1_', channels.hue.source)
.replace('_2_', channels.percentage.source)
.replace('_3_', channels.percentage.source), 'gi'),
hsla: new RegExp(alphaSpaceTpl
.replace('_space_', 'hsl')
.replace('_1_', channels.hue.source)
.replace('_2_', channels.percentage.source)
.replace('_3_', channels.percentage.source), 'gi'),
names: new RegExp('\\b(?:' + Object.keys(colorNames).join('|') + ')\\b', 'gi')
};
spaces.all = new RegExp(Object.keys(spaces).map(function (space) {
return spaces[space].source;
}).join('|'), 'gi');
module.exports = spaces;
+6
View File
@@ -0,0 +1,6 @@
module.exports = {
'1': /1|0/,
'100': /100|(?:[1-9]?\d)/,
'255': /255|(?:25[0-4]|2[0-4]\d|1\d\d|[1-9]?\d)/,
'360': /360|(?:3[0-5]\d|[1-2]\d\d|[1-9]?\d)/
};