@things-factory/modeller-ui 5.0.0-alpha.5 → 5.0.0-alpha.6
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/client/bootstrap.js +22 -26
- package/client/editors/things-editor-layout/things-card-layout.js +1 -1
- package/client/editors/things-editor-property.js +1 -546
- package/package.json +15 -14
- package/client/editors/paper-color-picker/paper-color-circle.js +0 -466
- package/client/editors/paper-color-picker/paper-color-input.js +0 -266
- package/client/editors/paper-color-picker/paper-color-picker.js +0 -584
- package/client/editors/things-editor-3dish.js +0 -164
- package/client/editors/things-editor-angle-input.js +0 -69
- package/client/editors/things-editor-attachment-selector.js +0 -110
- package/client/editors/things-editor-buttons-radio.js +0 -93
- package/client/editors/things-editor-code.js +0 -152
- package/client/editors/things-editor-color-stops.js +0 -499
- package/client/editors/things-editor-color-style.js +0 -345
- package/client/editors/things-editor-color.js +0 -313
- package/client/editors/things-editor-data.js +0 -152
- package/client/editors/things-editor-gradient.js +0 -335
- package/client/editors/things-editor-graphql.js +0 -173
- package/client/editors/things-editor-id.js +0 -85
- package/client/editors/things-editor-multiple-color.js +0 -132
- package/client/editors/things-editor-options.js +0 -156
- package/client/editors/things-editor-pattern.js +0 -161
- package/client/editors/things-editor-property-styles.js +0 -71
- package/client/editors/things-editor-range-input.js +0 -166
- package/client/editors/things-editor-script.js +0 -213
- package/client/editors/things-editor-stack.js +0 -107
- package/client/editors/things-editor-table.js +0 -376
- package/client/editors/things-editor-value-map.js +0 -290
- package/client/editors/things-editor-value-range.js +0 -292
|
@@ -1,584 +0,0 @@
|
|
|
1
|
-
import { html } from '@polymer/polymer/polymer-element'
|
|
2
|
-
|
|
3
|
-
import { Polymer } from '@polymer/polymer/lib/legacy/polymer-fn'
|
|
4
|
-
import { dom } from '@polymer/polymer/lib/legacy/polymer.dom'
|
|
5
|
-
|
|
6
|
-
import '@polymer/iron-flex-layout/iron-flex-layout'
|
|
7
|
-
import '@polymer/paper-slider/paper-slider'
|
|
8
|
-
import '@polymer/paper-dialog/paper-dialog'
|
|
9
|
-
import '@polymer/paper-button/paper-button'
|
|
10
|
-
import '@polymer/paper-input/paper-input'
|
|
11
|
-
import '@polymer/paper-input/paper-input-container'
|
|
12
|
-
import '@polymer/neon-animation/animations/fade-out-animation'
|
|
13
|
-
import '@polymer/neon-animation/animations/scale-up-animation'
|
|
14
|
-
import './paper-color-circle.js'
|
|
15
|
-
|
|
16
|
-
Polymer({
|
|
17
|
-
_template: html`
|
|
18
|
-
<style>
|
|
19
|
-
paper-color-circle {
|
|
20
|
-
width: 200px;
|
|
21
|
-
height: 200px;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
#container {
|
|
25
|
-
margin-top: 0px;
|
|
26
|
-
padding: 0px;
|
|
27
|
-
/*position:absolute;
|
|
28
|
-
left:0px;
|
|
29
|
-
top:0px;
|
|
30
|
-
right:0px;
|
|
31
|
-
bottom:0px;*/
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
#preview {
|
|
35
|
-
padding: 0px;
|
|
36
|
-
position: relative;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
paper-slider {
|
|
40
|
-
width: 100%;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
paper-input {
|
|
44
|
-
width: 100%;
|
|
45
|
-
padding: 0px 24px;
|
|
46
|
-
box-sizing: border-box;
|
|
47
|
-
margin: -10px 0px 0px 0px;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
#huePicker {
|
|
51
|
-
width: 255px;
|
|
52
|
-
margin: 15px;
|
|
53
|
-
height: 15px;
|
|
54
|
-
border-radius: 2px;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.landscapeOnly,
|
|
58
|
-
.portraitOnly {
|
|
59
|
-
display: none;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
#dialog {
|
|
63
|
-
display: flex;
|
|
64
|
-
align-items: stretch;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
paper-input {
|
|
68
|
-
margin-top: -1px;
|
|
69
|
-
padding: 0px;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
#detail {
|
|
73
|
-
background-color:#fff;
|
|
74
|
-
min-width: 240px;
|
|
75
|
-
margin: 0px;
|
|
76
|
-
padding: 0px;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
paper-color-circle {
|
|
80
|
-
display: block;
|
|
81
|
-
margin: auto;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
#preview {
|
|
85
|
-
margin-top: 0px;
|
|
86
|
-
background-image: linear-gradient(45deg, #eee 25%, transparent 25%),
|
|
87
|
-
linear-gradient(45deg, transparent 75%, #eee 75%), linear-gradient(45deg, #eee 25%, transparent 25%),
|
|
88
|
-
linear-gradient(45deg, transparent 75%, #eee 75%);
|
|
89
|
-
background-size: 24px 24px;
|
|
90
|
-
background-position: 0 0, 0px 0px, 12px 12px, 12px 12px;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
:host([advanced]) {
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.buttons {
|
|
97
|
-
margin-top: 20px;
|
|
98
|
-
padding-left: 0px;
|
|
99
|
-
padding-right: 0px;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
#rgb {
|
|
103
|
-
display: flex;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
#rgb paper-input {
|
|
107
|
-
flex: 1;
|
|
108
|
-
margin: 0px 5px;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
#rgb paper-input:first-child {
|
|
112
|
-
margin-left: 0px;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
#rgb paper-input:last-child {
|
|
116
|
-
margin-right: 0px;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
#color {
|
|
120
|
-
position: absolute;
|
|
121
|
-
left: 0px;
|
|
122
|
-
top: 0px;
|
|
123
|
-
right: 0px;
|
|
124
|
-
bottom: 0px;
|
|
125
|
-
z-index: 0;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
@media only screen and (orientation: portrait) {
|
|
129
|
-
.portraitOnly {
|
|
130
|
-
display: block;
|
|
131
|
-
}
|
|
132
|
-
#preview {
|
|
133
|
-
min-height: 91px;
|
|
134
|
-
}
|
|
135
|
-
#dialog {
|
|
136
|
-
width: 90%;
|
|
137
|
-
max-width: 350px;
|
|
138
|
-
flex-direction: column;
|
|
139
|
-
}
|
|
140
|
-
#detail {
|
|
141
|
-
padding-top: 20px;
|
|
142
|
-
}
|
|
143
|
-
#details {
|
|
144
|
-
padding: 0px 20px;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
@media only screen and (orientation: landscape) {
|
|
149
|
-
:host {
|
|
150
|
-
width: 480px;
|
|
151
|
-
}
|
|
152
|
-
#preview {
|
|
153
|
-
width: 185px;
|
|
154
|
-
}
|
|
155
|
-
#detail {
|
|
156
|
-
padding-top: 20px;
|
|
157
|
-
padding-left: 20px;
|
|
158
|
-
padding-right: 20px;
|
|
159
|
-
}
|
|
160
|
-
#container {
|
|
161
|
-
display: flex;
|
|
162
|
-
flex-direction: row;
|
|
163
|
-
}
|
|
164
|
-
.landscapeOnly {
|
|
165
|
-
display: block;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
</style>
|
|
169
|
-
|
|
170
|
-
<paper-dialog
|
|
171
|
-
id="dialog"
|
|
172
|
-
entry-animation="scale-up-animation"
|
|
173
|
-
exit-animation="fade-out-animation"
|
|
174
|
-
with-backdrop
|
|
175
|
-
class="color-picker-dialog"
|
|
176
|
-
>
|
|
177
|
-
<div id="preview"><div id="color"></div></div>
|
|
178
|
-
<div id="detail">
|
|
179
|
-
<paper-color-circle
|
|
180
|
-
id="picker"
|
|
181
|
-
shape="{{shape}}"
|
|
182
|
-
type="{{type}}"
|
|
183
|
-
value="{{colorValue}}"
|
|
184
|
-
color="{{immediateColor}}"
|
|
185
|
-
hue="{{colorHue}}"
|
|
186
|
-
lightness="{{colorLightness}}"
|
|
187
|
-
on-lightness-changed="_setSliders"
|
|
188
|
-
on-value-changed="_setSliders"
|
|
189
|
-
></paper-color-circle>
|
|
190
|
-
|
|
191
|
-
<div id="details">
|
|
192
|
-
<template is="dom-if" if="{{_showValueSlider(shape, type)}}">
|
|
193
|
-
<paper-input-container attr-for-value="immediate-value">
|
|
194
|
-
<label slot="label">Value (Brightness)</label>
|
|
195
|
-
<paper-slider
|
|
196
|
-
id="valueSlider"
|
|
197
|
-
class="paper-input-input"
|
|
198
|
-
min="0"
|
|
199
|
-
max="100"
|
|
200
|
-
pin="true"
|
|
201
|
-
value="100"
|
|
202
|
-
immediate-value="{{sliderValue}}"
|
|
203
|
-
slot="input"
|
|
204
|
-
></paper-slider>
|
|
205
|
-
</paper-input-container>
|
|
206
|
-
</template>
|
|
207
|
-
<template is="dom-if" if="{{_showLightnessSlider(shape, type)}}">
|
|
208
|
-
<paper-input-container attr-for-value="immediate-value">
|
|
209
|
-
<label slot="label">Lightness</label>
|
|
210
|
-
<paper-slider
|
|
211
|
-
id="lightnessSlider"
|
|
212
|
-
class="paper-input-input"
|
|
213
|
-
min="0"
|
|
214
|
-
max="100"
|
|
215
|
-
pin="true"
|
|
216
|
-
value="50"
|
|
217
|
-
immediate-value="{{sliderLightness}}"
|
|
218
|
-
slot="input"
|
|
219
|
-
></paper-slider>
|
|
220
|
-
</paper-input-container>
|
|
221
|
-
</template>
|
|
222
|
-
<template is="dom-if" if="{{_showHuePicker(shape)}}">
|
|
223
|
-
<paper-input-container attr-for-value="id">
|
|
224
|
-
<label slot="label">Hue</label>
|
|
225
|
-
<canvas
|
|
226
|
-
id="huePicker"
|
|
227
|
-
class="paper-input-input"
|
|
228
|
-
on-tap="huePickerPickColor"
|
|
229
|
-
on-track="huePickerPickColor"
|
|
230
|
-
height="1"
|
|
231
|
-
width="360"
|
|
232
|
-
slot="input"
|
|
233
|
-
></canvas>
|
|
234
|
-
</paper-input-container>
|
|
235
|
-
<!--<paper-slider id="hueSlider" min="0" max="100" value="50" immediate-value="{{sliderHue}}"></paper-slider>-->
|
|
236
|
-
</template>
|
|
237
|
-
|
|
238
|
-
<template is="dom-if" if="{{_and(allowAlpha,_initialAlphaValueHackApplied)}}">
|
|
239
|
-
<paper-input-container attr-for-value="immediate-value" hidden$="{{!_or(alwaysShowAlpha, advanced)}}">
|
|
240
|
-
<label slot="label">Alpha (transparency)</label>
|
|
241
|
-
<paper-slider
|
|
242
|
-
id="alphaPicker"
|
|
243
|
-
class="paper-input-input"
|
|
244
|
-
min="0"
|
|
245
|
-
max="1"
|
|
246
|
-
step="0.01"
|
|
247
|
-
value="{{_initialAlphaValueHack}}"
|
|
248
|
-
immediate-value="{{immediateColor.alpha}}"
|
|
249
|
-
on-change="_onAlphaChanged"
|
|
250
|
-
slot="input"
|
|
251
|
-
></paper-slider>
|
|
252
|
-
</paper-input-container>
|
|
253
|
-
</template>
|
|
254
|
-
|
|
255
|
-
<div hidden$="{{!advanced}}">
|
|
256
|
-
<!--<div class="landscapeOnly">-->
|
|
257
|
-
<div id="rgb">
|
|
258
|
-
<paper-input
|
|
259
|
-
id="redField"
|
|
260
|
-
value="{{immediateColor.red}}"
|
|
261
|
-
on-input="changeColorMixture"
|
|
262
|
-
type="number"
|
|
263
|
-
min="0"
|
|
264
|
-
max="255"
|
|
265
|
-
label="Red"
|
|
266
|
-
></paper-input>
|
|
267
|
-
<paper-input
|
|
268
|
-
id="greenField"
|
|
269
|
-
value="{{immediateColor.green}}"
|
|
270
|
-
on-input="changeColorMixture"
|
|
271
|
-
type="number"
|
|
272
|
-
min="0"
|
|
273
|
-
max="255"
|
|
274
|
-
label="Green"
|
|
275
|
-
></paper-input>
|
|
276
|
-
<paper-input
|
|
277
|
-
id="blueField"
|
|
278
|
-
value="{{immediateColor.blue}}"
|
|
279
|
-
on-input="changeColorMixture"
|
|
280
|
-
type="number"
|
|
281
|
-
min="0"
|
|
282
|
-
max="255"
|
|
283
|
-
label="Blue"
|
|
284
|
-
></paper-input>
|
|
285
|
-
</div>
|
|
286
|
-
<!--</div>-->
|
|
287
|
-
</div>
|
|
288
|
-
</div>
|
|
289
|
-
|
|
290
|
-
<div class="buttons">
|
|
291
|
-
<paper-button dialog-dismiss>Cancel</paper-button>
|
|
292
|
-
<paper-button on-tap="toggleAdvancedMode" hidden$="{{advanced}}">Advanced</paper-button>
|
|
293
|
-
<paper-button dialog-confirm on-tap="setColor" autofocus>OK</paper-button>
|
|
294
|
-
</div>
|
|
295
|
-
</div>
|
|
296
|
-
</paper-dialog>
|
|
297
|
-
`,
|
|
298
|
-
is: 'paper-color-picker',
|
|
299
|
-
properties: {
|
|
300
|
-
/**
|
|
301
|
-
* The selected color as an object: `{red, green, blue}`
|
|
302
|
-
*
|
|
303
|
-
* @attribute color
|
|
304
|
-
* @type Object
|
|
305
|
-
* @default new Object()
|
|
306
|
-
*/
|
|
307
|
-
color: {
|
|
308
|
-
type: Object,
|
|
309
|
-
value: {
|
|
310
|
-
red: undefined,
|
|
311
|
-
green: undefined,
|
|
312
|
-
blue: undefined,
|
|
313
|
-
alpha: 1
|
|
314
|
-
},
|
|
315
|
-
notify: true
|
|
316
|
-
},
|
|
317
|
-
colorHue: {
|
|
318
|
-
type: Number,
|
|
319
|
-
value: 0
|
|
320
|
-
},
|
|
321
|
-
colorLightness: {
|
|
322
|
-
type: Number,
|
|
323
|
-
value: 0.5
|
|
324
|
-
},
|
|
325
|
-
colorValue: {
|
|
326
|
-
type: Number,
|
|
327
|
-
value: 1
|
|
328
|
-
},
|
|
329
|
-
disableUpdate: {
|
|
330
|
-
type: Boolean,
|
|
331
|
-
value: false
|
|
332
|
-
},
|
|
333
|
-
/**
|
|
334
|
-
* Show alpha slider always instead of only in the advanced settings
|
|
335
|
-
*/
|
|
336
|
-
alwaysShowAlpha: Boolean,
|
|
337
|
-
/**
|
|
338
|
-
* Whether to allow changing the transparency of the picked color
|
|
339
|
-
*/
|
|
340
|
-
allowAlpha: Boolean,
|
|
341
|
-
/**
|
|
342
|
-
* The selected color as an object: `{red, green, blue}`
|
|
343
|
-
* even before the user clicks ok
|
|
344
|
-
*
|
|
345
|
-
* @attribute immediateColor
|
|
346
|
-
* @type Object
|
|
347
|
-
* @default {red: 50, green: 50, blue: 50}
|
|
348
|
-
*/
|
|
349
|
-
immediateColor: {
|
|
350
|
-
type: Object,
|
|
351
|
-
value: {
|
|
352
|
-
red: 0,
|
|
353
|
-
green: 150,
|
|
354
|
-
blue: 136,
|
|
355
|
-
alpha: 1
|
|
356
|
-
},
|
|
357
|
-
notify: true
|
|
358
|
-
},
|
|
359
|
-
/**
|
|
360
|
-
* *square*, *circle* or *huebox*
|
|
361
|
-
*
|
|
362
|
-
* @attribute shape
|
|
363
|
-
* @type string
|
|
364
|
-
* @default 'circle'
|
|
365
|
-
*/
|
|
366
|
-
shape: {
|
|
367
|
-
type: String,
|
|
368
|
-
value: 'circle',
|
|
369
|
-
notify: true
|
|
370
|
-
},
|
|
371
|
-
sliderHue: {
|
|
372
|
-
type: Number,
|
|
373
|
-
value: 50
|
|
374
|
-
},
|
|
375
|
-
sliderLightness: {
|
|
376
|
-
type: Number,
|
|
377
|
-
value: 50,
|
|
378
|
-
observer: 'sliderLightnessChanged'
|
|
379
|
-
},
|
|
380
|
-
sliderValue: {
|
|
381
|
-
type: Number,
|
|
382
|
-
value: 100,
|
|
383
|
-
observer: 'sliderValueChanged'
|
|
384
|
-
},
|
|
385
|
-
/**
|
|
386
|
-
* *hsv* or *hsl*
|
|
387
|
-
*
|
|
388
|
-
* @attribute type
|
|
389
|
-
* @type string
|
|
390
|
-
* @default 'hsv'
|
|
391
|
-
*/
|
|
392
|
-
type: {
|
|
393
|
-
type: String,
|
|
394
|
-
value: 'hsv',
|
|
395
|
-
notify: true
|
|
396
|
-
},
|
|
397
|
-
immediateColorAsString: {
|
|
398
|
-
type: String,
|
|
399
|
-
notify: true
|
|
400
|
-
},
|
|
401
|
-
colorAsString: {
|
|
402
|
-
type: String,
|
|
403
|
-
notify: true
|
|
404
|
-
},
|
|
405
|
-
advanced: {
|
|
406
|
-
type: Boolean,
|
|
407
|
-
reflectToAttribute: true,
|
|
408
|
-
observer: '_recenterDialog'
|
|
409
|
-
}
|
|
410
|
-
},
|
|
411
|
-
observers: ['immediateColorChanged(immediateColor.*)'],
|
|
412
|
-
ready: function() {
|
|
413
|
-
if (!this.advanced) {
|
|
414
|
-
this.set('advanced', false)
|
|
415
|
-
}
|
|
416
|
-
if (!this.alwaysShowAlpha) {
|
|
417
|
-
this.set('alwaysShowAlpha', false)
|
|
418
|
-
}
|
|
419
|
-
this.async(function() {
|
|
420
|
-
if (this._isColorDefined()) {
|
|
421
|
-
if (this.allowAlpha && typeof this.color.alpha !== 'undefined') {
|
|
422
|
-
this._initialAlphaValueHack = this.color.alpha
|
|
423
|
-
} else {
|
|
424
|
-
this._initialAlphaValueHack = 1
|
|
425
|
-
}
|
|
426
|
-
} else if (this._isImmediateColorDefined()) {
|
|
427
|
-
if (this.allowAlpha && typeof this.immediateColor.alpha !== 'undefined') {
|
|
428
|
-
this._initialAlphaValueHack = this.immediateColor.alpha
|
|
429
|
-
} else {
|
|
430
|
-
this._initialAlphaValueHack = 1
|
|
431
|
-
}
|
|
432
|
-
} else {
|
|
433
|
-
this._initialAlphaValueHack = 1
|
|
434
|
-
}
|
|
435
|
-
this._initialAlphaValueHackApplied = true
|
|
436
|
-
})
|
|
437
|
-
window.addEventListener(
|
|
438
|
-
'resize',
|
|
439
|
-
function() {
|
|
440
|
-
this.$.dialog.resetFit()
|
|
441
|
-
}.bind(this)
|
|
442
|
-
)
|
|
443
|
-
},
|
|
444
|
-
_and: function(a, b) {
|
|
445
|
-
return a && b
|
|
446
|
-
},
|
|
447
|
-
_or: function(a, b) {
|
|
448
|
-
return a || b
|
|
449
|
-
},
|
|
450
|
-
_isColorDefined: function() {
|
|
451
|
-
return this.color.red >= 0 && this.color.green >= 0 && this.color.blue >= 0
|
|
452
|
-
},
|
|
453
|
-
_isImmediateColorDefined: function() {
|
|
454
|
-
return this.immediateColor.red >= 0 && this.immediateColor.green >= 0 && this.immediateColor.blue >= 0
|
|
455
|
-
},
|
|
456
|
-
setColorWheel: function() {
|
|
457
|
-
if (!this.disableUpdate) {
|
|
458
|
-
if (this._showValueSlider()) {
|
|
459
|
-
this.set('colorValue', this.sliderValue / 100)
|
|
460
|
-
}
|
|
461
|
-
if (this._showLightnessSlider()) this.colorLightness = this.sliderLightness / 100
|
|
462
|
-
setTimeout(
|
|
463
|
-
function() {
|
|
464
|
-
this.disableUpdate = false
|
|
465
|
-
}.bind(this),
|
|
466
|
-
50
|
|
467
|
-
)
|
|
468
|
-
}
|
|
469
|
-
this.disableUpdate = true
|
|
470
|
-
},
|
|
471
|
-
sliderValueChanged: function() {
|
|
472
|
-
this.setColorWheel()
|
|
473
|
-
},
|
|
474
|
-
sliderLightnessChanged: function() {
|
|
475
|
-
this.setColorWheel()
|
|
476
|
-
},
|
|
477
|
-
_calculateLuminance: function(r, g, b) {
|
|
478
|
-
var a = [r, g, b].map(function(v) {
|
|
479
|
-
v /= 255
|
|
480
|
-
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4)
|
|
481
|
-
})
|
|
482
|
-
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722
|
|
483
|
-
},
|
|
484
|
-
immediateColorChanged: function() {
|
|
485
|
-
if (typeof this.immediateColor.alpha == 'undefined') {
|
|
486
|
-
this.immediateColor.alpha = 1
|
|
487
|
-
}
|
|
488
|
-
var colorAsString =
|
|
489
|
-
'rgba(' +
|
|
490
|
-
this.immediateColor['red'] +
|
|
491
|
-
',' +
|
|
492
|
-
this.immediateColor['green'] +
|
|
493
|
-
',' +
|
|
494
|
-
this.immediateColor['blue'] +
|
|
495
|
-
',' +
|
|
496
|
-
this.immediateColor['alpha'] +
|
|
497
|
-
')'
|
|
498
|
-
this.$.color.style.backgroundColor = colorAsString
|
|
499
|
-
this.immediateColorAsString = colorAsString
|
|
500
|
-
},
|
|
501
|
-
drawHuePicker: function() {
|
|
502
|
-
this._huePickerCtx = dom(this.root)
|
|
503
|
-
.querySelector('#huePicker')
|
|
504
|
-
.getContext('2d')
|
|
505
|
-
var bitmap = this._huePickerCtx.getImageData(0, 0, 360, 30)
|
|
506
|
-
for (var x = 0; x < 360; x++) {
|
|
507
|
-
var hue = x
|
|
508
|
-
var color = this.$.picker.hsv2rgb(hue, 1, 1)
|
|
509
|
-
bitmap.data[4 * x + 0] = color[0]
|
|
510
|
-
bitmap.data[4 * x + 1] = color[1]
|
|
511
|
-
bitmap.data[4 * x + 2] = color[2]
|
|
512
|
-
bitmap.data[4 * x + 3] = 255
|
|
513
|
-
}
|
|
514
|
-
this._huePickerCtx.putImageData(bitmap, 0, 0)
|
|
515
|
-
},
|
|
516
|
-
huePickerPickColor: function(e) {
|
|
517
|
-
var rect = dom(this.root)
|
|
518
|
-
.querySelector('#huePicker')
|
|
519
|
-
.getBoundingClientRect()
|
|
520
|
-
var percentage = (e.detail.x - rect.left) / rect.width
|
|
521
|
-
if (percentage > 0 && percentage < 1) this.colorHue = percentage
|
|
522
|
-
},
|
|
523
|
-
changeColorMixture: function() {
|
|
524
|
-
var red = this.$.redField.value
|
|
525
|
-
var green = this.$.greenField.value
|
|
526
|
-
var blue = this.$.blueField.value
|
|
527
|
-
var colors = {
|
|
528
|
-
red: red,
|
|
529
|
-
green: green,
|
|
530
|
-
blue: blue
|
|
531
|
-
}
|
|
532
|
-
this.set('immediateColor', colors)
|
|
533
|
-
},
|
|
534
|
-
setColor: function() {
|
|
535
|
-
this.set('color.red', this.immediateColor.red)
|
|
536
|
-
this.set('color.green', this.immediateColor.green)
|
|
537
|
-
this.set('color.blue', this.immediateColor.blue)
|
|
538
|
-
this.set('color.alpha', this.immediateColor.alpha)
|
|
539
|
-
this.set('colorAsString', this.immediateColorAsString)
|
|
540
|
-
},
|
|
541
|
-
open: function() {
|
|
542
|
-
if (this.color && this.color['green']) this.immediateColor = this.color
|
|
543
|
-
this.immediateColorChanged()
|
|
544
|
-
this.$.dialog.open()
|
|
545
|
-
if (this._showHuePicker()) this.drawHuePicker()
|
|
546
|
-
},
|
|
547
|
-
_computeColouredaaborder: function() {
|
|
548
|
-
return {
|
|
549
|
-
red: 50,
|
|
550
|
-
green: 50,
|
|
551
|
-
blue: 50
|
|
552
|
-
}
|
|
553
|
-
},
|
|
554
|
-
_showValueSlider: function() {
|
|
555
|
-
return this.type == 'hsv' && this.shape !== 'huebox'
|
|
556
|
-
},
|
|
557
|
-
_showLightnessSlider: function() {
|
|
558
|
-
return this.type == 'hsl' && this.shape !== 'huebox'
|
|
559
|
-
},
|
|
560
|
-
_showHuePicker: function() {
|
|
561
|
-
return this.shape == 'huebox'
|
|
562
|
-
},
|
|
563
|
-
toggleAdvancedMode: function() {
|
|
564
|
-
this.advanced = !this.advanced
|
|
565
|
-
},
|
|
566
|
-
_recenterDialog: function() {
|
|
567
|
-
if (this.$.dialog.opened) this.$.dialog.center()
|
|
568
|
-
},
|
|
569
|
-
_setSliders: function() {
|
|
570
|
-
this.async(function() {
|
|
571
|
-
var valueSlider = dom(this.root).querySelector('#valueSlider')
|
|
572
|
-
if (valueSlider) {
|
|
573
|
-
valueSlider.set('value', this.colorValue * 100)
|
|
574
|
-
}
|
|
575
|
-
var lightnessSlider = dom(this.root).querySelector('#lightnessSlider')
|
|
576
|
-
if (lightnessSlider) {
|
|
577
|
-
lightnessSlider.set('value', this.colorLightness * 100)
|
|
578
|
-
}
|
|
579
|
-
})
|
|
580
|
-
},
|
|
581
|
-
_onAlphaChanged: function(e) {
|
|
582
|
-
e.stopPropagation()
|
|
583
|
-
}
|
|
584
|
-
})
|