ace-colorpicker-rpk 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/.babelrc +30 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.md +35 -0
  3. package/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
  4. package/ChangeLogs.md +22 -0
  5. package/LICENSE +21 -0
  6. package/README.md +117 -0
  7. package/addon/ace-colorpicker.css +1074 -0
  8. package/addon/ace-colorpicker.js +9602 -0
  9. package/addon/sample/colorpicker.html +199 -0
  10. package/config/rollup.config.dev.js +52 -0
  11. package/config/rollup.config.prod.js +53 -0
  12. package/dist/ace-colorpicker.css +1074 -0
  13. package/dist/ace-colorpicker.js +9736 -0
  14. package/dist/ace-colorpicker.min.js +1 -0
  15. package/gl.html +56 -0
  16. package/index.html +172 -0
  17. package/package.json +87 -0
  18. package/resources/image/ace-editor.png +0 -0
  19. package/resources/image/colorpaletts.png +0 -0
  20. package/resources/image/colorpicker.png +0 -0
  21. package/resources/image/grapes.jpg +0 -0
  22. package/resources/image/palette-type.png +0 -0
  23. package/resources/image/scalecolors-title.png +0 -0
  24. package/resources/image/scalecolors.png +0 -0
  25. package/resources/image/screen-shot.png +0 -0
  26. package/resources/image/sketch-type.png +0 -0
  27. package/src/colorpicker/BaseBox.js +94 -0
  28. package/src/colorpicker/BaseColorPicker.js +404 -0
  29. package/src/colorpicker/BaseModule.js +19 -0
  30. package/src/colorpicker/BaseSlider.js +97 -0
  31. package/src/colorpicker/BaseStore.js +71 -0
  32. package/src/colorpicker/UIElement.js +46 -0
  33. package/src/colorpicker/VerticalSlider.js +57 -0
  34. package/src/colorpicker/chromedevtool/ColorControl.js +47 -0
  35. package/src/colorpicker/chromedevtool/index.js +36 -0
  36. package/src/colorpicker/index.js +37 -0
  37. package/src/colorpicker/macos/ColorControl.js +47 -0
  38. package/src/colorpicker/macos/index.js +38 -0
  39. package/src/colorpicker/mini/ColorControl.js +40 -0
  40. package/src/colorpicker/mini/index.js +24 -0
  41. package/src/colorpicker/mini-vertical/ColorControl.js +35 -0
  42. package/src/colorpicker/mini-vertical/index.js +23 -0
  43. package/src/colorpicker/module/ColorManager.js +111 -0
  44. package/src/colorpicker/module/ColorSetsList.js +132 -0
  45. package/src/colorpicker/ring/ColorControl.js +47 -0
  46. package/src/colorpicker/ring/index.js +42 -0
  47. package/src/colorpicker/ui/ColorInformation.js +216 -0
  48. package/src/colorpicker/ui/ColorPalette.js +130 -0
  49. package/src/colorpicker/ui/ColorRing.js +68 -0
  50. package/src/colorpicker/ui/ColorSetsChooser.js +96 -0
  51. package/src/colorpicker/ui/ColorWheel.js +257 -0
  52. package/src/colorpicker/ui/CurrentColorSets.js +81 -0
  53. package/src/colorpicker/ui/CurrentColorSetsContextMenu.js +63 -0
  54. package/src/colorpicker/ui/control/Hue.js +40 -0
  55. package/src/colorpicker/ui/control/Opacity.js +65 -0
  56. package/src/colorpicker/ui/control/Value.js +50 -0
  57. package/src/colorpicker/ui/control/VerticalHue.js +39 -0
  58. package/src/colorpicker/ui/control/VerticalOpacity.js +55 -0
  59. package/src/colorpicker/vscode/ColorControl.js +40 -0
  60. package/src/colorpicker/vscode/index.js +82 -0
  61. package/src/colorpicker/xd/ColorControl.js +36 -0
  62. package/src/colorpicker/xd/index.js +36 -0
  63. package/src/extension/ace/colorview.js +198 -0
  64. package/src/extension/ace/index.js +11 -0
  65. package/src/index.js +12 -0
  66. package/src/scss/colorpicker.scss +65 -0
  67. package/src/scss/colorview.scss +32 -0
  68. package/src/scss/component/button.scss +33 -0
  69. package/src/scss/component/colorchooser.scss +141 -0
  70. package/src/scss/component/colorsets-contextmenu.scss +33 -0
  71. package/src/scss/component/colorsets.scss +89 -0
  72. package/src/scss/component/control.scss +93 -0
  73. package/src/scss/component/gradient-editor.scss +260 -0
  74. package/src/scss/component/gradient-picker.scss +241 -0
  75. package/src/scss/component/information.scss +141 -0
  76. package/src/scss/component/palette.scss +45 -0
  77. package/src/scss/index.scss +5 -0
  78. package/src/scss/mixins.scss +21 -0
  79. package/src/scss/themes/macos.scss +71 -0
  80. package/src/scss/themes/mini-vertical.scss +94 -0
  81. package/src/scss/themes/mini.scss +76 -0
  82. package/src/scss/themes/palette.scss +85 -0
  83. package/src/scss/themes/ring.scss +57 -0
  84. package/src/scss/themes/sketch.scss +172 -0
  85. package/src/scss/themes/vscode.scss +93 -0
  86. package/src/scss/themes/xd.scss +88 -0
  87. package/src/util/Blender.js +29 -0
  88. package/src/util/Canvas.js +128 -0
  89. package/src/util/Color.js +27 -0
  90. package/src/util/ColorNames.js +14 -0
  91. package/src/util/Dom.js +361 -0
  92. package/src/util/Event.js +30 -0
  93. package/src/util/EventMachin.js +349 -0
  94. package/src/util/GL.js +8 -0
  95. package/src/util/HueColor.js +49 -0
  96. package/src/util/ImageFilter.js +9 -0
  97. package/src/util/ImageLoader.js +137 -0
  98. package/src/util/Kmeans.js +237 -0
  99. package/src/util/Matrix.js +196 -0
  100. package/src/util/State.js +42 -0
  101. package/src/util/blend/composite.js +124 -0
  102. package/src/util/blend/non-separable.js +118 -0
  103. package/src/util/blend/separable.js +76 -0
  104. package/src/util/filter/StackBlur.js +517 -0
  105. package/src/util/filter/functions.js +829 -0
  106. package/src/util/filter/image/crop.js +16 -0
  107. package/src/util/filter/image/flipH.js +23 -0
  108. package/src/util/filter/image/flipV.js +25 -0
  109. package/src/util/filter/image/histogram.js +45 -0
  110. package/src/util/filter/image/index.js +18 -0
  111. package/src/util/filter/image/resize.js +18 -0
  112. package/src/util/filter/image/rotate.js +39 -0
  113. package/src/util/filter/image/rotateDegree.js +53 -0
  114. package/src/util/filter/index.js +11 -0
  115. package/src/util/filter/matrix/blur.js +12 -0
  116. package/src/util/filter/matrix/emboss.js +17 -0
  117. package/src/util/filter/matrix/gaussian-blur-5x.js +17 -0
  118. package/src/util/filter/matrix/gaussian-blur.js +16 -0
  119. package/src/util/filter/matrix/grayscale2.js +16 -0
  120. package/src/util/filter/matrix/index.js +58 -0
  121. package/src/util/filter/matrix/kirsch-horizontal.js +13 -0
  122. package/src/util/filter/matrix/kirsch-vertical.js +13 -0
  123. package/src/util/filter/matrix/laplacian-5x.js +16 -0
  124. package/src/util/filter/matrix/laplacian.js +14 -0
  125. package/src/util/filter/matrix/motion-blur-2.js +18 -0
  126. package/src/util/filter/matrix/motion-blur-3.js +19 -0
  127. package/src/util/filter/matrix/motion-blur.js +18 -0
  128. package/src/util/filter/matrix/negative.js +16 -0
  129. package/src/util/filter/matrix/normal.js +11 -0
  130. package/src/util/filter/matrix/sepia2.js +16 -0
  131. package/src/util/filter/matrix/sharpen.js +14 -0
  132. package/src/util/filter/matrix/sobel-horizontal.js +11 -0
  133. package/src/util/filter/matrix/sobel-vertical.js +11 -0
  134. package/src/util/filter/matrix/stack-blur.js +15 -0
  135. package/src/util/filter/matrix/transparency.js +16 -0
  136. package/src/util/filter/matrix/unsharp-masking.js +16 -0
  137. package/src/util/filter/multi/index.js +9 -0
  138. package/src/util/filter/multi/kirsch.js +7 -0
  139. package/src/util/filter/multi/sobel.js +7 -0
  140. package/src/util/filter/multi/vintage.js +7 -0
  141. package/src/util/filter/pixel/bitonal.js +24 -0
  142. package/src/util/filter/pixel/brightness.js +19 -0
  143. package/src/util/filter/pixel/brownie.js +23 -0
  144. package/src/util/filter/pixel/clip.js +21 -0
  145. package/src/util/filter/pixel/contrast.js +18 -0
  146. package/src/util/filter/pixel/gamma.js +13 -0
  147. package/src/util/filter/pixel/gradient.js +52 -0
  148. package/src/util/filter/pixel/grayscale.js +27 -0
  149. package/src/util/filter/pixel/hue.js +28 -0
  150. package/src/util/filter/pixel/index.js +52 -0
  151. package/src/util/filter/pixel/invert.js +16 -0
  152. package/src/util/filter/pixel/kodachrome.js +23 -0
  153. package/src/util/filter/pixel/matrix.js +28 -0
  154. package/src/util/filter/pixel/noise.js +24 -0
  155. package/src/util/filter/pixel/opacity.js +14 -0
  156. package/src/util/filter/pixel/polaroid.js +23 -0
  157. package/src/util/filter/pixel/saturation.js +30 -0
  158. package/src/util/filter/pixel/sepia.js +28 -0
  159. package/src/util/filter/pixel/shade.js +21 -0
  160. package/src/util/filter/pixel/shift.js +23 -0
  161. package/src/util/filter/pixel/solarize.js +23 -0
  162. package/src/util/filter/pixel/technicolor.js +23 -0
  163. package/src/util/filter/pixel/threshold-color.js +35 -0
  164. package/src/util/filter/pixel/threshold.js +7 -0
  165. package/src/util/filter/pixel/tint.js +20 -0
  166. package/src/util/functions/formatter.js +99 -0
  167. package/src/util/functions/fromCMYK.js +17 -0
  168. package/src/util/functions/fromHSL.js +52 -0
  169. package/src/util/functions/fromHSV.js +64 -0
  170. package/src/util/functions/fromLAB.js +99 -0
  171. package/src/util/functions/fromRGB.js +220 -0
  172. package/src/util/functions/fromYCrCb.js +16 -0
  173. package/src/util/functions/func.js +194 -0
  174. package/src/util/functions/image.js +145 -0
  175. package/src/util/functions/math.js +56 -0
  176. package/src/util/functions/mixin.js +164 -0
  177. package/src/util/functions/parser.js +294 -0
  178. package/src/util/gl/filter/index.js +9 -0
  179. package/src/util/gl/filter/matrix/blur.js +9 -0
  180. package/src/util/gl/filter/matrix/emboss.js +17 -0
  181. package/src/util/gl/filter/matrix/gaussian-blur-5x.js +15 -0
  182. package/src/util/gl/filter/matrix/gaussian-blur.js +19 -0
  183. package/src/util/gl/filter/matrix/grayscale2.js +13 -0
  184. package/src/util/gl/filter/matrix/index.js +55 -0
  185. package/src/util/gl/filter/matrix/kirsch-horizontal.js +11 -0
  186. package/src/util/gl/filter/matrix/kirsch-vertical.js +11 -0
  187. package/src/util/gl/filter/matrix/laplacian-5x.js +13 -0
  188. package/src/util/gl/filter/matrix/laplacian.js +11 -0
  189. package/src/util/gl/filter/matrix/motion-blur-2.js +17 -0
  190. package/src/util/gl/filter/matrix/motion-blur-3.js +17 -0
  191. package/src/util/gl/filter/matrix/motion-blur.js +17 -0
  192. package/src/util/gl/filter/matrix/negative.js +13 -0
  193. package/src/util/gl/filter/matrix/normal.js +8 -0
  194. package/src/util/gl/filter/matrix/sepia2.js +13 -0
  195. package/src/util/gl/filter/matrix/sharpen.js +11 -0
  196. package/src/util/gl/filter/matrix/sobel-horizontal.js +11 -0
  197. package/src/util/gl/filter/matrix/sobel-vertical.js +11 -0
  198. package/src/util/gl/filter/matrix/transparency.js +13 -0
  199. package/src/util/gl/filter/matrix/unsharp-masking.js +14 -0
  200. package/src/util/gl/filter/multi/index.js +9 -0
  201. package/src/util/gl/filter/multi/kirsch.js +7 -0
  202. package/src/util/gl/filter/multi/sobel.js +7 -0
  203. package/src/util/gl/filter/multi/vintage.js +7 -0
  204. package/src/util/gl/filter/pixel/bitonal.js +22 -0
  205. package/src/util/gl/filter/pixel/brightness.js +14 -0
  206. package/src/util/gl/filter/pixel/brownie.js +11 -0
  207. package/src/util/gl/filter/pixel/chaos.js +20 -0
  208. package/src/util/gl/filter/pixel/clip.js +20 -0
  209. package/src/util/gl/filter/pixel/contrast.js +16 -0
  210. package/src/util/gl/filter/pixel/gamma.js +16 -0
  211. package/src/util/gl/filter/pixel/gradient.js +59 -0
  212. package/src/util/gl/filter/pixel/grayscale.js +22 -0
  213. package/src/util/gl/filter/pixel/hue.js +19 -0
  214. package/src/util/gl/filter/pixel/index.js +54 -0
  215. package/src/util/gl/filter/pixel/invert.js +18 -0
  216. package/src/util/gl/filter/pixel/kodachrome.js +11 -0
  217. package/src/util/gl/filter/pixel/matrix.js +29 -0
  218. package/src/util/gl/filter/pixel/noise.js +18 -0
  219. package/src/util/gl/filter/pixel/opacity.js +17 -0
  220. package/src/util/gl/filter/pixel/polaroid.js +11 -0
  221. package/src/util/gl/filter/pixel/saturation.js +20 -0
  222. package/src/util/gl/filter/pixel/sepia.js +19 -0
  223. package/src/util/gl/filter/pixel/shade.js +20 -0
  224. package/src/util/gl/filter/pixel/shift.js +11 -0
  225. package/src/util/gl/filter/pixel/solarize.js +21 -0
  226. package/src/util/gl/filter/pixel/technicolor.js +11 -0
  227. package/src/util/gl/filter/pixel/threshold-color.js +15 -0
  228. package/src/util/gl/filter/pixel/threshold.js +7 -0
  229. package/src/util/gl/filter/pixel/tint.js +25 -0
  230. package/src/util/gl/filter/util.js +185 -0
  231. package/src/util/gl/functions.js +158 -0
  232. package/src/util/gl/index.js +543 -0
  233. package/src/util/index.js +17 -0
  234. package/stand.html +975 -0
  235. package/test/util.Blend.spec.js +15 -0
  236. package/test/util.Color.spec.js +200 -0
  237. package/test/util.Filter.spec.js +12 -0
  238. package/test/util.ImageFilter.spec.js +16 -0
