Skip to content

Commit

Permalink
Merge pull request #33 from easylogic/fixed/#32
Browse files Browse the repository at this point in the history
fixed #32, support peerDependency codemirror
  • Loading branch information
easylogic authored Jun 27, 2019
2 parents 5dc686d + b992eed commit ebdca29
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 4 deletions.
132 changes: 132 additions & 0 deletions addon/codemirror-colorpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ var math = {
caculateAngle: caculateAngle
};

/**
* @method RGBtoHSV
*
* convert rgb to hsv
*
* color.RGBtoHSV(0, 0, 255) === { h : 240, s : 1, v : 1 } === '#FFFF00'
*
* @param {Number} R red color value
* @param {Number} G green color value
* @param {Number} B blue color value
* @return {Object} hsv color code
*/
function RGBtoHSV(r, g, b) {

if (arguments.length == 1) {
Expand Down Expand Up @@ -469,6 +481,18 @@ var fromLAB = {
LABtoXYZ: LABtoXYZ
};

/**
* @method HSVtoRGB
*
* convert hsv to rgb
*
* color.HSVtoRGB(0,0,1) === #FFFFF === { r : 255, g : 0, b : 0 }
*
* @param {Number} H hue color number (min : 0, max : 360)
* @param {Number} S Saturation number (min : 0, max : 1)
* @param {Number} V Value number (min : 0, max : 1 )
* @returns {Object}
*/
function HSVtoRGB(h, s, v) {

if (arguments.length == 1) {
Expand Down Expand Up @@ -1086,6 +1110,15 @@ var parser = {
color_split: color_split
};

/**
* @deprecated
*
* instead of this, use blend function
*
* @param {*} startColor
* @param {*} endColor
* @param {*} t
*/
function interpolateRGB(startColor, endColor) {
var t = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.5;
var exportFormat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'hex';
Expand Down Expand Up @@ -1906,6 +1939,7 @@ function crop() {
};
}

// Image manupulate
function resize(dstWidth, dstHeight) {
return function (bitmap, done) {
var c = Canvas.drawPixels(bitmap);
Expand Down Expand Up @@ -2131,6 +2165,9 @@ function bitonal(darkColor, lightColor) {
});
}

/*
* @param {Number} amount -100..100 , value < 0 is darken, value > 0 is brighten
*/
function brightness$1() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;

Expand Down Expand Up @@ -2158,6 +2195,10 @@ function brownie() {
});
}

/**
*
* @param {Number} amount from 0 to 100
*/
function clip() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;

Expand All @@ -2172,6 +2213,10 @@ function clip() {
}, { $C: $C });
}

/**
*
* @param {*} amount min = -128, max = 128
*/
function contrast$1() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;

Expand All @@ -2196,6 +2241,10 @@ function gamma() {
}, { $C: $C });
}

/**
* F.gradient('red', 'blue', 'yellow', 'white', 10)
* F.gradient('red, blue, yellow, white, 10')
*/
function gradient$1() {
// 전체 매개변수 기준으로 파싱
// 색이 아닌 것 기준으로 scale 변수로 인식
Expand Down Expand Up @@ -2267,6 +2316,9 @@ function grayscale(amount) {
});
}

/*
* @param {Number} amount 0..360
*/
function hue() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 360;

Expand Down Expand Up @@ -2350,6 +2402,10 @@ function matrix() {
});
}

/**
*
* @param {Number} amount 1..100
*/
function noise() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;

Expand Down Expand Up @@ -2393,6 +2449,9 @@ function polaroid() {
});
}

/*
* @param {Number} amount -100..100
*/
function saturation() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;

Expand All @@ -2412,6 +2471,9 @@ function saturation() {
});
}

/*
* @param {Number} amount 0..1
*/
function sepia() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;

Expand Down Expand Up @@ -2464,6 +2526,12 @@ function shift() {
});
}

