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,216 @@
1
+ import Event from '../../util/Event'
2
+ import UIElement from '../UIElement';
3
+
4
+ const source = 'chromedevtool-information';
5
+
6
+ export default class ColorInformation extends UIElement {
7
+
8
+ template () {
9
+ return /*html*/`
10
+ <div class="information hex">
11
+ <div ref="$informationChange" class="information-change">
12
+ <button ref="$formatChangeButton" type="button" class="format-change-button arrow-button"></button>
13
+ </div>
14
+ <div class="information-item hex">
15
+ <div class="input-field hex">
16
+ <input ref="$hexCode" class="input" type="text" />
17
+ <div class="title">HEX</div>
18
+ </div>
19
+ </div>
20
+ <div class="information-item rgb">
21
+ <div class="input-field rgb-r">
22
+ <input ref="$rgb_r" class="input" type="number" step="1" min="0" max="255" />
23
+ <div class="title">R</div>
24
+ </div>
25
+ <div class="input-field rgb-g">
26
+ <input ref="$rgb_g" class="input" type="number" step="1" min="0" max="255" />
27
+ <div class="title">G</div>
28
+ </div>
29
+ <div class="input-field rgb-b">
30
+ <input ref="$rgb_b" class="input" type="number" step="1" min="0" max="255" />
31
+ <div class="title">B</div>
32
+ </div>
33
+ <div class="input-field rgb-a">
34
+ <input ref="$rgb_a" class="input" type="number" step="0.01" min="0" max="1" />
35
+ <div class="title">A</div>
36
+ </div>
37
+ </div>
38
+ <div class="information-item hsl">
39
+ <div class="input-field hsl-h">
40
+ <input ref="$hsl_h" class="input" type="number" step="1" min="0" max="360" />
41
+ <div class="title">H</div>
42
+ </div>
43
+ <div class="input-field hsl-s">
44
+ <input ref="$hsl_s" class="input" type="number" step="1" min="0" max="100" />
45
+ <div class="postfix">%</div>
46
+ <div class="title">S</div>
47
+ </div>
48
+ <div class="input-field hsl-l">
49
+ <input ref="$hsl_l" class="input" type="number" step="1" min="0" max="100" />
50
+ <div class="postfix">%</div>
51
+ <div class="title">L</div>
52
+ </div>
53
+ <div class="input-field hsl-a">
54
+ <input ref="$hsl_a" class="input" type="number" step="0.01" min="0" max="1" />
55
+ <div class="title">A</div>
56
+ </div>
57
+ </div>
58
+ </div>
59
+ `
60
+ }
61
+
62
+ setCurrentFormat (format) {
63
+ this.format = format
64
+
65
+ this.initFormat();
66
+ }
67
+
68
+ initFormat () {
69
+ var current_format = this.format || 'hex';
70
+
71
+ ['hex', 'rgb', 'hsl'].filter(it => it !== current_format).forEach(formatString => {
72
+ this.$el.removeClass(formatString);
73
+ })
74
+
75
+ this.$el.addClass(current_format);
76
+ }
77
+
78
+
79
+ nextFormat() {
80
+ var current_format = this.$store.format || 'hex';
81
+
82
+ var next_format = 'hex';
83
+ if (current_format == 'hex') {
84
+ next_format = 'rgb';
85
+ } else if (current_format == 'rgb') {
86
+ next_format = 'hsl';
87
+ } else if (current_format == 'hsl') {
88
+ next_format = 'hex';
89
+ }
90
+
91
+ this.format = next_format;
92
+ this.$store.dispatch('/changeFormat', next_format);
93
+ this.$store.emit('lastUpdateColor')
94
+ this.initFormat();
95
+ }
96
+
97
+ goToFormat(to_format) {
98
+ this.format = to_format;
99
+ this.$store.dispatch('/changeFormat', this.format);
100
+ this.$store.emit('lastUpdateColor')
101
+ this.initFormat();
102
+ }
103
+
104
+ getFormat () {
105
+ return this.format || 'hex';
106
+ }
107
+
108
+ checkNumberKey(e) {
109
+ var code = e.which,
110
+ isExcept = false;
111
+
112
+ if(code == 37 || code == 39 || code == 8 || code == 46 || code == 9)
113
+ isExcept = true;
114
+
115
+ if(!isExcept && (code < 48 || code > 57))
116
+ return false;
117
+
118
+ return true;
119
+ }
120
+
121
+ checkNotNumberKey(e) {
122
+ return !this.checkNumberKey(e);
123
+ }
124
+
125
+ changeRgbColor () {
126
+ this.$store.dispatch('/changeColor', {
127
+ type: 'rgb',
128
+ r : this.refs.$rgb_r.int(),
129
+ g : this.refs.$rgb_g.int(),
130
+ b : this.refs.$rgb_b.int(),
131
+ a : this.refs.$rgb_a.float(),
132
+ source
133
+ })
134
+ this.$store.emit('lastUpdateColor')
135
+ }
136
+
137
+ changeHslColor () {
138
+ this.$store.dispatch('/changeColor', {
139
+ type: 'hsl',
140
+ h : this.refs.$hsl_h.int(),
141
+ s : this.refs.$hsl_s.int(),
142
+ l : this.refs.$hsl_l.int(),
143
+ a : this.refs.$hsl_a.float(),
144
+ source
145
+ })
146
+ this.$store.emit('lastUpdateColor')
147
+ }
148
+
149
+ '@changeColor' (sourceType) {
150
+ if (source != sourceType) {
151
+ this.refresh()
152
+ }
153
+ }
154
+
155
+ '@initColor' () { this.refresh() }
156
+
157
+ 'input $rgb_r' (e) { this.changeRgbColor(); }
158
+ 'input $rgb_g' (e) { this.changeRgbColor(); }
159
+ 'input $rgb_b' (e) { this.changeRgbColor(); }
160
+ 'input $rgb_a' (e) { this.changeRgbColor(); }
161
+
162
+ 'input $hsl_h' (e) { this.changeHslColor(); }
163
+ 'input $hsl_s' (e) { this.changeHslColor(); }
164
+ 'input $hsl_l' (e) { this.changeHslColor(); }
165
+ 'input $hsl_a' (e) { this.changeHslColor(); }
166
+
167
+ 'keyup $hexCode' (e) {
168
+ var code = this.refs.$hexCode.val();
169
+
170
+ if(code.charAt(0) == '#' && (code.length == 7 || code.length === 9)) {
171
+ this.$store.dispatch('/changeColor', code, source)
172
+ this.$store.emit('lastUpdateColor')
173
+ }
174
+ }
175
+
176
+ 'click $formatChangeButton' (e) {
177
+ this.nextFormat();
178
+ }
179
+
180
+ 'click $el .information-item.hex .input-field .title' (e) {
181
+ this.goToFormat('rgb');
182
+ }
183
+
184
+ 'click $el .information-item.rgb .input-field .title' (e) {
185
+ this.goToFormat('hsl');
186
+ }
187
+
188
+ 'click $el .information-item.hsl .input-field .title' (e) {
189
+ this.goToFormat('hex');
190
+ }
191
+
192
+ setRGBInput() {
193
+ this.refs.$rgb_r.val(this.$store.rgb.r);
194
+ this.refs.$rgb_g.val(this.$store.rgb.g);
195
+ this.refs.$rgb_b.val(this.$store.rgb.b);
196
+ this.refs.$rgb_a.val(this.$store.alpha);
197
+ }
198
+
199
+ setHSLInput() {
200
+ this.refs.$hsl_h.val(this.$store.hsl.h);
201
+ this.refs.$hsl_s.val(this.$store.hsl.s);
202
+ this.refs.$hsl_l.val(this.$store.hsl.l);
203
+ this.refs.$hsl_a.val(this.$store.alpha);
204
+ }
205
+
206
+ setHexInput () {
207
+ this.refs.$hexCode.val(this.$store.dispatch('/toHEX'));
208
+ }
209
+
210
+ refresh () {
211
+ this.setCurrentFormat(this.$store.format);
212
+ this.setRGBInput();
213
+ this.setHSLInput();
214
+ this.setHexInput();
215
+ }
216
+ }
@@ -0,0 +1,130 @@
1
+ import UIElement from '../UIElement';
2
+ import Event from '../../util/Event'
3
+
4
+ const source = 'chromedevtool-palette';
5
+
6
+ export default class ColorPalette extends UIElement {
7
+
8
+ template () {
9
+ return `
10
+ <div class="color">
11
+ <div ref="$saturation" class="saturation">
12
+ <div ref="$value" class="value">
13
+ <div ref="$drag_pointer" class="drag-pointer"></div>
14
+ </div>
15
+ </div>
16
+ </div>
17
+ `
18
+ }
19
+
20
+ setBackgroundColor (color) {
21
+ this.$el.css("background-color", color);
22
+ }
23
+
24
+ refresh () {
25
+ this.setColorUI();
26
+ }
27
+
28
+ caculateSV () {
29
+ var pos = this.drag_pointer_pos || { x : 0, y : 0 };
30
+
31
+ var width = this.state.get('$el.width');
32
+ var height = this.state.get('$el.height');
33
+
34
+ var s = (pos.x / width);
35
+ var v = ((height - pos.y) / height);
36
+
37
+ this.$store.dispatch('/changeColor', {
38
+ type: 'hsv',
39
+ s,
40
+ v,
41
+ source
42
+ })
43
+ }
44
+
45
+ setColorUI() {
46
+ var x = this.state.get('$el.width') * this.$store.hsv.s,
47
+ y = this.state.get('$el.height') * ( 1 - this.$store.hsv.v );
48
+
49
+ this.refs.$drag_pointer.css({
50
+ left : x + "px",
51
+ top : y + "px"
52
+ });
53
+
54
+ this.drag_pointer_pos = { x , y };
55
+
56
+ this.setBackgroundColor(this.$store.dispatch('/getHueColor'))
57
+ }
58
+
59
+
60
+ setMainColor(e) {
61
+ // e.preventDefault();
62
+ var pos = this.$el.offset(); // position for screen
63
+ var w = this.state.get('$el.contentWidth');
64
+ var h = this.state.get('$el.contentHeight');
65
+
66
+ var x = Event.pos(e).pageX - pos.left;
67
+ var y = Event.pos(e).pageY - pos.top;
68
+
69
+ if (x < 0) x = 0;
70
+ else if (x > w) x = w;
71
+
72
+ if (y < 0) y = 0;
73
+ else if (y > h) y = h;
74
+
75
+ this.refs.$drag_pointer.css({
76
+ left: x + 'px',
77
+ top: y + 'px'
78
+ });
79
+
80
+ this.drag_pointer_pos = { x , y }
81
+
82
+ this.caculateSV()
83
+ }
84
+
85
+ '@changeColor' (sourceType) {
86
+ if (source != sourceType) {
87
+ this.refresh()
88
+ }
89
+ }
90
+
91
+ '@initColor' () { this.refresh() }
92
+
93
+ 'mouseup document' (e) {
94
+ if (this.isDown) {
95
+ this.isDown = false;
96
+ this.$store.emit('lastUpdateColor');
97
+ }
98
+ }
99
+
100
+ 'mousemove document' (e) {
101
+ if (this.isDown) {
102
+ this.setMainColor(e);
103
+ }
104
+ }
105
+
106
+ mousedown (e) {
107
+ this.isDown = true;
108
+ this.setMainColor(e);
109
+ }
110
+
111
+ 'touchend document' (e) {
112
+ if (this.isDown) {
113
+ this.isDown = false;
114
+ this.$store.emit('lastUpdateColor');
115
+ }
116
+ }
117
+
118
+ 'touchmove document' (e) {
119
+ if (this.isDown) {
120
+ this.setMainColor(e);
121
+ }
122
+ }
123
+
124
+ touchstart (e) {
125
+ e.preventDefault()
126
+ this.isDown = true;
127
+ this.setMainColor(e);
128
+ }
129
+
130
+ }
@@ -0,0 +1,68 @@
1
+ import ColorWheel from './ColorWheel';
2
+ import { caculateAngle } from '../../util/functions/math';
3
+
4
+ export default class ColorRing extends ColorWheel {
5
+
6
+ constructor (opt) {
7
+ super(opt)
8
+
9
+ this.width = 214;
10
+ this.height = 214;
11
+ this.thinkness = 16;
12
+ this.half_thinkness = this.thinkness / 2
13
+ this.source = 'colorring'
14
+ }
15
+
16
+ template () {
17
+ return `
18
+ <div class="wheel" data-type="ring">
19
+ <canvas class="wheel-canvas" ref="$colorwheel" ></canvas>
20
+ <div class="drag-pointer" ref="$drag_pointer"></div>
21
+ </div>
22
+ `
23
+ }
24
+
25
+ setColorUI(isEvent) {
26
+ this.renderCanvas();
27
+ this.setHueColor(null, isEvent);
28
+ }
29
+
30
+ getDefaultValue () {
31
+ return this.$store.hsv.h
32
+ }
33
+
34
+ setHueColor (e, isEvent) {
35
+
36
+ if (!this.state.get('$el.width')) return;
37
+
38
+ var { minX, minY, radius, centerX, centerY } = this.getRectangle()
39
+ var { x , y } = this.getCurrentXY(
40
+ e,
41
+ this.getDefaultValue(),
42
+ radius,
43
+ centerX,
44
+ centerY
45
+ )
46
+
47
+ var rx = x - centerX, ry = y - centerY, hue = caculateAngle(rx, ry);
48
+
49
+ {
50
+ var { x, y } = this.getCurrentXY(null, hue, radius - this.half_thinkness, centerX, centerY);
51
+ }
52
+
53
+
54
+ // set drag pointer position
55
+ this.refs.$drag_pointer.css({
56
+ left: (x - minX) + 'px',
57
+ top: (y - minY) + 'px'
58
+ });
59
+
60
+ if (!isEvent) {
61
+ this.changeColor({
62
+ type: 'hsv',
63
+ h: hue
64
+ })
65
+ }
66
+ }
67
+ }
68
+
@@ -0,0 +1,96 @@
1
+ import UIElement from '../UIElement';
2
+
3
+ const DATA_COLORSETS_INDEX = 'data-colorsets-index';
4
+
5
+ export default class ColorSetsChooser extends UIElement {
6
+
7
+ template () {
8
+ return `
9
+ <div class="color-chooser">
10
+ <div class="color-chooser-container">
11
+ <div class="colorsets-item colorsets-item-header">
12
+ <h1 class="title">Color Palettes</h1>
13
+ <span ref="$toggleButton" class="items">&times;</span>
14
+ </div>
15
+ <div ref="$colorsetsList" class="colorsets-list"></div>
16
+ </div>
17
+ </div>
18
+ `
19
+ }
20
+
21
+ refresh () {
22
+ this.load();
23
+ }
24
+
25
+ '@changeCurrentColorSets' () {
26
+ this.refresh()
27
+ }
28
+
29
+ '@toggleColorChooser' () {
30
+ this.toggle()
31
+ }
32
+
33
+ // loadable
34
+ 'load $colorsetsList' () {
35
+ // colorsets
36
+ const colorSets = this.$store.dispatch('/getColorSetsList');
37
+
38
+ return `
39
+ <div>
40
+ ${colorSets.map( (element, index) => {
41
+ return `
42
+ <div class="colorsets-item" data-colorsets-index="${index}" >
43
+ <h1 class="title">${element.name}</h1>
44
+ <div class="items">
45
+ <div>
46
+ ${element.colors.filter((color, i) => i < 5).map(color => {
47
+ color = color || 'rgba(255, 255, 255, 1)';
48
+ return `<div class="color-item" title="${color}">
49
+ <div class="color-view" style="background-color: ${color}"></div>
50
+ </div>`
51
+ }).join('')}
52
+ </div>
53
+ </div>
54
+ </div>`
55
+ }).join('')}
56
+ </div>
57
+ `
58
+ }
59
+
60
+ show () {
61
+ this.$el.addClass('open');
62
+ }
63
+
64
+ hide () {
65
+ this.$el.removeClass('open');
66
+ }
67
+
68
+ toggle () {
69
+ this.$el.toggleClass('open');
70
+ }
71
+
72
+
73
+ 'click $toggleButton' (e) {
74
+ this.toggle();
75
+ }
76
+
77
+ 'click $colorsetsList .colorsets-item' (e) {
78
+ const $item = e.$delegateTarget;
79
+
80
+ if ($item) {
81
+
82
+ const index = parseInt($item.attr(DATA_COLORSETS_INDEX));
83
+
84
+ this.$store.dispatch('/setCurrentColorSets', index);
85
+
86
+ this.hide();
87
+ }
88
+ }
89
+
90
+ destroy () {
91
+ super.destroy();
92
+
93
+ this.hide();
94
+ }
95
+
96
+ }