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,16 @@
1
+ import { createBitmap } from '../functions'
2
+
3
+ export default function crop (startX = 0, startY = 0, width, height) {
4
+
5
+ const newBitmap = createBitmap(width * height * 4, width, height)
6
+
7
+ return function (bitmap, done, opt = {}) {
8
+ for (var y = startY, realY = 0; y < height; y++, realY++) {
9
+ for (var x = startX, realX = 0; x < width; x++, realX++) {
10
+ newBitmap.pixels[realY * width * realX] = bitmap.pixels[y * width * x]
11
+ }
12
+ }
13
+
14
+ done(newBitmap);
15
+ }
16
+ }
@@ -0,0 +1,23 @@
1
+ import {swapColor} from '../functions'
2
+ export default function flipH () {
3
+ return function (bitmap, done, opt = {}) {
4
+
5
+ const width = bitmap.width
6
+ const height = bitmap.height
7
+ const isCenter = width % 2 == 1 ? 1 : 0
8
+
9
+ const halfWidth = isCenter ? Math.floor(width / 2) : width / 2 ;
10
+
11
+ for (var y = 0; y < height; y++) {
12
+ for (var x = 0; x < halfWidth; x++) {
13
+
14
+ var startIndex = (y * width + x) << 2
15
+ var endIndex = (y * width + (width -1 - x) ) << 2
16
+ swapColor(bitmap.pixels, startIndex, endIndex)
17
+
18
+ }
19
+ }
20
+
21
+ done(bitmap);
22
+ }
23
+ }
@@ -0,0 +1,25 @@
1
+ import {
2
+ swapColor
3
+ } from '../functions'
4
+ export default function flipV () {
5
+ return function (bitmap, done, opt = {}) {
6
+
7
+ const width = bitmap.width
8
+ const height = bitmap.height
9
+ const isCenter = height % 2 == 1 ? 1 : 0
10
+
11
+ const halfHeight = isCenter ? Math.floor(height / 2) : height / 2 ;
12
+
13
+ for (var y = 0; y < halfHeight; y++) {
14
+ for (var x = 0; x < width; x++) {
15
+
16
+ var startIndex = (y * width + x) << 2
17
+ var endIndex = ((height -1 - y) * width + x ) << 2
18
+ swapColor(bitmap.pixels, startIndex, endIndex)
19
+
20
+ }
21
+ }
22
+
23
+ done(bitmap);
24
+ }
25
+ }
@@ -0,0 +1,45 @@
1
+ import { pixel } from '../functions'
2
+
3
+ export default function histogram (type = 'gray', points = []) {
4
+ var $realPoints = []
5
+
6
+ for(var i = 0; i < points.length - 1; i++) {
7
+ var sp = points[i]
8
+ var ep = points[i+1]
9
+
10
+ var distX = ep[0] - sp[0]
11
+ var distY = ep[1] - sp[1]
12
+
13
+ var rate = distY / distX
14
+
15
+ for(var realIndex = 0, start = sp[0]; realIndex < distX; realIndex++, start++ ) {
16
+ $realPoints[start] = sp[1] + realIndex * rate
17
+ }
18
+ }
19
+
20
+ $realPoints[255] = 255
21
+
22
+ if (type === 'red') {
23
+ return pixel(() => {
24
+ $r = $realPoints[$r];
25
+ }, { }, { $realPoints })
26
+ } else if (type === 'green') {
27
+ return pixel(() => {
28
+ $g = $realPoints[$g];
29
+ }, { }, { $realPoints })
30
+ } else if (type === 'blue') {
31
+ return pixel(() => {
32
+ $b = $realPoints[$b];
33
+ }, { }, { $realPoints })
34
+ } else {
35
+ return pixel(() => {
36
+
37
+ const l = Color.RGBtoYCrCb($r, $g, $b);
38
+ const c = Color.YCrCbtoRGB(clamp($realPoints[clamp(l.y)]), l.cr, l.cb, 0)
39
+ $r = c.r
40
+ $g = c.g
41
+ $b = c.b
42
+
43
+ }, { }, { $realPoints })
44
+ }
45
+ }
@@ -0,0 +1,18 @@
1
+ import crop from './crop'
2
+ import resize from './resize'
3
+ import flipV from './flipV'
4
+ import flipH from './flipH'
5
+ import rotate from './rotate'
6
+ import rotateDegree from './rotateDegree'
7
+ import histogram from './histogram'
8
+
9
+ export default {
10
+ crop,
11
+ resize,
12
+ flipH,
13
+ flipV,
14
+ rotate,
15
+ rotateDegree,
16
+ histogram,
17
+ 'rotate-degree' : rotateDegree
18
+ }
@@ -0,0 +1,18 @@
1
+ import Canvas from '../../Canvas'
2
+ // Image manupulate
3
+ export default function resize (dstWidth, dstHeight) {
4
+ return function (bitmap, done, opt = {}) {
5
+
6
+ var c = Canvas.drawPixels(bitmap);
7
+ var context = c.getContext('2d');
8
+
9
+ c.width = dstWidth;
10
+ c.height = dstHeight;
11
+
12
+ done({
13
+ pixels: new Uint8ClampedArray(context.getImageData(0, 0, dstWidth, dstHeight).data),
14
+ width: dstWidth,
15
+ height: dstHeight
16
+ })
17
+ }
18
+ }
@@ -0,0 +1,39 @@
1
+ import {
2
+ parseParamNumber,
3
+ packXY,
4
+ createBitmap,
5
+ fillPixelColor
6
+ } from '../functions'
7
+
8
+ import rotateDegree from './rotateDegree'
9
+
10
+ export default function rotate (degree = 0) {
11
+ degree = parseParamNumber(degree)
12
+ degree = degree % 360
13
+ return function (bitmap, done, opt = {}) {
14
+
15
+ if (degree == 0) return bitmap
16
+
17
+ if (degree == 90 || degree == 270) {
18
+ var newBitmap = createBitmap(bitmap.pixels.length, bitmap.height, bitmap.width)
19
+ } else if (degree == 180) {
20
+ var newBitmap = createBitmap(bitmap.pixels.length, bitmap.width, bitmap.height)
21
+ } else {
22
+ return rotateDegree(degree)(bitmap, done, opt)
23
+ }
24
+ packXY((pixels, i, x, y) => {
25
+
26
+ if (degree == 90) {
27
+ var endIndex = (x * newBitmap.width + (newBitmap.width -1 - y) ) << 2 // << 2 is equals to (multiply)* 4
28
+ } else if (degree == 270) {
29
+ var endIndex = ( (newBitmap.height -1 -x) * newBitmap.width + y ) << 2
30
+ } else if (degree == 180) {
31
+ var endIndex = ((newBitmap.height -1 -y) * newBitmap.width + (newBitmap.width -1 -x)) << 2
32
+ }
33
+
34
+ fillPixelColor(newBitmap.pixels, endIndex, bitmap.pixels, i)
35
+ })(bitmap, function () {
36
+ done(newBitmap)
37
+ }, opt)
38
+ }
39
+ }
@@ -0,0 +1,53 @@
1
+ import Matrix from '../../Matrix'
2
+ import {
3
+ createBitmap,
4
+ packXY,
5
+ fillPixelColor
6
+ } from '../functions'
7
+
8
+ export default function rotateDegree(angle, cx = 'center', cy = 'center') {
9
+ // const r = F.radian(angle)
10
+
11
+ return function (bitmap, done, opt = {}) {
12
+ var newBitmap = createBitmap(bitmap.pixels.length, bitmap.width, bitmap.height)
13
+ const width = bitmap.width
14
+ const height = bitmap.height
15
+
16
+ if (cx == 'center') {
17
+ cx = Math.floor(width / 2);
18
+ }
19
+
20
+ if (cy == 'center') {
21
+ cy = Math.floor(height/ 2);
22
+ }
23
+
24
+ const translateMatrix = Matrix.CONSTANT.translate(-cx, -cy)
25
+ const translateMatrix2 = Matrix.CONSTANT.translate(cx, cy)
26
+ const shear1Matrix = Matrix.CONSTANT.shear1(angle)
27
+ const shear2Matrix = Matrix.CONSTANT.shear2(angle)
28
+
29
+ packXY((pixels, i, x, y) => {
30
+ // console.log(x, y, i)
31
+ let arr = Matrix.multiply(translateMatrix, [x, y, 1])
32
+
33
+ arr = Matrix.multiply(shear1Matrix, arr).map(Math.round)
34
+ arr = Matrix.multiply(shear2Matrix, arr).map(Math.round)
35
+ arr = Matrix.multiply(shear1Matrix, arr).map(Math.round)
36
+ arr = Matrix.multiply(translateMatrix2, arr)
37
+
38
+ const [x1, y1] = arr
39
+
40
+ if (x1 < 0) return;
41
+ if (y1 < 0) return;
42
+ if (x1 > width-1) return;
43
+ if (y1 > height-1) return;
44
+
45
+ var endIndex = (y1 * width + x1) << 2 // bit 2 shift is * 4
46
+
47
+ fillPixelColor(pixels, endIndex, bitmap.pixels, i)
48
+
49
+ })(newBitmap, function () {
50
+ done(newBitmap)
51
+ }, opt)
52
+ }
53
+ }
@@ -0,0 +1,11 @@
1
+ import image from './image/index'
2
+ import pixel from './pixel/index'
3
+ import matrix from './matrix/index'
4
+ import multi from './multi/index'
5
+
6
+ export default {
7
+ ...image,
8
+ ...pixel,
9
+ ...matrix,
10
+ ...multi
11
+ }
@@ -0,0 +1,12 @@
1
+ import {
2
+ convolution,
3
+ parseParamNumber,
4
+ createBlurMatrix
5
+ } from '../functions'
6
+
7
+ export default function (amount = 3, hasAlphaChannel = true) {
8
+
9
+ amount = parseParamNumber(amount)
10
+
11
+ return convolution(createBlurMatrix(amount))
12
+ }
@@ -0,0 +1,17 @@
1
+ import {
2
+ parseParamNumber,
3
+ convolution
4
+ } from '../functions'
5
+ /*
6
+ * carve, mold, or stamp a design on (a surface) so that it stands out in relief.
7
+ *
8
+ * @param {Number} amount 0.0 .. 4.0
9
+ */
10
+ export default function emboss (amount = 4) {
11
+ amount = parseParamNumber(amount)
12
+ return convolution([
13
+ amount * (-2.0), -amount, 0.0,
14
+ -amount, 1.0, amount,
15
+ 0.0, amount, amount * 2.0,
16
+ ]);
17
+ }
@@ -0,0 +1,17 @@
1
+ import {
2
+ parseParamNumber,
3
+ convolution,
4
+ weight
5
+ } from '../functions'
6
+
7
+ export default function gaussianBlur5x (amount = 100) {
8
+ amount = parseParamNumber(amount)
9
+ const C = amount / 100;
10
+ return convolution(weight([
11
+ 1, 4, 6, 4, 1,
12
+ 4, 16, 24, 16, 4,
13
+ 6, 24, 36, 24, 6,
14
+ 4, 16, 24, 16, 4,
15
+ 1, 4, 6, 4, 1
16
+ ], (1/256) * C ));
17
+ }
@@ -0,0 +1,16 @@
1
+ import {
2
+ parseParamNumber,
3
+ convolution,
4
+ weight
5
+ } from '../functions'
6
+
7
+ export default function gaussianBlur (amount = 100) {
8
+ amount = parseParamNumber(amount)
9
+ const C = amount / 100;
10
+
11
+ return convolution(weight([
12
+ 1, 2, 1,
13
+ 2, 4, 2,
14
+ 1, 2, 1
15
+ ], (1/16) * C ));
16
+ }
@@ -0,0 +1,16 @@
1
+ import {
2
+ parseParamNumber,
3
+ convolution,
4
+ weight
5
+ } from '../functions'
6
+
7
+ export default function grayscale2 (amount = 100) {
8
+ amount = parseParamNumber(amount)
9
+ return convolution(weight([
10
+ 0.3, 0.3, 0.3, 0, 0,
11
+ 0.59, 0.59, 0.59, 0, 0,
12
+ 0.11, 0.11, 0.11, 0, 0,
13
+ 0, 0, 0, 0, 0,
14
+ 0, 0, 0, 0, 0
15
+ ], amount / 100));
16
+ }
@@ -0,0 +1,58 @@
1
+ import blur from './blur'
2
+ import emboss from './emboss'
3
+ import gaussianBlur from './gaussian-blur'
4
+ import gaussianBlur5x from './gaussian-blur-5x'
5
+ import grayscale2 from './grayscale2'
6
+ import normal from './normal'
7
+ import kirschHorizontal from './kirsch-horizontal'
8
+ import kirschVertical from './kirsch-vertical'
9
+ import laplacian from './laplacian'
10
+ import laplacian5x from './laplacian-5x'
11
+ import motionBlur from './motion-blur'
12
+ import motionBlur2 from './motion-blur-2'
13
+ import motionBlur3 from './motion-blur-3'
14
+ import negative from './negative'
15
+ import sepia2 from './sepia2'
16
+ import sharpen from './sharpen'
17
+ import sobelHorizontal from './sobel-horizontal'
18
+ import sobelVertical from './sobel-vertical'
19
+ import stackBlur from './stack-blur'
20
+ import transparency from './transparency'
21
+ import unsharpMasking from './unsharp-masking'
22
+
23
+
24
+ export default {
25
+ blur,
26
+ emboss,
27
+ gaussianBlur,
28
+ 'gaussian-blur': gaussianBlur,
29
+ gaussianBlur5x,
30
+ 'gaussian-blur-5x': gaussianBlur5x,
31
+ grayscale2,
32
+ normal,
33
+ kirschHorizontal,
34
+ 'kirsch-horizontal': kirschHorizontal,
35
+ kirschVertical,
36
+ 'kirsch-vertical': kirschVertical,
37
+ laplacian,
38
+ laplacian5x,
39
+ 'laplacian-5x': laplacian5x,
40
+ motionBlur,
41
+ 'motion-blur': motionBlur,
42
+ motionBlur2,
43
+ 'motion-blur-2': motionBlur2,
44
+ motionBlur3,
45
+ 'motion-blur-3': motionBlur3,
46
+ negative,
47
+ sepia2,
48
+ sharpen,
49
+ sobelHorizontal,
50
+ 'sobel-horizontal': sobelHorizontal,
51
+ sobelVertical,
52
+ 'sobel-vertical': sobelVertical,
53
+ stackBlur,
54
+ 'stack-blur': stackBlur,
55
+ transparency,
56
+ unsharpMasking,
57
+ 'unsharp-masking': unsharpMasking
58
+ }
@@ -0,0 +1,13 @@
1
+ import {
2
+ parseParamNumber,
3
+ convolution
4
+ } from '../functions'
5
+
6
+ export default function kirschHorizontal (count = 1) {
7
+ count = parseParamNumber(count)
8
+ return convolution([
9
+ 5, 5, 5,
10
+ -3, 0, -3,
11
+ -3, -3, -3
12
+ ]);
13
+ }
@@ -0,0 +1,13 @@
1
+ import {
2
+ parseParamNumber,
3
+ convolution
4
+ } from '../functions'
5
+
6
+ export default function kirschVertical (count = 1) {
7
+ count = parseParamNumber(count)
8
+ return convolution([
9
+ 5, -3, -3,
10
+ 5, 0, -3,
11
+ 5, -3, -3
12
+ ]);
13
+ }
@@ -0,0 +1,16 @@
1
+ import {
2
+ parseParamNumber,
3
+ convolution,
4
+ weight
5
+ } from '../functions'
6
+
7
+ export default function laplacian5x (amount = 100) {
8
+ amount = parseParamNumber(amount)
9
+ return convolution(weight([
10
+ -1, -1, -1, -1, -1,
11
+ -1, -1, -1, -1, -1,
12
+ -1, -1, 24, -1, -1,
13
+ -1, -1, -1, -1, -1,
14
+ -1, -1, -1, -1, -1
15
+ ], amount / 100));
16
+ }
@@ -0,0 +1,14 @@
1
+ import {
2
+ parseParamNumber,
3
+ convolution,
4
+ weight
5
+ } from '../functions'
6
+
7
+ export default function laplacian (amount = 100) {
8
+ amount = parseParamNumber(amount)
9
+ return convolution(weight([
10
+ -1, -1, -1,
11
+ -1, 8, -1,
12
+ -1, -1, -1
13
+ ], amount / 100));
14
+ }
@@ -0,0 +1,18 @@
1
+ import {
2
+ convolution,
3
+ weight
4
+ } from '../functions'
5
+
6
+ export default function motionBlur2 () {
7
+ return convolution(weight([
8
+ 1, 0, 0, 0, 0, 0, 0, 0, 1,
9
+ 0, 1, 0, 0, 0, 0, 0, 1, 0,
10
+ 0, 0, 1, 0, 0, 0, 1, 0, 0,
11
+ 0, 0, 0, 1, 0, 1, 0, 0, 0,
12
+ 0, 0, 0, 0, 1, 0, 0, 0, 0,
13
+ 0, 0, 0, 1, 0, 1, 0, 0, 0,
14
+ 0, 0, 1, 0, 0, 0, 1, 0, 0,
15
+ 0, 1, 0, 0, 0, 0, 0, 1, 0,
16
+ 1, 0, 0, 0, 0, 0, 0, 0, 1,
17
+ ], 1 / 9));
18
+ }
@@ -0,0 +1,19 @@
1
+ import {
2
+ convolution,
3
+ weight
4
+ } from '../functions'
5
+
6
+
7
+ export default function motionBlur3 () {
8
+ return convolution(weight([
9
+ 1, 0, 0, 0, 1, 0, 0, 0, 1,
10
+ 0, 1, 0, 0, 1, 0, 0, 1, 0,
11
+ 0, 0, 1, 0, 1, 0, 1, 0, 0,
12
+ 0, 0, 0, 1, 1, 1, 0, 0, 0,
13
+ 1, 1, 1, 1, 1, 1, 1, 1, 1,
14
+ 0, 0, 0, 1, 1, 1, 0, 0, 0,
15
+ 0, 0, 1, 0, 1, 0, 1, 0, 0,
16
+ 0, 1, 0, 0, 1, 0, 0, 1, 0,
17
+ 1, 0, 0, 0, 1, 0, 0, 0, 1,
18
+ ], 1 / 9));
19
+ }
@@ -0,0 +1,18 @@
1
+ import {
2
+ convolution,
3
+ weight
4
+ } from '../functions'
5
+
6
+ export default function motionBlur () {
7
+ return convolution(weight([
8
+ 1, 0, 0, 0, 0, 0, 0, 0, 0,
9
+ 0, 1, 0, 0, 0, 0, 0, 0, 0,
10
+ 0, 0, 1, 0, 0, 0, 0, 0, 0,
11
+ 0, 0, 0, 1, 0, 0, 0, 0, 0,
12
+ 0, 0, 0, 0, 1, 0, 0, 0, 0,
13
+ 0, 0, 0, 0, 0, 1, 0, 0, 0,
14
+ 0, 0, 0, 0, 0, 0, 1, 0, 0,
15
+ 0, 0, 0, 0, 0, 0, 0, 1, 0,
16
+ 0, 0, 0, 0, 0, 0, 0, 0, 1,
17
+ ], 1 / 9));
18
+ }
@@ -0,0 +1,16 @@
1
+ import {
2
+ parseParamNumber,
3
+ convolution,
4
+ weight
5
+ } from '../functions'
6
+
7
+ export default function negative (amount = 100) {
8
+ amount = parseParamNumber(amount)
9
+ return convolution(weight([
10
+ -1, 0, 0, 0, 0,
11
+ 0, -1, 0, 0, 0,
12
+ 0, 0, -1, 0, 0,
13
+ 0, 0, 0, 1, 0,
14
+ 1, 1, 1, 1, 1
15
+ ], amount / 100));
16
+ }
@@ -0,0 +1,11 @@
1
+ import {
2
+ convolution
3
+ } from '../functions'
4
+
5
+ export default function identity () {
6
+ return convolution([
7
+ 0, 0, 0,
8
+ 0, 1, 0,
9
+ 0, 0, 0
10
+ ]);
11
+ }
@@ -0,0 +1,16 @@
1
+ import {
2
+ parseParamNumber,
3
+ convolution,
4
+ weight
5
+ } from '../functions'
6
+
7
+ export default function sepia2 (amount = 100) {
8
+ amount = parseParamNumber(amount)
9
+ return convolution(weight([
10
+ 0.393, 0.349, 0.272, 0, 0,
11
+ 0.769, 0.686, 0.534, 0, 0,
12
+ 0.189, 0.168, 0.131, 0, 0,
13
+ 0, 0, 0, 0, 0,
14
+ 0, 0, 0, 0, 0
15
+ ], amount / 100));
16
+ }
@@ -0,0 +1,14 @@
1
+ import {
2
+ parseParamNumber,
3
+ convolution,
4
+ weight
5
+ } from '../functions'
6
+
7
+ export default function sharpen (amount = 100) {
8
+ amount = parseParamNumber(amount)
9
+ return convolution(weight([
10
+ 0, -1, 0,
11
+ -1, 5, -1,
12
+ 0, -1, 0
13
+ ], amount / 100));
14
+ }
@@ -0,0 +1,11 @@
1
+ import {
2
+ convolution
3
+ } from '../functions'
4
+
5
+ export default function sobelHorizontal () {
6
+ return convolution([
7
+ -1, -2, -1,
8
+ 0, 0, 0,
9
+ 1, 2, 1
10
+ ]);
11
+ }
@@ -0,0 +1,11 @@
1
+ import {
2
+ convolution
3
+ } from '../functions'
4
+
5
+ export default function sobelVertical () {
6
+ return convolution([
7
+ -1, 0, 1,
8
+ -2, 0, 2,
9
+ -1, 0, 1
10
+ ]);
11
+ }
@@ -0,0 +1,15 @@
1
+ import {
2
+ parseParamNumber
3
+ } from '../functions'
4
+
5
+ import StackBlur from '../StackBlur'
6
+
7
+ export default function (radius = 10, hasAlphaChannel = true) {
8
+ radius = parseParamNumber(radius)
9
+
10
+ return function (bitmap, done, opt = {}) {
11
+ let newBitmap = StackBlur(bitmap, radius, hasAlphaChannel )
12
+
13
+ done(newBitmap);
14
+ }
15
+ }
@@ -0,0 +1,16 @@
1
+ import {
2
+ parseParamNumber,
3
+ convolution,
4
+ weight
5
+ } from '../functions'
6
+
7
+ export default function transparency (amount = 100) {
8
+ amount = parseParamNumber(amount)
9
+ return convolution(weight([
10
+ 1, 0, 0, 0, 0,
11
+ 0, 1, 0, 0, 0,
12
+ 0, 0, 1, 0, 0,
13
+ 0, 0, 0, 0.3, 0,
14
+ 0, 0, 0, 0, 1,
15
+ ], amount / 100));
16
+ }
@@ -0,0 +1,16 @@
1
+ import {
2
+ parseParamNumber,
3
+ convolution,
4
+ weight
5
+ } from '../functions'
6
+
7
+ export default function unsharpMasking (amount = 256) {
8
+ amount = parseParamNumber(amount)
9
+ return convolution(weight([
10
+ 1, 4, 6, 4, 1,
11
+ 4, 16, 24, 16, 4,
12
+ 6, 24, -476, 24, 6,
13
+ 4, 16, 24, 16, 4,
14
+ 1, 4, 6, 4, 1
15
+ ], -1 / amount));
16
+ }
@@ -0,0 +1,9 @@
1
+ import kirsch from './kirsch'
2
+ import sobel from './sobel'
3
+ import vintage from './vintage'
4
+
5
+ export default {
6
+ kirsch,
7
+ sobel,
8
+ vintage
9
+ }