/**
* change the relative darkness of (a part of an image) by overexposure to light.
* @param {*} r
* @param {*} g
* @param {*} b
*/
function solarize(redValue, greenValue, blueValue) {
var $redValue = parseParamNumber(redValue);
var $greenValue = parseParamNumber(greenValue);
Expand Down Expand Up @@ -2523,6 +2591,9 @@ function thresholdColor() {
});
}

/*
* @param {Number} amount 0..100
*/
function threshold() {
var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 200;
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
Expand Down Expand Up @@ -2584,6 +2655,11 @@ function blur () {
return convolution(createBlurMatrix(amount));
}

/*
* carve, mold, or stamp a design on (a surface) so that it stands out in relief.
*
* @param {Number} amount 0.0 .. 4.0
*/
function emboss() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4;

Expand Down Expand Up @@ -4157,13 +4233,22 @@ function normal () {
return convolution$1([0, 0, 0, 0, 1, 0, 0, 0, 0]);
}

/*
* carve, mold, or stamp a design on (a surface) so that it stands out in relief.
*
* @param {Number} amount 0.0 .. 4.0
*/
function emboss$1() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4;

amount = parseParamNumber$1(amount);
return convolution$1([amount * -2.0, -amount, 0.0, -amount, 1.0, amount, 0.0, amount, amount * 2.0]);
}

/**
*
* @param {Number} amount 0..1
*/
function gaussianBlur$1() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;

Expand Down Expand Up @@ -4280,6 +4365,9 @@ function bitonal$1(darkColor, lightColor) {
return shader('\n if ((pixelColor.r + pixelColor.g + pixelColor.b) > ' + checkVlue + ') {\n outColor = vec4(' + lightColorString + '.rgb, pixelColor.a);\n } else {\n outColor = vec4(' + darkColorString + '.rgb, pixelColor.a);\n }\n ');
}

/*
* @param {Number} amount -1..1 , value < 0 is darken, value > 0 is brighten
*/
function brightness$2() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;

Expand Down Expand Up @@ -4317,6 +4405,9 @@ function brownie$1() {
return matrix$3(0.5997023498159715, 0.34553243048391263, -0.2708298674538042, 0, -0.037703249837783157, 0.8609577587992641, 0.15059552388459913, 0, 0.24113635128153335, -0.07441037908422492, 0.44972182064877153, 0, 0, 0, 0, 1);
}

/*
* @param {Number} amount 0..1
*/
function clip$1() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;

Expand All @@ -4333,6 +4424,9 @@ function chaos() {
return shader('\n vec2 st = pixelColor.st;\n st *= ' + C + ';\n \n vec2 ipos = floor(st); // get the integer coords\n\n vec3 color = vec3(random( ipos ));\n\n outColor = vec4(color, pixelColor.a);\n ');
}

/*
* @param {Number} amount 0..1
*/
function contrast$2() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;

Expand All @@ -4341,6 +4435,9 @@ function contrast$2() {
return shader('\n outColor = pixelColor * ' + C + ';\n ');
}

/*
* @param {Number} amount -1..1 , value < 0 is darken, value > 0 is brighten
*/
function gamma$1() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;

Expand All @@ -4349,6 +4446,10 @@ function gamma$1() {
return shader('\n outColor = vec4(pow(pixelColor.r, ' + C + '), pow(pixelColor.g, ' + C + '), pow(pixelColor.b, ' + C + '), pixelColor.a );\n ');
}

