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.
- package/.babelrc +30 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +35 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- package/ChangeLogs.md +22 -0
- package/LICENSE +21 -0
- package/README.md +117 -0
- package/addon/ace-colorpicker.css +1074 -0
- package/addon/ace-colorpicker.js +9602 -0
- package/addon/sample/colorpicker.html +199 -0
- package/config/rollup.config.dev.js +52 -0
- package/config/rollup.config.prod.js +53 -0
- package/dist/ace-colorpicker.css +1074 -0
- package/dist/ace-colorpicker.js +9736 -0
- package/dist/ace-colorpicker.min.js +1 -0
- package/gl.html +56 -0
- package/index.html +172 -0
- package/package.json +87 -0
- package/resources/image/ace-editor.png +0 -0
- package/resources/image/colorpaletts.png +0 -0
- package/resources/image/colorpicker.png +0 -0
- package/resources/image/grapes.jpg +0 -0
- package/resources/image/palette-type.png +0 -0
- package/resources/image/scalecolors-title.png +0 -0
- package/resources/image/scalecolors.png +0 -0
- package/resources/image/screen-shot.png +0 -0
- package/resources/image/sketch-type.png +0 -0
- package/src/colorpicker/BaseBox.js +94 -0
- package/src/colorpicker/BaseColorPicker.js +404 -0
- package/src/colorpicker/BaseModule.js +19 -0
- package/src/colorpicker/BaseSlider.js +97 -0
- package/src/colorpicker/BaseStore.js +71 -0
- package/src/colorpicker/UIElement.js +46 -0
- package/src/colorpicker/VerticalSlider.js +57 -0
- package/src/colorpicker/chromedevtool/ColorControl.js +47 -0
- package/src/colorpicker/chromedevtool/index.js +36 -0
- package/src/colorpicker/index.js +37 -0
- package/src/colorpicker/macos/ColorControl.js +47 -0
- package/src/colorpicker/macos/index.js +38 -0
- package/src/colorpicker/mini/ColorControl.js +40 -0
- package/src/colorpicker/mini/index.js +24 -0
- package/src/colorpicker/mini-vertical/ColorControl.js +35 -0
- package/src/colorpicker/mini-vertical/index.js +23 -0
- package/src/colorpicker/module/ColorManager.js +111 -0
- package/src/colorpicker/module/ColorSetsList.js +132 -0
- package/src/colorpicker/ring/ColorControl.js +47 -0
- package/src/colorpicker/ring/index.js +42 -0
- package/src/colorpicker/ui/ColorInformation.js +216 -0
- package/src/colorpicker/ui/ColorPalette.js +130 -0
- package/src/colorpicker/ui/ColorRing.js +68 -0
- package/src/colorpicker/ui/ColorSetsChooser.js +96 -0
- package/src/colorpicker/ui/ColorWheel.js +257 -0
- package/src/colorpicker/ui/CurrentColorSets.js +81 -0
- package/src/colorpicker/ui/CurrentColorSetsContextMenu.js +63 -0
- package/src/colorpicker/ui/control/Hue.js +40 -0
- package/src/colorpicker/ui/control/Opacity.js +65 -0
- package/src/colorpicker/ui/control/Value.js +50 -0
- package/src/colorpicker/ui/control/VerticalHue.js +39 -0
- package/src/colorpicker/ui/control/VerticalOpacity.js +55 -0
- package/src/colorpicker/vscode/ColorControl.js +40 -0
- package/src/colorpicker/vscode/index.js +82 -0
- package/src/colorpicker/xd/ColorControl.js +36 -0
- package/src/colorpicker/xd/index.js +36 -0
- package/src/extension/ace/colorview.js +198 -0
- package/src/extension/ace/index.js +11 -0
- package/src/index.js +12 -0
- package/src/scss/colorpicker.scss +65 -0
- package/src/scss/colorview.scss +32 -0
- package/src/scss/component/button.scss +33 -0
- package/src/scss/component/colorchooser.scss +141 -0
- package/src/scss/component/colorsets-contextmenu.scss +33 -0
- package/src/scss/component/colorsets.scss +89 -0
- package/src/scss/component/control.scss +93 -0
- package/src/scss/component/gradient-editor.scss +260 -0
- package/src/scss/component/gradient-picker.scss +241 -0
- package/src/scss/component/information.scss +141 -0
- package/src/scss/component/palette.scss +45 -0
- package/src/scss/index.scss +5 -0
- package/src/scss/mixins.scss +21 -0
- package/src/scss/themes/macos.scss +71 -0
- package/src/scss/themes/mini-vertical.scss +94 -0
- package/src/scss/themes/mini.scss +76 -0
- package/src/scss/themes/palette.scss +85 -0
- package/src/scss/themes/ring.scss +57 -0
- package/src/scss/themes/sketch.scss +172 -0
- package/src/scss/themes/vscode.scss +93 -0
- package/src/scss/themes/xd.scss +88 -0
- package/src/util/Blender.js +29 -0
- package/src/util/Canvas.js +128 -0
- package/src/util/Color.js +27 -0
- package/src/util/ColorNames.js +14 -0
- package/src/util/Dom.js +361 -0
- package/src/util/Event.js +30 -0
- package/src/util/EventMachin.js +349 -0
- package/src/util/GL.js +8 -0
- package/src/util/HueColor.js +49 -0
- package/src/util/ImageFilter.js +9 -0
- package/src/util/ImageLoader.js +137 -0
- package/src/util/Kmeans.js +237 -0
- package/src/util/Matrix.js +196 -0
- package/src/util/State.js +42 -0
- package/src/util/blend/composite.js +124 -0
- package/src/util/blend/non-separable.js +118 -0
- package/src/util/blend/separable.js +76 -0
- package/src/util/filter/StackBlur.js +517 -0
- package/src/util/filter/functions.js +829 -0
- package/src/util/filter/image/crop.js +16 -0
- package/src/util/filter/image/flipH.js +23 -0
- package/src/util/filter/image/flipV.js +25 -0
- package/src/util/filter/image/histogram.js +45 -0
- package/src/util/filter/image/index.js +18 -0
- package/src/util/filter/image/resize.js +18 -0
- package/src/util/filter/image/rotate.js +39 -0
- package/src/util/filter/image/rotateDegree.js +53 -0
- package/src/util/filter/index.js +11 -0
- package/src/util/filter/matrix/blur.js +12 -0
- package/src/util/filter/matrix/emboss.js +17 -0
- package/src/util/filter/matrix/gaussian-blur-5x.js +17 -0
- package/src/util/filter/matrix/gaussian-blur.js +16 -0
- package/src/util/filter/matrix/grayscale2.js +16 -0
- package/src/util/filter/matrix/index.js +58 -0
- package/src/util/filter/matrix/kirsch-horizontal.js +13 -0
- package/src/util/filter/matrix/kirsch-vertical.js +13 -0
- package/src/util/filter/matrix/laplacian-5x.js +16 -0
- package/src/util/filter/matrix/laplacian.js +14 -0
- package/src/util/filter/matrix/motion-blur-2.js +18 -0
- package/src/util/filter/matrix/motion-blur-3.js +19 -0
- package/src/util/filter/matrix/motion-blur.js +18 -0
- package/src/util/filter/matrix/negative.js +16 -0
- package/src/util/filter/matrix/normal.js +11 -0
- package/src/util/filter/matrix/sepia2.js +16 -0
- package/src/util/filter/matrix/sharpen.js +14 -0
- package/src/util/filter/matrix/sobel-horizontal.js +11 -0
- package/src/util/filter/matrix/sobel-vertical.js +11 -0
- package/src/util/filter/matrix/stack-blur.js +15 -0
- package/src/util/filter/matrix/transparency.js +16 -0
- package/src/util/filter/matrix/unsharp-masking.js +16 -0
- package/src/util/filter/multi/index.js +9 -0
- package/src/util/filter/multi/kirsch.js +7 -0
- package/src/util/filter/multi/sobel.js +7 -0
- package/src/util/filter/multi/vintage.js +7 -0
- package/src/util/filter/pixel/bitonal.js +24 -0
- package/src/util/filter/pixel/brightness.js +19 -0
- package/src/util/filter/pixel/brownie.js +23 -0
- package/src/util/filter/pixel/clip.js +21 -0
- package/src/util/filter/pixel/contrast.js +18 -0
- package/src/util/filter/pixel/gamma.js +13 -0
- package/src/util/filter/pixel/gradient.js +52 -0
- package/src/util/filter/pixel/grayscale.js +27 -0
- package/src/util/filter/pixel/hue.js +28 -0
- package/src/util/filter/pixel/index.js +52 -0
- package/src/util/filter/pixel/invert.js +16 -0
- package/src/util/filter/pixel/kodachrome.js +23 -0
- package/src/util/filter/pixel/matrix.js +28 -0
- package/src/util/filter/pixel/noise.js +24 -0
- package/src/util/filter/pixel/opacity.js +14 -0
- package/src/util/filter/pixel/polaroid.js +23 -0
- package/src/util/filter/pixel/saturation.js +30 -0
- package/src/util/filter/pixel/sepia.js +28 -0
- package/src/util/filter/pixel/shade.js +21 -0
- package/src/util/filter/pixel/shift.js +23 -0
- package/src/util/filter/pixel/solarize.js +23 -0
- package/src/util/filter/pixel/technicolor.js +23 -0
- package/src/util/filter/pixel/threshold-color.js +35 -0
- package/src/util/filter/pixel/threshold.js +7 -0
- package/src/util/filter/pixel/tint.js +20 -0
- package/src/util/functions/formatter.js +99 -0
- package/src/util/functions/fromCMYK.js +17 -0
- package/src/util/functions/fromHSL.js +52 -0
- package/src/util/functions/fromHSV.js +64 -0
- package/src/util/functions/fromLAB.js +99 -0
- package/src/util/functions/fromRGB.js +220 -0
- package/src/util/functions/fromYCrCb.js +16 -0
- package/src/util/functions/func.js +194 -0
- package/src/util/functions/image.js +145 -0
- package/src/util/functions/math.js +56 -0
- package/src/util/functions/mixin.js +164 -0
- package/src/util/functions/parser.js +294 -0
- package/src/util/gl/filter/index.js +9 -0
- package/src/util/gl/filter/matrix/blur.js +9 -0
- package/src/util/gl/filter/matrix/emboss.js +17 -0
- package/src/util/gl/filter/matrix/gaussian-blur-5x.js +15 -0
- package/src/util/gl/filter/matrix/gaussian-blur.js +19 -0
- package/src/util/gl/filter/matrix/grayscale2.js +13 -0
- package/src/util/gl/filter/matrix/index.js +55 -0
- package/src/util/gl/filter/matrix/kirsch-horizontal.js +11 -0
- package/src/util/gl/filter/matrix/kirsch-vertical.js +11 -0
- package/src/util/gl/filter/matrix/laplacian-5x.js +13 -0
- package/src/util/gl/filter/matrix/laplacian.js +11 -0
- package/src/util/gl/filter/matrix/motion-blur-2.js +17 -0
- package/src/util/gl/filter/matrix/motion-blur-3.js +17 -0
- package/src/util/gl/filter/matrix/motion-blur.js +17 -0
- package/src/util/gl/filter/matrix/negative.js +13 -0
- package/src/util/gl/filter/matrix/normal.js +8 -0
- package/src/util/gl/filter/matrix/sepia2.js +13 -0
- package/src/util/gl/filter/matrix/sharpen.js +11 -0
- package/src/util/gl/filter/matrix/sobel-horizontal.js +11 -0
- package/src/util/gl/filter/matrix/sobel-vertical.js +11 -0
- package/src/util/gl/filter/matrix/transparency.js +13 -0
- package/src/util/gl/filter/matrix/unsharp-masking.js +14 -0
- package/src/util/gl/filter/multi/index.js +9 -0
- package/src/util/gl/filter/multi/kirsch.js +7 -0
- package/src/util/gl/filter/multi/sobel.js +7 -0
- package/src/util/gl/filter/multi/vintage.js +7 -0
- package/src/util/gl/filter/pixel/bitonal.js +22 -0
- package/src/util/gl/filter/pixel/brightness.js +14 -0
- package/src/util/gl/filter/pixel/brownie.js +11 -0
- package/src/util/gl/filter/pixel/chaos.js +20 -0
- package/src/util/gl/filter/pixel/clip.js +20 -0
- package/src/util/gl/filter/pixel/contrast.js +16 -0
- package/src/util/gl/filter/pixel/gamma.js +16 -0
- package/src/util/gl/filter/pixel/gradient.js +59 -0
- package/src/util/gl/filter/pixel/grayscale.js +22 -0
- package/src/util/gl/filter/pixel/hue.js +19 -0
- package/src/util/gl/filter/pixel/index.js +54 -0
- package/src/util/gl/filter/pixel/invert.js +18 -0
- package/src/util/gl/filter/pixel/kodachrome.js +11 -0
- package/src/util/gl/filter/pixel/matrix.js +29 -0
- package/src/util/gl/filter/pixel/noise.js +18 -0
- package/src/util/gl/filter/pixel/opacity.js +17 -0
- package/src/util/gl/filter/pixel/polaroid.js +11 -0
- package/src/util/gl/filter/pixel/saturation.js +20 -0
- package/src/util/gl/filter/pixel/sepia.js +19 -0
- package/src/util/gl/filter/pixel/shade.js +20 -0
- package/src/util/gl/filter/pixel/shift.js +11 -0
- package/src/util/gl/filter/pixel/solarize.js +21 -0
- package/src/util/gl/filter/pixel/technicolor.js +11 -0
- package/src/util/gl/filter/pixel/threshold-color.js +15 -0
- package/src/util/gl/filter/pixel/threshold.js +7 -0
- package/src/util/gl/filter/pixel/tint.js +25 -0
- package/src/util/gl/filter/util.js +185 -0
- package/src/util/gl/functions.js +158 -0
- package/src/util/gl/index.js +543 -0
- package/src/util/index.js +17 -0
- package/stand.html +975 -0
- package/test/util.Blend.spec.js +15 -0
- package/test/util.Color.spec.js +200 -0
- package/test/util.Filter.spec.js +12 -0
- package/test/util.ImageFilter.spec.js +16 -0
@@ -0,0 +1,257 @@
|
|
1
|
+
|
2
|
+
import Color from '../../util/Color'
|
3
|
+
import Dom from '../../util/Dom'
|
4
|
+
import Event from '../../util/Event'
|
5
|
+
import UIElement from '../UIElement';
|
6
|
+
import { getXYInCircle, caculateAngle } from '../../util/functions/math';
|
7
|
+
|
8
|
+
export default class ColorWheel extends UIElement {
|
9
|
+
|
10
|
+
constructor (opt) {
|
11
|
+
super(opt)
|
12
|
+
|
13
|
+
this.width = 214;
|
14
|
+
this.height = 214;
|
15
|
+
this.thinkness = 0;
|
16
|
+
this.half_thinkness = 0
|
17
|
+
this.source = 'colorwheel'
|
18
|
+
}
|
19
|
+
|
20
|
+
template () {
|
21
|
+
return `
|
22
|
+
<div class="wheel">
|
23
|
+
<canvas class="wheel-canvas" ref="$colorwheel" ></canvas>
|
24
|
+
<div class="wheel-canvas" ref="$valuewheel" ></div>
|
25
|
+
<div class="drag-pointer" ref="$drag_pointer"></div>
|
26
|
+
</div>
|
27
|
+
`
|
28
|
+
}
|
29
|
+
|
30
|
+
refresh (isEvent) {
|
31
|
+
this.setColorUI(isEvent);
|
32
|
+
}
|
33
|
+
|
34
|
+
setColorUI(isEvent) {
|
35
|
+
this.renderCanvas();
|
36
|
+
this.renderValue()
|
37
|
+
this.setHueColor(null, isEvent);
|
38
|
+
}
|
39
|
+
|
40
|
+
|
41
|
+
renderValue () {
|
42
|
+
var value = (1 - (this.$store.hsv.v) );
|
43
|
+
this.refs.$valuewheel.css({
|
44
|
+
'background-color': `rgba(0, 0, 0, ${value})`
|
45
|
+
})
|
46
|
+
}
|
47
|
+
|
48
|
+
|
49
|
+
renderWheel (width, height) {
|
50
|
+
|
51
|
+
|
52
|
+
if (this.width && !width) width = this.width;
|
53
|
+
if (this.height && !height) height = this.height;
|
54
|
+
|
55
|
+
const $canvas = new Dom('canvas');
|
56
|
+
const context = $canvas.el.getContext('2d')
|
57
|
+
$canvas.el.width = width;
|
58
|
+
$canvas.el.height = height;
|
59
|
+
$canvas.css({ width: width + 'px', height: height + 'px' })
|
60
|
+
|
61
|
+
var img = context.getImageData(0, 0, width, height);
|
62
|
+
var pixels = img.data;
|
63
|
+
var half_width = Math.floor(width/2)
|
64
|
+
var half_height = Math.floor(height/2)
|
65
|
+
|
66
|
+
var radius = (width > height) ? half_height : half_width;
|
67
|
+
var cx = half_width;
|
68
|
+
var cy = half_height;
|
69
|
+
|
70
|
+
for(var y = 0; y < height; y++) {
|
71
|
+
for (var x = 0; x < width; x++) {
|
72
|
+
var rx = x - cx + 1,
|
73
|
+
ry = y - cy + 1,
|
74
|
+
d = rx * rx + ry * ry,
|
75
|
+
hue = caculateAngle(rx, ry);
|
76
|
+
|
77
|
+
var rgb = Color.HSVtoRGB(
|
78
|
+
hue, // 0~360 hue
|
79
|
+
Math.min(Math.sqrt(d) / radius, 1), // 0..1 Saturation
|
80
|
+
1 // 0..1 Value
|
81
|
+
);
|
82
|
+
|
83
|
+
var index = (y * width + x) * 4;
|
84
|
+
pixels[index] = rgb.r;
|
85
|
+
pixels[index + 1] = rgb.g;
|
86
|
+
pixels[index + 2] = rgb.b;
|
87
|
+
pixels[index + 3] = 255;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
context.putImageData(img,0, 0)
|
92
|
+
|
93
|
+
if (this.thinkness > 0) {
|
94
|
+
context.globalCompositeOperation = "destination-out" // destination-out 은 그리는 영역이 지워진다.
|
95
|
+
context.fillStyle = 'black'
|
96
|
+
context.beginPath();
|
97
|
+
context.arc(cx, cy, radius - this.thinkness, 0, Math.PI * 2);
|
98
|
+
context.closePath();
|
99
|
+
context.fill()
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
return $canvas;
|
104
|
+
}
|
105
|
+
|
106
|
+
renderCanvas () {
|
107
|
+
|
108
|
+
// only once rendering
|
109
|
+
if (this.$store.createdWheelCanvas) return;
|
110
|
+
|
111
|
+
const $canvas = this.refs.$colorwheel
|
112
|
+
// console.log($canvas);
|
113
|
+
const context = $canvas.el.getContext('2d')
|
114
|
+
|
115
|
+
let [width, height] = $canvas.size()
|
116
|
+
|
117
|
+
if (this.width && !width) width = this.width;
|
118
|
+
if (this.height && !height) height = this.height;
|
119
|
+
|
120
|
+
$canvas.el.width = width;
|
121
|
+
$canvas.el.height = height;
|
122
|
+
$canvas.css({ width: width + 'px', height: height + 'px' })
|
123
|
+
|
124
|
+
var $wheelCanvas = this.renderWheel(width, height)
|
125
|
+
|
126
|
+
context.drawImage($wheelCanvas.el, 0, 0)
|
127
|
+
|
128
|
+
this.$store.createdWheelCanvas = true;
|
129
|
+
}
|
130
|
+
|
131
|
+
getDefaultValue () {
|
132
|
+
return this.$store.hsv.h
|
133
|
+
}
|
134
|
+
|
135
|
+
getDefaultSaturation () {
|
136
|
+
return this.$store.hsv.s
|
137
|
+
}
|
138
|
+
|
139
|
+
getCurrentXY(e, angle, radius, centerX, centerY) {
|
140
|
+
return e ? Event.posXY(e) : getXYInCircle(angle, radius, centerX, centerY)
|
141
|
+
}
|
142
|
+
|
143
|
+
getRectangle () {
|
144
|
+
var width = this.state.get('$el.width');
|
145
|
+
var height = this.state.get('$el.height');
|
146
|
+
var radius = this.state.get('$colorwheel.width') / 2;
|
147
|
+
|
148
|
+
var minX = this.refs.$el.offset().left;
|
149
|
+
var centerX = minX + width / 2;
|
150
|
+
|
151
|
+
var minY = this.refs.$el.offset().top;
|
152
|
+
var centerY = minY + height / 2;
|
153
|
+
|
154
|
+
return { minX, minY, width, height, radius, centerX, centerY }
|
155
|
+
}
|
156
|
+
|
157
|
+
setHueColor (e, isEvent) {
|
158
|
+
|
159
|
+
if (!this.state.get('$el.width')) return;
|
160
|
+
|
161
|
+
var { minX, minY, radius, centerX, centerY } = this.getRectangle()
|
162
|
+
|
163
|
+
var { x , y } = this.getCurrentXY(
|
164
|
+
e,
|
165
|
+
this.getDefaultValue(),
|
166
|
+
this.getDefaultSaturation() * radius,
|
167
|
+
centerX,
|
168
|
+
centerY
|
169
|
+
)
|
170
|
+
|
171
|
+
var rx = x - centerX, ry = y - centerY, d = rx * rx + ry * ry, hue = caculateAngle(rx, ry);
|
172
|
+
|
173
|
+
if (d > radius * radius) {
|
174
|
+
var {x, y} = this.getCurrentXY(null, hue, radius, centerX, centerY);
|
175
|
+
}
|
176
|
+
|
177
|
+
// saturation 을
|
178
|
+
var saturation = Math.min(Math.sqrt(d) / radius, 1)
|
179
|
+
|
180
|
+
// set drag pointer position
|
181
|
+
this.refs.$drag_pointer.css({
|
182
|
+
left: (x - minX) + 'px',
|
183
|
+
top: (y - minY) + 'px'
|
184
|
+
});
|
185
|
+
|
186
|
+
if (!isEvent) {
|
187
|
+
this.changeColor({
|
188
|
+
type: 'hsv',
|
189
|
+
h: hue,
|
190
|
+
s: saturation
|
191
|
+
})
|
192
|
+
}
|
193
|
+
}
|
194
|
+
|
195
|
+
changeColor (opt) {
|
196
|
+
this.$store.dispatch('/changeColor',Object.assign({
|
197
|
+
source: this.source
|
198
|
+
}, opt || {}))
|
199
|
+
}
|
200
|
+
|
201
|
+
'@changeColor' (sourceType) {
|
202
|
+
if (this.source != sourceType) {
|
203
|
+
this.refresh(true);
|
204
|
+
}
|
205
|
+
}
|
206
|
+
|
207
|
+
'@initColor' () { this.refresh(true) }
|
208
|
+
|
209
|
+
// Event Bindings
|
210
|
+
'mouseup document' (e) {
|
211
|
+
if (this.isDown) {
|
212
|
+
this.isDown = false ;
|
213
|
+
this.$store.emit('lastUpdateColor');
|
214
|
+
}
|
215
|
+
}
|
216
|
+
|
217
|
+
'mousemove document' (e) {
|
218
|
+
if (this.isDown) {
|
219
|
+
this.setHueColor(e);
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
'mousedown $drag_pointer' (e) {
|
224
|
+
e.preventDefault();
|
225
|
+
this.isDown = true;
|
226
|
+
}
|
227
|
+
|
228
|
+
'mousedown $el' (e) {
|
229
|
+
this.isDown = true;
|
230
|
+
this.setHueColor(e);
|
231
|
+
}
|
232
|
+
|
233
|
+
'touchend document' (e) {
|
234
|
+
if (this.isDown) {
|
235
|
+
this.isDown = false ;
|
236
|
+
this.$store.emit('lastUpdateColor');
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
'touchmove document' (e) {
|
241
|
+
if (this.isDown) {
|
242
|
+
this.setHueColor(e);
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
'touchstart $drag_pointer' (e) {
|
247
|
+
e.preventDefault();
|
248
|
+
this.isDown = true;
|
249
|
+
}
|
250
|
+
|
251
|
+
'touchstart $el' (e) {
|
252
|
+
e.preventDefault()
|
253
|
+
this.isDown = true;
|
254
|
+
this.setHueColor(e);
|
255
|
+
}
|
256
|
+
}
|
257
|
+
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import Dom from '../../util/Dom'
|
2
|
+
import UIElement from '../UIElement';
|
3
|
+
|
4
|
+
export default class CurrentColorSets extends UIElement {
|
5
|
+
|
6
|
+
template() {
|
7
|
+
return `
|
8
|
+
<div class="colorsets">
|
9
|
+
<div class="menu" title="Open Color Palettes">
|
10
|
+
<button ref="$colorSetsChooseButton" type="button" class="color-sets-choose-btn arrow-button"></button>
|
11
|
+
</div>
|
12
|
+
<div ref="$colorSetsColorList" class="color-list"></div>
|
13
|
+
</div>
|
14
|
+
`
|
15
|
+
}
|
16
|
+
|
17
|
+
'load $colorSetsColorList' () {
|
18
|
+
const currentColorSets = this.$store.dispatch('/getCurrentColorSets')
|
19
|
+
const colors = this.$store.dispatch('/getCurrentColors')
|
20
|
+
|
21
|
+
return `
|
22
|
+
<div class="current-color-sets">
|
23
|
+
${colors.map( (color, i) => {
|
24
|
+
return `<div class="color-item" title="${color}" data-index="${i}" data-color="${color}">
|
25
|
+
<div class="empty"></div>
|
26
|
+
<div class="color-view" style="background-color: ${color}"></div>
|
27
|
+
</div>`
|
28
|
+
}).join('')}
|
29
|
+
${currentColorSets.edit ? `<div class="add-color-item">+</div>` : ''}
|
30
|
+
</div>
|
31
|
+
`
|
32
|
+
}
|
33
|
+
|
34
|
+
refresh () {
|
35
|
+
this.load();
|
36
|
+
}
|
37
|
+
|
38
|
+
|
39
|
+
addColor (color) {
|
40
|
+
this.$store.dispatch('/addCurrentColor', color);
|
41
|
+
}
|
42
|
+
|
43
|
+
'@changeCurrentColorSets' () {
|
44
|
+
this.refresh()
|
45
|
+
}
|
46
|
+
|
47
|
+
'click $colorSetsChooseButton' (e) {
|
48
|
+
this.$store.emit('toggleColorChooser');
|
49
|
+
}
|
50
|
+
|
51
|
+
'contextmenu $colorSetsColorList' (e) {
|
52
|
+
e.preventDefault();
|
53
|
+
const currentColorSets = this.$store.dispatch('/getCurrentColorSets')
|
54
|
+
|
55
|
+
if (!currentColorSets.edit) {
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
|
59
|
+
const $target = new Dom(e.target);
|
60
|
+
|
61
|
+
const $item = $target.closest('color-item');
|
62
|
+
|
63
|
+
if ($item) {
|
64
|
+
const index = parseInt($item.attr('data-index'));
|
65
|
+
|
66
|
+
this.$store.emit('showContextMenu', e, index);
|
67
|
+
} else {
|
68
|
+
this.$store.emit('showContextMenu', e);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
'click $colorSetsColorList .add-color-item' (e) {
|
73
|
+
this.addColor(this.$store.dispatch('/toColor'));
|
74
|
+
}
|
75
|
+
|
76
|
+
'click $colorSetsColorList .color-item' (e) {
|
77
|
+
this.$store.dispatch('/changeColor', e.$delegateTarget.attr('data-color'));
|
78
|
+
this.$store.emit('lastUpdateColor')
|
79
|
+
}
|
80
|
+
|
81
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import Event from '../../util/Event'
|
2
|
+
import UIElement from '../UIElement';
|
3
|
+
|
4
|
+
export default class CurrentColorSetsContextMenu extends UIElement {
|
5
|
+
|
6
|
+
template () {
|
7
|
+
return `
|
8
|
+
<ul class="colorsets-contextmenu">
|
9
|
+
<li class="menu-item small-hide" data-type="remove-color">Remove color</li>
|
10
|
+
<li class="menu-item small-hide" data-type="remove-all-to-the-right">Remove all to the right</li>
|
11
|
+
<li class="menu-item" data-type="clear-palette">Clear palette</li>
|
12
|
+
</ul>
|
13
|
+
`
|
14
|
+
}
|
15
|
+
|
16
|
+
show (e, index) {
|
17
|
+
const $event = Event.pos(e);
|
18
|
+
|
19
|
+
this.$el.css({
|
20
|
+
top: ($event.clientY - 10) + 'px',
|
21
|
+
left: $event.clientX + 'px'
|
22
|
+
});
|
23
|
+
this.$el.addClass('show');
|
24
|
+
this.selectedColorIndex = index;
|
25
|
+
|
26
|
+
if (typeof this.selectedColorIndex == 'undefined') {
|
27
|
+
this.$el.addClass('small')
|
28
|
+
} else {
|
29
|
+
this.$el.removeClass('small')
|
30
|
+
}
|
31
|
+
|
32
|
+
}
|
33
|
+
|
34
|
+
hide () {
|
35
|
+
this.$el.removeClass('show');
|
36
|
+
}
|
37
|
+
|
38
|
+
runCommand (command) {
|
39
|
+
switch(command) {
|
40
|
+
case 'remove-color':
|
41
|
+
this.$store.dispatch('/removeCurrentColor', this.selectedColorIndex);
|
42
|
+
break;
|
43
|
+
case 'remove-all-to-the-right':
|
44
|
+
this.$store.dispatch('/removeCurrentColorToTheRight', this.selectedColorIndex);
|
45
|
+
break;
|
46
|
+
case 'clear-palette':
|
47
|
+
this.$store.dispatch('/clearPalette');
|
48
|
+
break;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
'@showContextMenu' (e, index) {
|
53
|
+
this.show(e, index)
|
54
|
+
}
|
55
|
+
|
56
|
+
'click $el .menu-item' (e) {
|
57
|
+
e.preventDefault();
|
58
|
+
|
59
|
+
this.runCommand(e.$delegateTarget.attr('data-type'));
|
60
|
+
this.hide();
|
61
|
+
}
|
62
|
+
|
63
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import BaseSlider from '../../BaseSlider';
|
2
|
+
|
3
|
+
export default class Hue extends BaseSlider {
|
4
|
+
|
5
|
+
constructor (opt) {
|
6
|
+
super(opt)
|
7
|
+
|
8
|
+
this.minValue = 0
|
9
|
+
this.maxValue = 360
|
10
|
+
this.source = 'hue-control'
|
11
|
+
}
|
12
|
+
|
13
|
+
template () {
|
14
|
+
return `
|
15
|
+
<div class="hue">
|
16
|
+
<div ref="$container" class="hue-container">
|
17
|
+
<div ref="$bar" class="drag-bar"></div>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
`
|
21
|
+
}
|
22
|
+
|
23
|
+
getDefaultValue () {
|
24
|
+
return this.$store.hsv.h
|
25
|
+
}
|
26
|
+
|
27
|
+
refreshColorUI(e) {
|
28
|
+
|
29
|
+
var dist = this.getCaculatedDist(e);
|
30
|
+
|
31
|
+
this.setColorUI(dist/100 * this.maxValue);
|
32
|
+
|
33
|
+
this.changeColor({
|
34
|
+
h: (dist/100) * this.maxValue,
|
35
|
+
type: 'hsv'
|
36
|
+
})
|
37
|
+
}
|
38
|
+
|
39
|
+
|
40
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
|
2
|
+
import Color from '../../../util/Color'
|
3
|
+
import Event from '../../../util/Event'
|
4
|
+
import BaseSlider from '../../BaseSlider';
|
5
|
+
|
6
|
+
const source = 'chromedevtool-control-Opacity';
|
7
|
+
|
8
|
+
export default class Opacity extends BaseSlider {
|
9
|
+
|
10
|
+
constructor (opt) {
|
11
|
+
super(opt);
|
12
|
+
|
13
|
+
this.minValue = 0;
|
14
|
+
this.maxValue = 1;
|
15
|
+
this.source = 'opacity-control'
|
16
|
+
}
|
17
|
+
|
18
|
+
template () {
|
19
|
+
return `
|
20
|
+
<div class="opacity">
|
21
|
+
<div ref="$container" class="opacity-container">
|
22
|
+
<div ref="$colorbar" class="color-bar"></div>
|
23
|
+
<div ref="$bar" class="drag-bar"></div>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
`
|
27
|
+
}
|
28
|
+
|
29
|
+
refresh () {
|
30
|
+
super.refresh()
|
31
|
+
this.setOpacityColorBar()
|
32
|
+
}
|
33
|
+
|
34
|
+
setOpacityColorBar() {
|
35
|
+
var rgb = Object.assign({}, this.$store.rgb);
|
36
|
+
|
37
|
+
rgb.a = 0;
|
38
|
+
var start = Color.format(rgb, 'rgb');
|
39
|
+
|
40
|
+
rgb.a = 1;
|
41
|
+
var end = Color.format(rgb, 'rgb');
|
42
|
+
|
43
|
+
this.setOpacityColorBarBackground(start, end);
|
44
|
+
}
|
45
|
+
|
46
|
+
setOpacityColorBarBackground(start, end) {
|
47
|
+
this.refs.$colorbar.css('background', 'linear-gradient(to right, ' + start + ', ' + end + ')');
|
48
|
+
}
|
49
|
+
|
50
|
+
getDefaultValue () {
|
51
|
+
return this.$store.alpha
|
52
|
+
}
|
53
|
+
|
54
|
+
refreshColorUI(e) {
|
55
|
+
var dist = this.getCaculatedDist(e);
|
56
|
+
|
57
|
+
this.setColorUI( (dist/100) * this.maxValue);
|
58
|
+
|
59
|
+
this.changeColor({
|
60
|
+
a: (Math.floor(dist) / 100) * this.maxValue
|
61
|
+
})
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
import Event from '../../../util/Event'
|
3
|
+
import BaseSlider from '../../BaseSlider';
|
4
|
+
|
5
|
+
export default class Value extends BaseSlider {
|
6
|
+
|
7
|
+
constructor (opt) {
|
8
|
+
super(opt)
|
9
|
+
|
10
|
+
this.minValue = 0
|
11
|
+
this.maxValue = 1
|
12
|
+
this.source = 'value-control'
|
13
|
+
}
|
14
|
+
|
15
|
+
template () {
|
16
|
+
return `
|
17
|
+
<div class="value">
|
18
|
+
<div ref="$container" class="value-container">
|
19
|
+
<div ref="$bar" class="drag-bar"></div>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
`
|
23
|
+
}
|
24
|
+
|
25
|
+
setBackgroundColor () {
|
26
|
+
this.refs.$container.css("background-color", this.$store.dispatch('/toRGB'));
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
refresh () {
|
31
|
+
super.refresh()
|
32
|
+
this.setBackgroundColor();
|
33
|
+
}
|
34
|
+
|
35
|
+
getDefaultValue () {
|
36
|
+
return this.$store.hsv.v
|
37
|
+
}
|
38
|
+
|
39
|
+
refreshColorUI(e) {
|
40
|
+
var dist = this.getCaculatedDist(e);
|
41
|
+
|
42
|
+
this.setColorUI(dist/100 * this.maxValue)
|
43
|
+
|
44
|
+
this.changeColor({
|
45
|
+
type: 'hsv',
|
46
|
+
v: dist/100 * this.maxValue
|
47
|
+
})
|
48
|
+
}
|
49
|
+
|
50
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import VerticalSlider from '../../VerticalSlider';
|
2
|
+
|
3
|
+
export default class VerticalHue extends VerticalSlider {
|
4
|
+
|
5
|
+
constructor (opt) {
|
6
|
+
super(opt)
|
7
|
+
|
8
|
+
this.minValue = 0
|
9
|
+
this.maxValue = 360
|
10
|
+
this.source = 'vertical-hue-control'
|
11
|
+
}
|
12
|
+
|
13
|
+
template () {
|
14
|
+
return `
|
15
|
+
<div class="hue">
|
16
|
+
<div ref="$container" class="hue-container">
|
17
|
+
<div ref="$bar" class="drag-bar"></div>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
`
|
21
|
+
}
|
22
|
+
|
23
|
+
getDefaultValue () {
|
24
|
+
return this.$store.hsv.h
|
25
|
+
}
|
26
|
+
|
27
|
+
refreshColorUI(e) {
|
28
|
+
|
29
|
+
var dist = this.getCaculatedDist(e)
|
30
|
+
|
31
|
+
this.setColorUI( dist/100 * this.maxValue);
|
32
|
+
|
33
|
+
this.changeColor({
|
34
|
+
h: (dist/100) * this.maxValue,
|
35
|
+
type: 'hsv'
|
36
|
+
})
|
37
|
+
}
|
38
|
+
|
39
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
|
2
|
+
import Color from '../../../util/Color'
|
3
|
+
import Event from '../../../util/Event'
|
4
|
+
import VerticalSlider from '../../VerticalSlider';
|
5
|
+
|
6
|
+
export default class Opacity extends VerticalSlider {
|
7
|
+
|
8
|
+
constructor (opt) {
|
9
|
+
super(opt)
|
10
|
+
|
11
|
+
this.source = 'vertical-opacity-control'
|
12
|
+
}
|
13
|
+
|
14
|
+
template () {
|
15
|
+
return `
|
16
|
+
<div class="opacity">
|
17
|
+
<div ref="$container" class="opacity-container">
|
18
|
+
<div ref="$colorbar" class="color-bar"></div>
|
19
|
+
<div ref="$bar" class="drag-bar2"></div>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
`
|
23
|
+
}
|
24
|
+
|
25
|
+
refresh () {
|
26
|
+
super.refresh()
|
27
|
+
this.setOpacityColorBar()
|
28
|
+
}
|
29
|
+
|
30
|
+
setOpacityColorBar() {
|
31
|
+
var rgb = Object.assign({}, this.$store.rgb);
|
32
|
+
|
33
|
+
rgb.a = 0;
|
34
|
+
var start = Color.format(rgb, 'rgb');
|
35
|
+
|
36
|
+
rgb.a = 1;
|
37
|
+
var end = Color.format(rgb, 'rgb');
|
38
|
+
|
39
|
+
this.refs.$colorbar.css('background', 'linear-gradient(to top, ' + start + ', ' + end + ')');
|
40
|
+
}
|
41
|
+
|
42
|
+
getDefaultValue () {
|
43
|
+
return this.$store.alpha
|
44
|
+
}
|
45
|
+
|
46
|
+
refreshColorUI(e) {
|
47
|
+
var dist = this.getCaculatedDist(e)
|
48
|
+
|
49
|
+
this.setColorUI( ( dist/100 * this.maxValue) );
|
50
|
+
|
51
|
+
this.changeColor({
|
52
|
+
a: Math.floor(dist) / 100 * this.maxValue
|
53
|
+
})
|
54
|
+
}
|
55
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import Hue from '../ui/control/VerticalHue';
|
2
|
+
import Opacity from '../ui/control/VerticalOpacity'
|
3
|
+
import UIElement from '../UIElement';
|
4
|
+
|
5
|
+
const source = 'mini-control';
|
6
|
+
|
7
|
+
export default class ColorControl extends UIElement {
|
8
|
+
|
9
|
+
components () {
|
10
|
+
return { Hue, Opacity }
|
11
|
+
}
|
12
|
+
|
13
|
+
template () {
|
14
|
+
return /*html*/`
|
15
|
+
<div class="control">
|
16
|
+
<div target="Opacity" ></div>
|
17
|
+
<div target="Hue" ></div>
|
18
|
+
</div>
|
19
|
+
`
|
20
|
+
}
|
21
|
+
|
22
|
+
refresh () {
|
23
|
+
this.setColorUI();
|
24
|
+
}
|
25
|
+
|
26
|
+
setColorUI() {
|
27
|
+
this.Hue.setColorUI()
|
28
|
+
this.Opacity.setColorUI()
|
29
|
+
}
|
30
|
+
|
31
|
+
'@changeColor' (sourceType) {
|
32
|
+
if (source != sourceType) {
|
33
|
+
this.refresh()
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
'@initColor' () { this.refresh() }
|
38
|
+
|
39
|
+
}
|
40
|
+
|