@@ -0,0 +1,22 @@
1
+ import Color from '../../../Color'
2
+ import {
3
+ shader,
4
+ colorToVec4,
5
+ toFloatString
6
+ } from '../util'
7
+
8
+ export default function bitonal(darkColor, lightColor, threshold = 0.5) {
9
+ let checkVlue = toFloatString(threshold)
10
+ let darkColorString = colorToVec4(Color.parse(darkColor))
11
+ let lightColorString = colorToVec4(Color.parse(lightColor))
12
+
13
+ return shader(`
14
+ if ((pixelColor.r + pixelColor.g + pixelColor.b) > ${checkVlue}) {
15
+ outColor = vec4(${lightColorString}.rgb, pixelColor.a);
16
+ } else {
17
+ outColor = vec4(${darkColorString}.rgb, pixelColor.a);
18
+ }
19
+ `);
20
+ }
21
+
22
+
@@ -0,0 +1,14 @@
1
+ import {
2
+ shader, toFloatString, parseParamNumber
3
+ } from '../util'
4
+
5
+ /*
6
+ * @param {Number} amount -1..1 , value < 0 is darken, value > 0 is brighten
7
+ */
8
+ export default function brightness (amount = 1) {
9
+ const C = toFloatString( parseParamNumber(amount) );
10
+
11
+ return shader(`
12
+ outColor = pixelColor + (${C});
13
+ `);
14
+ }
@@ -0,0 +1,11 @@
1
+ import matrix from './matrix'
2
+
3
+ export default function brownie () {
4
+
5
+ return matrix(
6
+ 0.5997023498159715,0.34553243048391263,-0.2708298674538042,0,
7
+ -0.037703249837783157,0.8609577587992641,0.15059552388459913,0,
8
+ 0.24113635128153335,-0.07441037908422492,0.44972182064877153,0,
9
+ 0,0,0,1
10
+ )
11
+ }
@@ -0,0 +1,20 @@
1
+ import {
2
+ shader,
3
+ parseParamNumber,
4
+ toFloatString
5
+ } from '../util'
6
+
7
+ export default function chaos (amount = 10) {
8
+ const C = toFloatString( parseParamNumber(amount) );
9
+
10
+ return shader(`
11
+ vec2 st = pixelColor.st;
12
+ st *= ${C};
13
+
14
+ vec2 ipos = floor(st); // get the integer coords
15
+
16
+ vec3 color = vec3(random( ipos ));
17
+
18
+ outColor = vec4(color, pixelColor.a);
19
+ `);
20
+ }
@@ -0,0 +1,20 @@
1
+
2
+ import {
3
+ shader, toFloatString, parseParamNumber
4
+ } from '../util'
5
+
6
+ /*
7
+ * @param {Number} amount 0..1
8
+ */
9
+ export default function clip (amount = 0) {
10
+ const C = toFloatString(parseParamNumber(amount))
11
+
12
+ return shader(`
13
+ outColor = vec4(
14
+ (pixelColor.r > 1.0 - ${C}) ? 1.0 : 0.0,
15
+ (pixelColor.g > 1.0 - ${C}) ? 1.0 : 0.0,
16
+ (pixelColor.b > 1.0 - ${C}) ? 1.0 : 0.0,
17
+ pixelColor.a
18
+ );
19
+ `);
20
+ }
@@ -0,0 +1,16 @@
1
+ import {
2
+ shader,
3
+ parseParamNumber,
4
+ toFloatString
5
+ } from '../util'
6
+
7
+ /*
8
+ * @param {Number} amount 0..1
9
+ */
10
+ export default function contrast (amount = 1) {
11
+ const C = toFloatString(parseParamNumber(amount));
12
+
13
+ return shader(`
14
+ outColor = pixelColor * ${C};
15
+ `);
16
+ }
@@ -0,0 +1,16 @@
1
+ import {
2
+ shader,
3
+ parseParamNumber,
4
+ toFloatString
5
+ } from '../util'
6
+
7
+ /*
8
+ * @param {Number} amount -1..1 , value < 0 is darken, value > 0 is brighten
9
+ */
10
+ export default function gamma (amount = 1) {
11
+ const C = toFloatString( parseParamNumber(amount) )
12
+
13
+ return shader(`
14
+ outColor = vec4(pow(pixelColor.r, ${C}), pow(pixelColor.g, ${C}), pow(pixelColor.b, ${C}), pixelColor.a );
15
+ `);
16
+ }
@@ -0,0 +1,59 @@
1
+ import Color from '../../../Color'
2
+ import {
3
+ shader,
4
+ colorToVec4,
5
+ toFloatString
6
+ } from '../util'
7
+ /**
8
+ * F.gradient('red', 'blue', 'yellow', 'white', 10)
9
+ * F.gradient('red, blue, yellow, white, 10')
10
+ */
11
+ export default function gradient () {
12
+ // 전체 매개변수 기준으로 파싱
13
+ // 색이 아닌 것 기준으로 scale 변수로 인식
14
+
15
+ let params = [...arguments];
16
+
17
+ if (params.length === 1 && typeof params[0] === 'string') {
18
+ params = Color.convertMatchesArray(params[0])
19
+ }
20
+
21
+ params = params.map(arg => {
22
+ return arg
23
+ }).join(', ')
24
+
25
+ let colors = Color.parseGradient(params);
26
+
27
+ colors[0][1] = 0;
28
+ colors[colors.length-1][1] = 1;
29
+
30
+ colors = colors.map(c => {
31
+ const {r, g, b, a} = Color.parse(c[0])
32
+ return [{r, g, b, a}, c[1]];
33
+ })
34
+
35
+ let temp = []
36
+
37
+ for(var i = 0, len = colors.length; i < len - 1; i++) {
38
+ const start = colors[i];
39
+ const end = colors[i+1];
40
+
41
+ const startColor = colorToVec4(start[0])
42
+ const endColor = colorToVec4(end[0])
43
+
44
+ const startRate = toFloatString (start[1]);
45
+ const endRate = toFloatString (end[1]);
46
+
47
+ temp.push(`
48
+ if (${startRate} <= rate && rate < ${endRate}) {
49
+ outColor = mix(${startColor}, ${endColor}, (rate - ${startRate})/(${endRate} - ${startRate}));
50
+ }
51
+ `)
52
+ }
53
+
54
+ return shader(`
55
+ float rate = (pixelColor.r * 0.2126 + pixelColor.g * 0.7152 + pixelColor.b * 0.0722);
56
+
57
+ ${temp.join('\n')}
58
+ `)
59
+ }
@@ -0,0 +1,22 @@
1
+ import {
2
+ parseParamNumber
3
+ } from '../util'
4
+
5
+ import matrix from './matrix'
6
+
7
+ /**
8
+ *
9
+ * @param {Number} amount 0..1
10
+ */
11
+ export default function grayscale (amount = 1) {
12
+ let C = parseParamNumber(amount);
13
+
14
+ if (C > 1) C = 1;
15
+
16
+ return matrix(
17
+ (0.2126 + 0.7874 * (1 - C)), (0.7152 - 0.7152 * (1 - C)), (0.0722 - 0.0722 * (1 - C)), 0,
18
+ (0.2126 - 0.2126 * (1 - C)), (0.7152 + 0.2848 * (1 - C)), (0.0722 - 0.0722 * (1 - C)), 0,
19
+ (0.2126 - 0.2126 * (1 - C)), (0.7152 - 0.7152 * (1 - C)), (0.0722 + 0.9278 * (1 - C)), 0,
20
+ 0, 0, 0, 1
21
+ );
22
+ }
@@ -0,0 +1,19 @@
1
+ //http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
2
+ import {
3
+ shader,
4
+ parseParamNumber,
5
+ toFloatString
6
+ } from '../util'
7
+
8
+ /*
9
+ * @param {Number} amount 0..1 , (real value 0..360)
10
+ */
11
+ export default function hue (amount = 1) {
12
+ const C = toFloatString( parseParamNumber(amount))
13
+
14
+ return shader(`
15
+ vec3 hsv = rgb2hsv(pixelColor.rgb);
16
+ hsv.x += ${C};
17
+ outColor = vec4(hsv2rgb(hsv).rgb, pixelColor.a);
18
+ `);
19
+ }
@@ -0,0 +1,54 @@
1
+
2
+ import bitonal from './bitonal'
3
+ import brightness from './brightness'
4
+ import brownie from './brownie'
5
+ import clip from './clip'
6
+ import chaos from './chaos'
7
+ import contrast from './contrast'
8
+ import gamma from './gamma'
9
+ import gradient from './gradient'
10
+ import grayscale from './grayscale'
11
+ import hue from './hue'
12
+ import invert from './invert'
13
+ import kodachrome from './kodachrome'
14
+ import matrix from './matrix'
15
+ import noise from './noise'
16
+ import opacity from './opacity'
17
+ import polaroid from './polaroid'
18
+ import saturation from './saturation'
19
+ import sepia from './sepia'
20
+ import shade from './shade'
21
+ import shift from './shift'
22
+ import solarize from './solarize'
23
+ import technicolor from './technicolor'
24
+ import threshold from './threshold'
25
+ import thresholdColor from './threshold-color'
26
+ import tint from './tint'
27
+
28
+ export default {
29
+ bitonal,
30
+ brightness,
31
+ brownie,
32
+ clip,
33
+ chaos,
34
+ contrast,
35
+ gamma,
36
+ gradient,
37
+ grayscale,
38
+ hue,
39
+ invert,
40
+ kodachrome,
41
+ matrix,
42
+ noise,
43
+ opacity,
44
+ polaroid,
45
+ saturation,
46
+ sepia,
47
+ shade,
48
+ shift,
49
+ solarize,
50
+ technicolor,
51
+ threshold,
52
+ 'threshold-color': thresholdColor,
53
+ tint
54
+ }
@@ -0,0 +1,18 @@
1
+ import {
2
+ shader,
3
+ parseParamNumber,
4
+ toFloatString
5
+ } from '../util'
6
+
7
+ export default function invert (amount = 1) {
8
+ const C = toFloatString( parseParamNumber(amount) );
9
+
10
+ return shader(`
11
+ outColor = vec4(
12
+ (1.0 - pixelColor.r) * ${C},
13
+ (1.0 - pixelColor.g) * ${C},
14
+ (1.0 - pixelColor.b) * ${C},
15
+ pixelColor.a
16
+ );
17
+ `);
18
+ }
@@ -0,0 +1,11 @@
1
+ import matrix from './matrix'
2
+
3
+ export default function kodachrome () {
4
+
5
+ return matrix(
6
+ 1.1285582396593525,-0.3967382283601348,-0.03992559172921793,0,
7
+ -0.16404339962244616,1.0835251566291304,-0.05498805115633132,0,
8
+ -0.16786010706155763,-0.5603416277695248,1.6014850761964943,0,
9
+ 0,0,0,1
10
+ )
11
+ }
@@ -0,0 +1,29 @@
1
+ import {
2
+ shader,
3
+ toFloatString
4
+ } from '../util'
5
+
6
+ export default function matrix (
7
+ $a = 0, $b = 0, $c = 0, $d = 0,
8
+ $e = 0, $f = 0, $g = 0, $h = 0,
9
+ $i = 0, $j = 0, $k = 0, $l = 0,
10
+ $m = 0, $n = 0, $o = 0, $p = 0
11
+ ) {
12
+
13
+ const matrix = [
14
+ $a, $b, $c, $d,
15
+ $e, $f, $g, $h,
16
+ $i, $j, $k, $l,
17
+ $m, $n, $o, $p
18
+ ].map(toFloatString)
19
+
20
+ return shader(`
21
+
22
+ outColor = vec4(
23
+ ${matrix[0]} * pixelColor.r + ${matrix[1]} * pixelColor.g + ${matrix[2]} * pixelColor.b + ${matrix[3]} * pixelColor.a,
24
+ ${matrix[4]} * pixelColor.r + ${matrix[5]} * pixelColor.g + ${matrix[6]} * pixelColor.b + ${matrix[7]} * pixelColor.a,
25
+ ${matrix[8]} * pixelColor.r + ${matrix[9]} * pixelColor.g + ${matrix[10]} * pixelColor.b + ${matrix[11]} * pixelColor.a,
26
+ ${matrix[12]} * pixelColor.r + ${matrix[13]} * pixelColor.g + ${matrix[14]} * pixelColor.b + ${matrix[15]} * pixelColor.a
27
+ );
28
+ `);
29
+ }
@@ -0,0 +1,18 @@
1
+ import { shader, parseParamNumber, toFloatString } from '../util';
2
+
3
+
4
+ /**
5
+ *
6
+ * @param {Number} amount 0..1
7
+ */
8
+ export default function noise (amount = 1) {
9
+
10
+ const C = Math.abs( parseParamNumber(amount))
11
+ const min = toFloatString( -C )
12
+ const max = toFloatString( C )
13
+ return shader(`
14
+ float rnd = ${min} + random( pixelColor.st ) * (${max} - ${min});
15
+
16
+ outColor = vec4(pixelColor.rgb + rnd, 1.0);
17
+ `);
18
+ }
@@ -0,0 +1,17 @@
1
+ import {
2
+ shader,
3
+ parseParamNumber,
4
+ toFloatString
5
+ } from '../util'
6
+
7
+ /**
8
+ *
9
+ * @param {Number} amount 0..1
10
+ */
11
+ export default function opacity (amount = 1) {
12
+ const C = toFloatString( parseParamNumber(amount));
13
+
14
+ return shader(`
15
+ outColor = vec4(pixelColor.rgb, pixelColor.a * ${C});
16
+ `);
17
+ }
@@ -0,0 +1,11 @@
1
+ import matrix from './matrix'
2
+
3
+ export default function polaroid () {
4
+
5
+ return matrix(
6
+ 1.438,-0.062,-0.062,0,
7
+ -0.122,1.378,-0.122,0,
8
+ -0.016,-0.016,1.483,0,
9
+ 0,0,0,1
10
+ )
11
+ }
@@ -0,0 +1,20 @@
1
+ import {
2
+ parseParamNumber
3
+ } from '../util'
4
+ import matrix from './matrix'
5
+
6
+
7
+ /*
8
+ * @param {Number} amount 0..1
9
+ */
10
+ export default function saturation (amount = 0) {
11
+ const L = 1 - Math.abs(parseParamNumber(amount));
12
+
13
+ return matrix(
14
+ L, 0, 0, 0,
15
+ 0, L, 0, 0,
16
+ 0, 0, L, 0,
17
+ 0, 0, 0, L
18
+ )
19
+
20
+ }
@@ -0,0 +1,19 @@
1
+ import {
2
+ parseParamNumber
3
+ } from '../util';
4
+ import matrix from "./matrix";
5
+
6
+ /*
7
+ * @param {Number} amount 0..100
8
+ */
9
+ export default function sepia (amount = 1) {
10
+ let C = parseParamNumber(amount);
11
+ if (C > 1) C = 1;
12
+
13
+ return matrix(
14
+ (0.393 + 0.607 * (1 - C)), (0.769 - 0.769 * (1 - C)), (0.189 - 0.189 * (1 - C)), 0,
15
+ (0.349 - 0.349 * (1 - C)), (0.686 + 0.314 * (1 - C)), (0.168 - 0.168 * (1 - C)), 0,
16
+ (0.272 - 0.272 * (1 - C)), (0.534 - 0.534 * (1 - C)), (0.131 + 0.869 * (1 - C)), 0,
17
+ 0, 0, 0, 1
18
+ )
19
+ }
@@ -0,0 +1,20 @@
1
+ import {
2
+ shader,
3
+ parseParamNumber,
4
+ toFloatString
5
+ } from '../util'
6
+
7
+ export default function shade(redValue = 1, greenValue = 1, blueValue = 1) {
8
+ const r = toFloatString(parseParamNumber(redValue) / 255)
9
+ const g = toFloatString(parseParamNumber(greenValue) /255)
10
+ const b = toFloatString(parseParamNumber(blueValue) /255)
11
+
12
+ return shader(`
13
+ outColor = vec4(
14
+ pixelColor.r * ${r},
15
+ pixelColor.g * ${g},
16
+ pixelColor.b * ${b},
17
+ pixelColor.a
18
+ );
19
+ `);
20
+ }
@@ -0,0 +1,11 @@
1
+ import matrix from './matrix'
2
+
3
+ export default function shift () {
4
+
5
+ return matrix(
6
+ 1.438,-0.062,-0.062,0,
7
+ -0.122,1.378,-0.122,0,
8
+ -0.016,-0.016,1.483,0,
9
+ 0,0,0,1
10
+ );
11
+ }
@@ -0,0 +1,21 @@
1
+ import {
2
+ shader,
3
+ parseParamNumber,
4
+ toFloatString
5
+ } from '../util'
6
+
7
+ export default function solarize (redValue, greenValue, blueValue) {
8
+ const r = toFloatString( parseParamNumber(redValue) )
9
+ const g = toFloatString( parseParamNumber(greenValue) )
10
+ const b = toFloatString( parseParamNumber(blueValue) )
11
+
12
+ return shader(`
13
+ outColor = vec4(
14
+ (pixelColor.r < ${r}) ? 1.0 - pixelColor.r: pixelColor.r,
15
+ (pixelColor.g < ${g}) ? 1.0 - pixelColor.g: pixelColor.g,
16
+ (pixelColor.b < ${b}) ? 1.0 - pixelColor.b: pixelColor.b,
17
+ pixelColor.a
18
+ );
19
+ `);
20
+ }
21
+
@@ -0,0 +1,11 @@
1
+ import matrix from './matrix'
2
+
3
+ export default function technicolor () {
4
+
5
+ return matrix(
6
+ 1.9125277891456083,-0.8545344976951645,-0.09155508482755585,0,
7
+ -0.3087833385928097,1.7658908555458428,-0.10601743074722245,0,
8
+ -0.231103377548616,-0.7501899197440212,1.847597816108189,0,
9
+ 0,0,0,1
10
+ )
11
+ }
@@ -0,0 +1,15 @@
1
+ import {
2
+ parseParamNumber,
3
+ shader,
4
+ toFloatString
5
+ } from '../util'
6
+
7
+ export default function thresholdColor (scale = 1) {
8
+ scale = toFloatString( parseParamNumber(scale) )
9
+
10
+ return shader(`
11
+ float c = ( (pixelColor.r * 0.2126 + pixelColor.g * 0.7152 + pixelColor.b * 0.0722) ) >= ${scale} ? 1.0 : 0.0;
12
+
13
+ outColor = vec4(c, c, c, pixelColor.a);
14
+ `)
15
+ }
@@ -0,0 +1,7 @@
1
+ import thresholdColor from './threshold-color'
2
+ /*
3
+ * @param {Number} amount 0..100
4
+ */
5
+ export default function threshold (scale = 200, amount = 100) {
6
+ return thresholdColor(scale, amount, false)
7
+ }
@@ -0,0 +1,25 @@
1
+ import {
2
+ shader,
3
+ parseParamNumber
4
+ } from '../util'
5
+
6
+ /**
7
+ *
8
+ * @param {*} redTint 0..1
9
+ * @param {*} greenTint 0..1
10
+ * @param {*} blueTint 0..1
11
+ */
12
+ export default function (redTint = 0, greenTint = 0, blueTint = 0) {
13
+ const r = parseParamNumber(redTint)
14
+ const g = parseParamNumber(greenTint)
15
+ const b = parseParamNumber(blueTint)
16
+
17
+ return shader(`
18
+ outColor = vec4(
19
+ pixelColor.r += (1 - pixelColor.r) * ${r},
20
+ pixelColor.g += (1 - pixelColor.g) * ${g},
21
+ pixelColor.b += (1 - pixelColor.b) * ${b},
22
+ pixelColor.a
23
+ );
24
+ `);
25
+ }