/**
* F.gradient('red', 'blue', 'yellow', 'white', 10)
* F.gradient('red, blue, yellow, white, 10')
*/
function gradient$2() {
// 전체 매개변수 기준으로 파싱
// 색이 아닌 것 기준으로 scale 변수로 인식
Expand Down Expand Up @@ -4396,6 +4497,10 @@ function gradient$2() {
return shader('\n float rate = (pixelColor.r * 0.2126 + pixelColor.g * 0.7152 + pixelColor.b * 0.0722); \n\n ' + temp.join('\n') + ' \n ');
}

/**
*
* @param {Number} amount 0..1
*/
function grayscale$1() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;

Expand All @@ -4407,6 +4512,9 @@ function grayscale$1() {
}

//http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
/*
* @param {Number} amount 0..1 , (real value 0..360)
*/
function hue$1() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;

Expand All @@ -4428,6 +4536,10 @@ function kodachrome$1() {
return matrix$3(1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 0, 0, 0, 1);
}

/**
*
* @param {Number} amount 0..1
*/
function noise$1() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;

Expand All @@ -4438,6 +4550,10 @@ function noise$1() {
return shader('\n float rnd = ' + min + ' + random( pixelColor.st ) * (' + max + ' - ' + min + ');\n\n outColor = vec4(pixelColor.rgb + rnd, 1.0);\n ');
}

/**
*
* @param {Number} amount 0..1
*/
function opacity$1() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;

Expand All @@ -4451,6 +4567,9 @@ function polaroid$1() {
return matrix$3(1.438, -0.062, -0.062, 0, -0.122, 1.378, -0.122, 0, -0.016, -0.016, 1.483, 0, 0, 0, 0, 1);
}

/*
* @param {Number} amount 0..1
*/
function saturation$1() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;

Expand All @@ -4459,6 +4578,9 @@ function saturation$1() {
return matrix$3(L, 0, 0, 0, 0, L, 0, 0, 0, 0, L, 0, 0, 0, 0, L);
}

/*
* @param {Number} amount 0..100
*/
function sepia$1() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;

Expand Down Expand Up @@ -4506,13 +4628,22 @@ function thresholdColor$1() {
return shader('\n float c = ( (pixelColor.r * 0.2126 + pixelColor.g * 0.7152 + pixelColor.b * 0.0722) ) >= ' + scale + ' ? 1.0 : 0.0;\n\n outColor = vec4(c, c, c, pixelColor.a);\n ');
}

/*
* @param {Number} amount 0..100
*/
function threshold$1() {
var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 200;
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;

return thresholdColor$1(scale, amount, false);
}

/**
*
* @param {*} redTint 0..1
* @param {*} greenTint 0..1
* @param {*} blueTint 0..1
*/
function tint$1 () {
var redTint = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var greenTint = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
Expand Down Expand Up @@ -9120,6 +9251,7 @@ var ColorRing = function (_ColorWheel) {
return ColorRing;
}(ColorWheel);

// import ColorWheel from '../ui/ColorWheel'
var RingColorPicker = function (_BaseColorPicker) {
inherits(RingColorPicker, _BaseColorPicker);

Expand Down
3 changes: 2 additions & 1 deletion config/rollup.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import serve from 'rollup-plugin-serve'
import livereload from 'rollup-plugin-livereload'
import autoprefixer from 'autoprefixer'
import glslify from 'rollup-plugin-glslify';

import peerDepsExternal from 'rollup-plugin-peer-deps-external';

// rollup.config.js
export default {
Expand All @@ -20,6 +20,7 @@ export default {
},
name: 'CodeMirrorColorPicker',
plugins : [
peerDepsExternal(),
serve(),
livereload({watch: 'addon'}),
glslify({ basedir: 'src/util/glsl/source' }),
Expand Down
3 changes: 3 additions & 0 deletions config/rollup.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import babel from 'rollup-plugin-babel';
import uglify from 'rollup-plugin-uglify';
import autoprefixer from 'autoprefixer'
import glslify from 'rollup-plugin-glslify';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';


// rollup.config.js
export default [{
Expand All @@ -18,6 +20,7 @@ export default [{
},
name: 'CodeMirrorColorPicker',
plugins : [
peerDepsExternal(),
glslify({ basedir: 'src/util/glsl/source' }),
//scss({output : 'dist/' + packageJSON.name + '.css'}),
postcss({
Expand Down
2 changes: 1 addition & 1 deletion dist/codemirror-colorpicker.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit ebdca29

Please sign in to comment.