tweak-ui 0.4.2 → 0.5.0
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/LICENSE +7 -7
- package/README.md +32 -32
- package/dist/lib/builder.d.ts +166 -162
- package/dist/lib/builder.d.ts.map +1 -1
- package/dist/lib/builder.js +250 -0
- package/dist/lib/builder.js.map +1 -0
- package/dist/lib/color-formats/array-format.d.ts +8 -8
- package/dist/lib/color-formats/array-format.js +18 -0
- package/dist/lib/color-formats/array-format.js.map +1 -0
- package/dist/lib/color-formats/converter.d.ts +18 -18
- package/dist/lib/color-formats/converter.js +85 -0
- package/dist/lib/color-formats/converter.js.map +1 -0
- package/dist/lib/color-formats/css-string-format.d.ts +7 -7
- package/dist/lib/color-formats/css-string-format.js +28 -0
- package/dist/lib/color-formats/css-string-format.js.map +1 -0
- package/dist/lib/color-formats/formatter.d.ts +8 -8
- package/dist/lib/color-formats/formatter.js +35 -0
- package/dist/lib/color-formats/formatter.js.map +1 -0
- package/dist/lib/color-formats/hex-string-format.d.ts +7 -7
- package/dist/lib/color-formats/hex-string-format.js +28 -0
- package/dist/lib/color-formats/hex-string-format.js.map +1 -0
- package/dist/lib/color-formats/index.d.ts +3 -3
- package/dist/lib/color-formats/index.js +4 -0
- package/dist/lib/color-formats/index.js.map +1 -0
- package/dist/lib/color-formats/number-format.d.ts +8 -8
- package/dist/lib/color-formats/number-format.js +23 -0
- package/dist/lib/color-formats/number-format.js.map +1 -0
- package/dist/lib/color-formats/object-format.d.ts +14 -14
- package/dist/lib/color-formats/object-format.js +23 -0
- package/dist/lib/color-formats/object-format.js.map +1 -0
- package/dist/lib/color-formats/types.d.ts +101 -101
- package/dist/lib/color-formats/types.js +2 -0
- package/dist/lib/color-formats/types.js.map +1 -0
- package/dist/lib/components/button.d.ts +28 -28
- package/dist/lib/components/button.d.ts.map +1 -1
- package/dist/lib/components/button.js +15 -0
- package/dist/lib/components/button.js.map +1 -0
- package/dist/lib/components/content.d.ts +21 -21
- package/dist/lib/components/content.d.ts.map +1 -1
- package/dist/lib/components/content.js +10 -0
- package/dist/lib/components/content.js.map +1 -0
- package/dist/lib/components/controls/angle.d.ts +51 -51
- package/dist/lib/components/controls/angle.d.ts.map +1 -1
- package/dist/lib/components/controls/angle.js +201 -0
- package/dist/lib/components/controls/angle.js.map +1 -0
- package/dist/lib/components/controls/checkbox.d.ts +28 -28
- package/dist/lib/components/controls/checkbox.d.ts.map +1 -1
- package/dist/lib/components/controls/checkbox.js +31 -0
- package/dist/lib/components/controls/checkbox.js.map +1 -0
- package/dist/lib/components/controls/color-picker.d.ts +56 -56
- package/dist/lib/components/controls/color-picker.d.ts.map +1 -1
- package/dist/lib/components/controls/color-picker.js +267 -0
- package/dist/lib/components/controls/color-picker.js.map +1 -0
- package/dist/lib/components/controls/color.d.ts +51 -51
- package/dist/lib/components/controls/color.d.ts.map +1 -1
- package/dist/lib/components/controls/color.js +77 -0
- package/dist/lib/components/controls/color.js.map +1 -0
- package/dist/lib/components/controls/index.d.ts +10 -10
- package/dist/lib/components/controls/index.js +11 -0
- package/dist/lib/components/controls/index.js.map +1 -0
- package/dist/lib/components/controls/number.d.ts +47 -47
- package/dist/lib/components/controls/number.d.ts.map +1 -1
- package/dist/lib/components/controls/number.js +142 -0
- package/dist/lib/components/controls/number.js.map +1 -0
- package/dist/lib/components/controls/point.d.ts +47 -47
- package/dist/lib/components/controls/point.d.ts.map +1 -1
- package/dist/lib/components/controls/point.js +137 -0
- package/dist/lib/components/controls/point.js.map +1 -0
- package/dist/lib/components/controls/position.d.ts +55 -55
- package/dist/lib/components/controls/position.d.ts.map +1 -1
- package/dist/lib/components/controls/position.js +36 -0
- package/dist/lib/components/controls/position.js.map +1 -0
- package/dist/lib/components/controls/select.d.ts +59 -59
- package/dist/lib/components/controls/select.d.ts.map +1 -1
- package/dist/lib/components/controls/select.js +132 -0
- package/dist/lib/components/controls/select.js.map +1 -0
- package/dist/lib/components/controls/spherical.d.ts +74 -74
- package/dist/lib/components/controls/spherical.d.ts.map +1 -1
- package/dist/lib/components/controls/spherical.js +302 -0
- package/dist/lib/components/controls/spherical.js.map +1 -0
- package/dist/lib/components/controls/text.d.ts +35 -35
- package/dist/lib/components/controls/text.d.ts.map +1 -1
- package/dist/lib/components/controls/text.js +24 -0
- package/dist/lib/components/controls/text.js.map +1 -0
- package/dist/lib/components/groups/accordion.d.ts +21 -21
- package/dist/lib/components/groups/accordion.d.ts.map +1 -1
- package/dist/lib/components/groups/accordion.js +34 -0
- package/dist/lib/components/groups/accordion.js.map +1 -0
- package/dist/lib/components/groups/container.d.ts +24 -24
- package/dist/lib/components/groups/container.d.ts.map +1 -1
- package/dist/lib/components/groups/container.js +19 -0
- package/dist/lib/components/groups/container.js.map +1 -0
- package/dist/lib/components/groups/group.d.ts +48 -48
- package/dist/lib/components/groups/group.d.ts.map +1 -1
- package/dist/lib/components/groups/group.js +50 -0
- package/dist/lib/components/groups/group.js.map +1 -0
- package/dist/lib/components/groups/index.d.ts +4 -4
- package/dist/lib/components/groups/index.js +5 -0
- package/dist/lib/components/groups/index.js.map +1 -0
- package/dist/lib/components/groups/tabs.d.ts +21 -21
- package/dist/lib/components/groups/tabs.d.ts.map +1 -1
- package/dist/lib/components/groups/tabs.js +31 -0
- package/dist/lib/components/groups/tabs.js.map +1 -0
- package/dist/lib/components/image.d.ts +36 -36
- package/dist/lib/components/image.d.ts.map +1 -1
- package/dist/lib/components/image.js +46 -0
- package/dist/lib/components/image.js.map +1 -0
- package/dist/lib/components/index.d.ts +5 -5
- package/dist/lib/components/index.js +6 -0
- package/dist/lib/components/index.js.map +1 -0
- package/dist/lib/core/index.d.ts +4 -4
- package/dist/lib/core/index.js +5 -0
- package/dist/lib/core/index.js.map +1 -0
- package/dist/lib/core/registry.d.ts +17 -17
- package/dist/lib/core/registry.js +30 -0
- package/dist/lib/core/registry.js.map +1 -0
- package/dist/lib/core/render.d.ts +9 -9
- package/dist/lib/core/render.d.ts.map +1 -1
- package/dist/lib/core/render.js +19 -0
- package/dist/lib/core/render.js.map +1 -0
- package/dist/lib/core/types.d.ts +87 -87
- package/dist/lib/core/types.d.ts.map +1 -1
- package/dist/lib/core/types.js +2 -0
- package/dist/lib/core/types.js.map +1 -0
- package/dist/lib/core/utils.d.ts +93 -93
- package/dist/lib/core/utils.d.ts.map +1 -1
- package/dist/lib/core/utils.js +193 -0
- package/dist/lib/core/utils.js.map +1 -0
- package/dist/lib/core/value-accessor.d.ts +17 -17
- package/dist/lib/core/value-accessor.js +52 -0
- package/dist/lib/core/value-accessor.js.map +1 -0
- package/dist/lib/index.d.ts +21 -27
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +29 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/mount.d.ts +45 -45
- package/dist/lib/mount.js +85 -0
- package/dist/lib/mount.js.map +1 -0
- package/dist/tweak-ui.css +133 -138
- package/dist/tweak-ui.css.map +1 -1
- package/dist/tweak-ui.min.css +1 -1
- package/dist/tweak-ui.min.css.map +1 -1
- package/dist/tweak-ui.module.js +2733 -2380
- package/dist/tweak-ui.module.js.map +1 -1
- package/dist/tweak-ui.umd.js +1 -4403
- package/dist/tweak-ui.umd.js.map +1 -1
- package/package.json +25 -42
- package/dist/index.html +0 -1061
- package/dist/lib/color-formats/array-format.spec.d.ts +0 -2
- package/dist/lib/color-formats/array-format.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/converter.spec.d.ts +0 -2
- package/dist/lib/color-formats/converter.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/css-string-format.spec.d.ts +0 -2
- package/dist/lib/color-formats/css-string-format.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/formatter.spec.d.ts +0 -2
- package/dist/lib/color-formats/formatter.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/hex-string-format.spec.d.ts +0 -2
- package/dist/lib/color-formats/hex-string-format.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/number-format.spec.d.ts +0 -2
- package/dist/lib/color-formats/number-format.spec.d.ts.map +0 -1
- package/dist/lib/color-formats/object-format.spec.d.ts +0 -2
- package/dist/lib/color-formats/object-format.spec.d.ts.map +0 -1
- package/dist/scss/_style.scss +0 -120
- package/dist/scss/_themes.scss +0 -23
- package/dist/scss/_utils.scss +0 -24
- package/dist/scss/_variables.scss +0 -30
- package/dist/scss/controls/_angle.scss +0 -64
- package/dist/scss/controls/_button.scss +0 -0
- package/dist/scss/controls/_checkbox.scss +0 -19
- package/dist/scss/controls/_color-picker.scss +0 -124
- package/dist/scss/controls/_color.scss +0 -14
- package/dist/scss/controls/_container.scss +0 -13
- package/dist/scss/controls/_group.scss +0 -69
- package/dist/scss/controls/_image.scss +0 -27
- package/dist/scss/controls/_number.scss +0 -38
- package/dist/scss/controls/_point.scss +0 -36
- package/dist/scss/controls/_position.scss +0 -9
- package/dist/scss/controls/_select.scss +0 -0
- package/dist/scss/controls/_spherical.scss +0 -87
- package/dist/scss/controls/_tabs.scss +0 -38
- package/dist/scss/controls/_text.scss +0 -0
- package/dist/scss/index.scss +0 -21
- package/dist/tweak-ui.umd.min.js +0 -17
- package/dist/tweak-ui.umd.min.js.map +0 -1
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// tslint:disable: unified-signatures
|
|
2
|
+
import { isFunction, isObject, isString } from './core/utils';
|
|
3
|
+
function assign(partial, overrides) {
|
|
4
|
+
Object.keys(overrides).forEach((key) => {
|
|
5
|
+
partial[key] = overrides[key];
|
|
6
|
+
});
|
|
7
|
+
return partial;
|
|
8
|
+
}
|
|
9
|
+
function buildGroup() {
|
|
10
|
+
let label = null;
|
|
11
|
+
let opts = {};
|
|
12
|
+
let cb;
|
|
13
|
+
// tslint:disable-next-line: prefer-for-of
|
|
14
|
+
for (let i = 0; i < arguments.length; i++) {
|
|
15
|
+
const arg = arguments[i];
|
|
16
|
+
if (isString(arg)) {
|
|
17
|
+
label = arg;
|
|
18
|
+
}
|
|
19
|
+
else if (isObject(arg)) {
|
|
20
|
+
opts = arg;
|
|
21
|
+
}
|
|
22
|
+
else if (isFunction(arg)) {
|
|
23
|
+
cb = arg;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (label) {
|
|
27
|
+
opts.label = label;
|
|
28
|
+
}
|
|
29
|
+
if (cb) {
|
|
30
|
+
const controls = this.controls;
|
|
31
|
+
this.controls = [];
|
|
32
|
+
cb(this);
|
|
33
|
+
opts.children = this.controls;
|
|
34
|
+
this.controls = controls;
|
|
35
|
+
}
|
|
36
|
+
return opts;
|
|
37
|
+
}
|
|
38
|
+
function buildControl() {
|
|
39
|
+
let opts = {};
|
|
40
|
+
if (arguments.length > 1) {
|
|
41
|
+
opts = arguments[2] || opts;
|
|
42
|
+
opts.target = arguments[0];
|
|
43
|
+
opts.property = arguments[1];
|
|
44
|
+
if (opts.label === undefined) {
|
|
45
|
+
opts.label = String(opts.property || '');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (arguments.length === 1) {
|
|
49
|
+
opts = arguments[0] || opts;
|
|
50
|
+
}
|
|
51
|
+
return opts;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
export class Builder {
|
|
58
|
+
constructor() {
|
|
59
|
+
/**
|
|
60
|
+
* Collection of created controls
|
|
61
|
+
*/
|
|
62
|
+
this.controls = [];
|
|
63
|
+
}
|
|
64
|
+
group() {
|
|
65
|
+
const opts = buildGroup.apply(this, arguments);
|
|
66
|
+
return this.add(assign(opts, {
|
|
67
|
+
type: 'group',
|
|
68
|
+
children: opts.children,
|
|
69
|
+
label: null,
|
|
70
|
+
title: opts.label,
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
collapsible() {
|
|
74
|
+
const opts = buildGroup.apply(this, arguments);
|
|
75
|
+
return this.add(assign(opts, {
|
|
76
|
+
type: 'group',
|
|
77
|
+
children: opts.children,
|
|
78
|
+
collapsible: true,
|
|
79
|
+
label: null,
|
|
80
|
+
title: opts.label,
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
container() {
|
|
84
|
+
const opts = buildGroup.apply(this, arguments);
|
|
85
|
+
return this.add(assign(opts, {
|
|
86
|
+
type: 'container',
|
|
87
|
+
children: opts.children,
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
tabs() {
|
|
91
|
+
const opts = buildGroup.apply(this, arguments);
|
|
92
|
+
return this.add(assign(opts, {
|
|
93
|
+
type: 'tabs',
|
|
94
|
+
active: opts.active || 0,
|
|
95
|
+
children: opts.children,
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
accordion() {
|
|
99
|
+
const opts = buildGroup.apply(this, arguments);
|
|
100
|
+
return this.add(assign(opts, {
|
|
101
|
+
type: 'accordion',
|
|
102
|
+
children: opts.children,
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
checkbox() {
|
|
106
|
+
const opts = buildControl.apply(this, arguments);
|
|
107
|
+
return this.add(assign(opts, { type: 'checkbox' }));
|
|
108
|
+
}
|
|
109
|
+
text() {
|
|
110
|
+
const opts = buildControl.apply(this, arguments);
|
|
111
|
+
return this.add(assign(opts, { type: 'text' }));
|
|
112
|
+
}
|
|
113
|
+
number() {
|
|
114
|
+
const opts = buildControl.apply(this, arguments);
|
|
115
|
+
return this.add(assign(opts, { type: 'number' }));
|
|
116
|
+
}
|
|
117
|
+
slider() {
|
|
118
|
+
const opts = buildControl.apply(this, arguments);
|
|
119
|
+
return this.add(assign(opts, { type: 'slider' }));
|
|
120
|
+
}
|
|
121
|
+
position() {
|
|
122
|
+
const opts = buildControl.apply(this, arguments);
|
|
123
|
+
return this.add(assign(opts, { type: 'position' }));
|
|
124
|
+
}
|
|
125
|
+
select() {
|
|
126
|
+
const opts = buildControl.apply(this, arguments);
|
|
127
|
+
return this.add(assign(opts, { type: 'select' }));
|
|
128
|
+
}
|
|
129
|
+
color() {
|
|
130
|
+
const opts = buildControl.apply(this, arguments);
|
|
131
|
+
return this.add(assign(opts, { type: 'color' }));
|
|
132
|
+
}
|
|
133
|
+
colorPicker() {
|
|
134
|
+
const opts = buildControl.apply(this, arguments);
|
|
135
|
+
return this.add(assign(opts, { type: 'color-picker' }));
|
|
136
|
+
}
|
|
137
|
+
point() {
|
|
138
|
+
const opts = buildControl.apply(this, arguments);
|
|
139
|
+
return this.add(assign(opts, { type: 'point' }));
|
|
140
|
+
}
|
|
141
|
+
spherical() {
|
|
142
|
+
const opts = buildControl.apply(this, arguments);
|
|
143
|
+
return this.add(assign(opts, { type: 'spherical' }));
|
|
144
|
+
}
|
|
145
|
+
angle() {
|
|
146
|
+
const opts = buildControl.apply(this, arguments);
|
|
147
|
+
return this.add(assign(opts, { type: 'angle' }));
|
|
148
|
+
}
|
|
149
|
+
object(label, target, config = {}) {
|
|
150
|
+
return this.group(label, (ui) => {
|
|
151
|
+
for (const key in target) {
|
|
152
|
+
if (!config[key]) {
|
|
153
|
+
const value = target[key];
|
|
154
|
+
switch (typeof value) {
|
|
155
|
+
case 'number':
|
|
156
|
+
ui.number(target, key);
|
|
157
|
+
break;
|
|
158
|
+
case 'string':
|
|
159
|
+
ui.text(target, key);
|
|
160
|
+
break;
|
|
161
|
+
case 'boolean':
|
|
162
|
+
ui.checkbox(target, key);
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
switch (config[key].type) {
|
|
168
|
+
case 'text':
|
|
169
|
+
ui.text(target, key, config[key]);
|
|
170
|
+
break;
|
|
171
|
+
case 'number':
|
|
172
|
+
ui.number(target, key, config[key]);
|
|
173
|
+
break;
|
|
174
|
+
case 'checkbox':
|
|
175
|
+
ui.checkbox(target, key, config[key]);
|
|
176
|
+
break;
|
|
177
|
+
case 'select':
|
|
178
|
+
ui.select(target, key, config[key]);
|
|
179
|
+
break;
|
|
180
|
+
case 'color':
|
|
181
|
+
ui.color(target, key, config[key]);
|
|
182
|
+
break;
|
|
183
|
+
case 'color-picker':
|
|
184
|
+
ui.colorPicker(target, key, config[key]);
|
|
185
|
+
break;
|
|
186
|
+
case 'point':
|
|
187
|
+
ui.point(target, key, config[key]);
|
|
188
|
+
break;
|
|
189
|
+
case 'spherical':
|
|
190
|
+
ui.spherical(target, key, config[key]);
|
|
191
|
+
break;
|
|
192
|
+
case 'angle':
|
|
193
|
+
ui.angle(target, key, config[key]);
|
|
194
|
+
break;
|
|
195
|
+
default:
|
|
196
|
+
//
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Adds a button control
|
|
203
|
+
*
|
|
204
|
+
* @param text - The button text
|
|
205
|
+
* @param opts - Additional options for the control
|
|
206
|
+
*/
|
|
207
|
+
button(text, opts = {}) {
|
|
208
|
+
return this.add(assign(opts, {
|
|
209
|
+
type: 'button',
|
|
210
|
+
text: text,
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
image() {
|
|
214
|
+
const opts = buildGroup.apply(this, arguments);
|
|
215
|
+
return this.add(assign(opts, {
|
|
216
|
+
type: 'image',
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Adds a description text
|
|
221
|
+
*
|
|
222
|
+
* @param label - The control label
|
|
223
|
+
* @param text - The text message
|
|
224
|
+
* @param opts - Additional options for the control
|
|
225
|
+
*/
|
|
226
|
+
content(label, content, opts = {}) {
|
|
227
|
+
return this.add(assign(opts, {
|
|
228
|
+
type: 'content',
|
|
229
|
+
label: label,
|
|
230
|
+
content: content,
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Adds a control
|
|
235
|
+
*
|
|
236
|
+
* @param def - The control definition
|
|
237
|
+
*/
|
|
238
|
+
add(def) {
|
|
239
|
+
this.controls.push(assign(def, {
|
|
240
|
+
remove: () => {
|
|
241
|
+
const i = this.controls.indexOf(def);
|
|
242
|
+
if (i >= 0) {
|
|
243
|
+
this.controls.splice(i, 1);
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
}));
|
|
247
|
+
return def;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/lib/builder.ts"],"names":[],"mappings":"AACA,qCAAqC;AAuBrC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAgF7D,SAAS,MAAM,CAA2B,OAAmB,EAAE,SAAY;IACzE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;QAC7C,OAAO,CAAC,GAAc,CAAC,GAAG,SAAS,CAAC,GAAc,CAAC,CAAA;IACrD,CAAC,CAAC,CAAA;IACF,OAAO,OAAY,CAAA;AACrB,CAAC;AAED,SAAS,UAAU;IACjB,IAAI,KAAK,GAAW,IAAI,CAAA;IACxB,IAAI,IAAI,GAAe,EAAE,CAAA;IACzB,IAAI,EAAa,CAAA;IAEjB,0CAA0C;IAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;QACxB,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAClB,KAAK,GAAG,GAAG,CAAA;QACb,CAAC;aAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,IAAI,GAAG,GAAG,CAAA;QACZ,CAAC;aAAM,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,EAAE,GAAG,GAAG,CAAA;QACV,CAAC;IACH,CAAC;IAED,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,I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YACV,MAAM,EAAE,GAAG,EAAE;gBACX,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;gBACpC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBACX,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;gBAC5B,CAAC;YACH,CAAC;SACF,CAAC,CACH,CAAA;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;CACF","sourcesContent":["\n// tslint:disable: unified-signatures\n\nimport { ComponentModel, ComponentGroupModel, ValueSource } from './core'\n\nimport {\n AccordeonModel,\n AngleModel,\n ButtonModel,\n CheckboxModel,\n ContainerModel,\n ColorModel,\n ColorPickerModel,\n ContentModel,\n GroupModel,\n ImageModel,\n NumberModel,\n PointModel,\n SelectModel,\n SphericalModel,\n TabsModel,\n TextModel,\n PositionModel,\n} from './components'\nimport { isFunction, isObject, isString } from './core/utils'\nimport { Child } from 'mithril'\n\n/**\n *\n * @public\n */\nexport interface Removable {\n remove?: () => void\n}\n\n/**\n * Union type of all build in models\n * @public\n */\nexport type BuildInComponent =\n | AccordeonModel\n | AngleModel\n | ButtonModel\n | CheckboxModel\n | ColorModel\n | ColorPickerModel\n | ContainerModel\n | ContentModel\n | GroupModel\n | ImageModel\n | NumberModel\n | PointModel\n | SelectModel\n | SphericalModel\n | TabsModel\n | TextModel\n | PositionModel\n\n/**\n * @public\n */\nexport type BuilderFn = (b: Builder) => void\n\n/**\n * @public\n */\nexport type TabsBuilderFn = (b: TabsBuilder) => void\n\n/**\n * @public\n */\nexport type AccordeonBuilderFn = (b: AccordeonBuilder) => void\n\n/**\n * @public\n */\nexport interface TabsBuilder {\n group(label: string, builder: BuilderFn): GroupModel & Removable\n}\n\n/**\n * @public\n */\nexport interface AccordeonBuilder {\n /**\n * Adds a control group\n *\n * @param title - The group label\n * @param builder - A callback allowing to build sub controls\n */\n group(title: string, builder: BuilderFn): GroupModel & Removable\n /**\n * Adds a control group\n *\n * @param title - The group label\n * @param opts - Additional control options\n * @param builder - A callback allowing to build sub controls\n */\n group(title: string, opts: Partial<GroupModel>, builder?: BuilderFn): GroupModel & Removable\n group(title: string, builder: BuilderFn): GroupModel & Removable\n}\n\nfunction assign<T extends ComponentModel, E>(partial: T, overrides: E): T & E\nfunction assign<T extends ComponentModel>(partial: Partial<T>, overrides: T): T\nfunction assign<T extends ComponentModel>(partial: Partial<T>, overrides: T): T {\n Object.keys(overrides).forEach((key: string) => {\n partial[key as keyof T] = overrides[key as keyof T]\n })\n return partial as T\n}\n\nfunction buildGroup<T extends ComponentGroupModel>(this: Builder): Partial<T> {\n let label: string = null\n let opts: Partial<T> = {}\n let cb: BuilderFn\n\n // tslint:disable-next-line: prefer-for-of\n for (let i = 0; i < arguments.length; i++) {\n const arg = arguments[i]\n if (isString(arg)) {\n label = arg\n } else if (isObject(arg)) {\n opts = arg\n } else if (isFunction(arg)) {\n cb = arg\n }\n }\n\n if (label) {\n opts.label = label\n }\n\n if (cb) {\n const controls = this.controls\n this.controls = []\n cb(this)\n opts.children = this.controls\n this.controls = controls\n }\n return opts\n}\n\n\nfunction buildControl<T extends ValueSource<any, any> & ComponentModel>(): Partial<T> {\n let opts: Partial<T> = {}\n\n if (arguments.length > 1) {\n opts = arguments[2] || opts\n opts.target = arguments[0]\n opts.property = arguments[1]\n if (opts.label === undefined) {\n opts.label = String(opts.property || '')\n }\n }\n if (arguments.length === 1) {\n opts = arguments[0] || opts\n }\n\n return opts\n}\n\n/**\n *\n * @public\n */\nexport class Builder {\n /**\n * Collection of created controls\n */\n public controls: ComponentModel[] = []\n\n public group(builder: BuilderFn): GroupModel & Removable\n public group(opts: Partial<GroupModel>): GroupModel & Removable\n public group(opts: Partial<GroupModel>, builder: BuilderFn): GroupModel & Removable\n public group(label: string, builder: BuilderFn): GroupModel & Removable\n public group(label: string, opts: Partial<GroupModel>): GroupModel & Removable\n public group(label: string, opts: Partial<GroupModel>, builder: BuilderFn): GroupModel & Removable\n public group(): GroupModel & Removable {\n const opts: Partial<GroupModel> = buildGroup.apply(this, arguments)\n return this.add<GroupModel>(assign(opts, {\n type: 'group',\n children: opts.children,\n label: null,\n title: opts.label,\n }))\n }\n\n public collapsible(builder: BuilderFn): GroupModel & Removable\n public collapsible(opts: Partial<GroupModel>): GroupModel & Removable\n public collapsible(opts: Partial<GroupModel>, builder: BuilderFn): GroupModel & Removable\n public collapsible(label: string, builder: BuilderFn): GroupModel & Removable\n public collapsible(label: string, opts: Partial<GroupModel>): GroupModel & Removable\n public collapsible(label: string, opts: Partial<GroupModel>, builder: BuilderFn): GroupModel & Removable\n public collapsible(): GroupModel & Removable {\n const opts: Partial<GroupModel> = buildGroup.apply(this, arguments)\n return this.add<GroupModel>(assign(opts, {\n type: 'group',\n children: opts.children,\n collapsible: true,\n label: null,\n title: opts.label,\n }))\n }\n\n public container(builder: BuilderFn): ContainerModel & Removable\n public container(opts: Partial<ContainerModel>): ContainerModel & Removable\n public container(opts: Partial<ContainerModel>, builder: BuilderFn): ContainerModel & Removable\n public container(label: string, builder: BuilderFn): ContainerModel & Removable\n public container(label: string, opts: Partial<ContainerModel>): ContainerModel & Removable\n public container(label: string, opts: Partial<ContainerModel>, builder: BuilderFn): ContainerModel & Removable\n public container(): ContainerModel & Removable {\n const opts: Partial<ContainerModel> = buildGroup.apply(this, arguments)\n return this.add<ContainerModel>(assign(opts, {\n type: 'container',\n children: opts.children,\n }))\n }\n\n public tabs(builder: TabsBuilderFn): TabsModel & Removable\n public tabs(opts: Partial<TabsModel>): TabsModel & Removable\n public tabs(opts: Partial<TabsModel>, builder: TabsBuilderFn): TabsModel & Removable\n public tabs(label: string, builder: TabsBuilderFn): TabsModel & Removable\n public tabs(label: string, opts: Partial<TabsModel>): TabsModel & Removable\n public tabs(label: string, opts: Partial<TabsModel>, builder: TabsBuilderFn): TabsModel & Removable\n public tabs(): TabsModel & Removable {\n const opts: Partial<TabsModel> = buildGroup.apply(this, arguments)\n return this.add<TabsModel>(assign(opts, {\n type: 'tabs',\n active: opts.active || 0,\n children: opts.children,\n }))\n }\n\n public accordion(builder: AccordeonBuilderFn): AccordeonModel & Removable\n public accordion(opts: Partial<AccordeonModel>): AccordeonModel & Removable\n public accordion(opts: Partial<AccordeonModel>, builder: AccordeonBuilderFn): AccordeonModel & Removable\n public accordion(label: string, builder: AccordeonBuilderFn): AccordeonModel & Removable\n public accordion(label: string, opts: Partial<AccordeonModel>): AccordeonModel & Removable\n public accordion(label: string, opts: Partial<AccordeonModel>, builder: AccordeonBuilderFn): AccordeonModel & Removable\n public accordion(): AccordeonModel & Removable {\n const opts: Partial<AccordeonModel> = buildGroup.apply(this, arguments)\n return this.add<AccordeonModel>(assign(opts, {\n type: 'accordion',\n children: opts.children,\n }))\n }\n\n public checkbox<T>(opts: Partial<CheckboxModel<T>>): CheckboxModel<T>\n public checkbox<T>(target: T, property: keyof T): CheckboxModel<T>\n public checkbox<T>(target: T, property: keyof T, opts: Partial<CheckboxModel<T>>): CheckboxModel<T>\n public checkbox(): CheckboxModel {\n const opts: Partial<CheckboxModel> = buildControl.apply(this, arguments)\n return this.add<CheckboxModel>(\n assign(opts, { type: 'checkbox' }),\n )\n }\n\n public text<T>(opts: Partial<TextModel<T>>): TextModel<T>\n public text<T>(target: T, property: keyof T): TextModel<T>\n public text<T>(target: T, property: keyof T, opts: Partial<TextModel<T>>): TextModel<T>\n public text(): TextModel {\n const opts: Partial<TextModel> = buildControl.apply(this, arguments)\n return this.add<TextModel>(\n assign(opts, { type: 'text' }),\n )\n }\n\n public number<T>(opts: Partial<NumberModel<T>>): NumberModel<T>\n public number<T>(target: T, property: keyof T): NumberModel<T>\n public number<T>(target: T, property: keyof T, opts: Partial<NumberModel<T>>): NumberModel<T>\n public number(): NumberModel {\n const opts: Partial<NumberModel> = buildControl.apply(this, arguments)\n return this.add<NumberModel>(\n assign(opts, { type: 'number' }),\n )\n }\n\n public slider<T>(opts: Partial<NumberModel<T>>): NumberModel<T>\n public slider<T>(target: T, property: keyof T): NumberModel<T>\n public slider<T>(target: T, property: keyof T, opts: Partial<NumberModel<T>>): NumberModel<T>\n public slider(): NumberModel {\n const opts: Partial<NumberModel> = buildControl.apply(this, arguments)\n return this.add<NumberModel>(\n assign(opts, { type: 'slider' }),\n )\n }\n\n public position<T>(opts: Partial<PositionModel<T>>): PositionModel<T>\n public position<T>(target: T, property: keyof T): PositionModel<T>\n public position<T>(target: T, property: keyof T, opts: Partial<PositionModel<T>>): PositionModel<T>\n public position(): PositionModel {\n const opts: Partial<PositionModel> = buildControl.apply(this, arguments)\n return this.add<PositionModel>(\n assign(opts, { type: 'position' }),\n )\n }\n public select<T>(opts: Partial<SelectModel<T>>): SelectModel<T>\n public select<T>(target: T, property: keyof T): SelectModel<T>\n public select<T>(target: T, property: keyof T, opts: Partial<SelectModel<T>>): SelectModel<T>\n public select(): SelectModel {\n const opts: Partial<SelectModel> = buildControl.apply(this, arguments)\n return this.add<SelectModel>(\n assign(opts, { type: 'select' }),\n )\n }\n\n public color<T>(opts: Partial<ColorModel<T>>): ColorModel<T>\n public color<T>(target: T, property: keyof T): ColorModel<T>\n public color<T>(target: T, property: keyof T, opts: Partial<ColorModel<T>>): ColorModel<T>\n public color(): ColorModel {\n const opts: Partial<ColorModel> = buildControl.apply(this, arguments)\n return this.add<ColorModel>(\n assign(opts, { type: 'color' }),\n )\n }\n\n public colorPicker<T>(opts: Partial<ColorPickerModel<T>>): ColorPickerModel<T>\n public colorPicker<T>(target: T, property: keyof T): ColorPickerModel<T>\n public colorPicker<T>(target: T, property: keyof T, opts: Partial<ColorPickerModel<T>>): ColorPickerModel<T>\n public colorPicker(): ColorPickerModel {\n const opts: Partial<ColorPickerModel> = buildControl.apply(this, arguments)\n return this.add<ColorPickerModel>(\n assign(opts, { type: 'color-picker' }),\n )\n }\n\n public point<T>(opts: Partial<PointModel<T>>): PointModel<T>\n public point<T>(target: T, property: keyof T): PointModel<T>\n public point<T>(target: T, property: keyof T, opts: Partial<PointModel<T>>): PointModel<T>\n public point(): PointModel {\n const opts: Partial<PointModel> = buildControl.apply(this, arguments)\n return this.add<PointModel>(\n assign(opts, { type: 'point' }),\n )\n }\n\n public spherical<T>(opts: Partial<SphericalModel<T>>): SphericalModel<T>\n public spherical<T>(target: T, property: keyof T): SphericalModel<T>\n public spherical<T>(target: T, property: keyof T, opts: Partial<SphericalModel<T>>): SphericalModel<T>\n public spherical(): SphericalModel {\n const opts: Partial<SphericalModel> = buildControl.apply(this, arguments)\n return this.add<SphericalModel>(\n assign(opts, { type: 'spherical' }),\n )\n }\n\n public angle<T>(opts: Partial<AngleModel<T>>): AngleModel<T>\n public angle<T>(target: T, property: keyof T): AngleModel<T>\n public angle<T>(target: T, property: keyof T, opts: Partial<AngleModel<T>>): AngleModel<T>\n public angle(): AngleModel {\n const opts: Partial<AngleModel> = buildControl.apply(this, arguments)\n return this.add<AngleModel>(\n assign(opts, { type: 'angle' }),\n )\n }\n\n public object<T>(label: string, target: T, config: ObjectConfig<T> = {}) {\n return this.group(label, (ui) => {\n for (const key in target) {\n if (!config[key]) {\n const value = target[key]\n switch (typeof value) {\n case 'number':\n ui.number(target, key);\n break\n case 'string':\n ui.text(target, key);\n break\n case 'boolean':\n ui.checkbox(target, key);\n break\n }\n continue\n }\n switch (config[key].type) {\n case 'text':\n ui.text(target, key, config[key]);\n break;\n case 'number':\n ui.number(target, key, config[key]);\n break;\n case 'checkbox':\n ui.checkbox(target, key, config[key]);\n break;\n case 'select':\n ui.select(target, key, config[key]);\n break;\n case 'color':\n ui.color(target, key, config[key]);\n break;\n case 'color-picker':\n ui.colorPicker(target, key, config[key]);\n break;\n case 'point':\n ui.point(target, key, config[key]);\n break;\n case 'spherical':\n ui.spherical(target, key, config[key]);\n break;\n case 'angle':\n ui.angle(target, key, config[key]);\n break;\n default:\n //\n }\n }\n })\n }\n\n /**\n * Adds a button control\n *\n * @param text - The button text\n * @param opts - Additional options for the control\n */\n public button(text: string, opts: Partial<ButtonModel> = {}) {\n return this.add<ButtonModel>(\n assign(opts, {\n type: 'button',\n text: text,\n }),\n )\n }\n\n /**\n * Adds an image control\n *\n * @param label - The control label\n * @param opts - Additional options for the control\n */\n public image(opts: Partial<ImageModel>): ImageModel & Removable\n public image(label: string, opts: Partial<ImageModel>): ImageModel & Removable\n public image() {\n const opts: Partial<ImageModel> = buildGroup.apply(this, arguments)\n return this.add<ImageModel>(assign(opts, {\n type: 'image',\n }))\n }\n\n /**\n * Adds a description text\n *\n * @param label - The control label\n * @param text - The text message\n * @param opts - Additional options for the control\n */\n public content(label: string, content: Child, opts: Partial<ContentModel> = {}) {\n return this.add<ContentModel>(\n assign(opts, {\n type: 'content',\n label: label,\n content: content,\n }),\n )\n }\n\n\n\n /**\n * Adds a build in control\n *\n * @param def - The control definition\n */\n public add<T extends BuildInComponent>(def: T): T & Removable\n /**\n * Adds a control\n *\n * @param def - The control definition\n */\n public add<T extends ComponentModel>(def: T): T & Removable\n /**\n * Adds a control\n *\n * @param def - The control definition\n */\n public add<T extends ComponentModel>(def: T): T & Removable {\n this.controls.push(\n assign(def, {\n remove: () => {\n const i = this.controls.indexOf(def)\n if (i >= 0) {\n this.controls.splice(i, 1)\n }\n },\n }),\n )\n return def\n }\n}\n\nexport type ObjectConfig<T> = {\n [K in keyof T]?:\n TextModel<T> |\n NumberModel<T> |\n CheckboxModel<T> |\n SelectModel<T> |\n ColorModel<T> |\n ColorPickerModel<T> |\n PointModel<T> |\n SphericalModel<T> |\n AngleModel<T>\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ColorFormatter, RGBA } from './types';
|
|
2
|
-
export declare class ArrayColorFormat implements ColorFormatter<number[]> {
|
|
3
|
-
private components;
|
|
4
|
-
private normalized;
|
|
5
|
-
constructor(components: string[], normalized: boolean);
|
|
6
|
-
parse(v: number[]): RGBA;
|
|
7
|
-
format(rgba: RGBA): number[];
|
|
8
|
-
}
|
|
1
|
+
import { ColorFormatter, RGBA } from './types';
|
|
2
|
+
export declare class ArrayColorFormat implements ColorFormatter<number[]> {
|
|
3
|
+
private components;
|
|
4
|
+
private normalized;
|
|
5
|
+
constructor(components: string[], normalized: boolean);
|
|
6
|
+
parse(v: number[]): RGBA;
|
|
7
|
+
format(rgba: RGBA): number[];
|
|
8
|
+
}
|
|
9
9
|
//# sourceMappingURL=array-format.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class ArrayColorFormat {
|
|
2
|
+
constructor(components, normalized) {
|
|
3
|
+
this.components = components;
|
|
4
|
+
this.normalized = normalized;
|
|
5
|
+
}
|
|
6
|
+
parse(v) {
|
|
7
|
+
v = v || [];
|
|
8
|
+
const result = { r: 0, g: 0, b: 0, a: 1 };
|
|
9
|
+
this.components.forEach((key, i) => {
|
|
10
|
+
result[key] = (v[i] || 0) / (this.normalized ? 1 : 255);
|
|
11
|
+
});
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
format(rgba) {
|
|
15
|
+
return this.components.map((key) => (this.normalized ? rgba[key] : Math.round(rgba[key] * 255)) || 0);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=array-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-format.js","sourceRoot":"","sources":["../../../src/lib/color-formats/array-format.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,gBAAgB;IAC3B,YAAoB,UAAoB,EAAU,UAAmB;QAAjD,eAAU,GAAV,UAAU,CAAU;QAAU,eAAU,GAAV,UAAU,CAAS;IAAG,CAAC;IAClE,KAAK,CAAC,CAAW;QACtB,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;QACX,MAAM,MAAM,GAAS,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA;QAC/C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;YACjC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QACzD,CAAC,CAAC,CAAA;QACF,OAAO,MAAM,CAAA;IACf,CAAC;IAEM,MAAM,CAAC,IAAU;QACtB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CACxB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAC1E,CAAA;IACH,CAAC;CACF","sourcesContent":["import { ColorFormatter, RGBA } from './types'\r\n\r\nexport class ArrayColorFormat implements ColorFormatter<number[]> {\r\n constructor(private components: string[], private normalized: boolean) {}\r\n public parse(v: number[]) {\r\n v = v || []\r\n const result: RGBA = { r: 0, g: 0, b: 0, a: 1 }\r\n this.components.forEach((key, i) => {\r\n result[key] = (v[i] || 0) / (this.normalized ? 1 : 255)\r\n })\r\n return result\r\n }\r\n\r\n public format(rgba: RGBA) {\r\n return this.components.map(\r\n (key) => (this.normalized ? rgba[key] : Math.round(rgba[key] * 255)) || 0,\r\n )\r\n }\r\n}\r\n"]}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { HSV, RGB } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Converts hsv to rgb
|
|
4
|
-
*
|
|
5
|
-
* @public
|
|
6
|
-
* @param hsv - HSV components where H is in range [0:360] and S and V are in range [0:1]
|
|
7
|
-
* @returns RGB color components in range [0:1]
|
|
8
|
-
*/
|
|
9
|
-
export declare function hsv2rgb(hsv: HSV): RGB;
|
|
10
|
-
/**
|
|
11
|
-
* Converts rgb to hsv
|
|
12
|
-
*
|
|
13
|
-
* @public
|
|
14
|
-
* @remarks
|
|
15
|
-
* The RGB components are assumed to be in range [0:1].
|
|
16
|
-
* The resulting H component is in range [0:360] and S and V in range [0:1]
|
|
17
|
-
*/
|
|
18
|
-
export declare function rgb2hsv(rgb: RGB): HSV;
|
|
1
|
+
import { HSV, RGB } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Converts hsv to rgb
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
* @param hsv - HSV components where H is in range [0:360] and S and V are in range [0:1]
|
|
7
|
+
* @returns RGB color components in range [0:1]
|
|
8
|
+
*/
|
|
9
|
+
export declare function hsv2rgb(hsv: HSV): RGB;
|
|
10
|
+
/**
|
|
11
|
+
* Converts rgb to hsv
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
* @remarks
|
|
15
|
+
* The RGB components are assumed to be in range [0:1].
|
|
16
|
+
* The resulting H component is in range [0:360] and S and V in range [0:1]
|
|
17
|
+
*/
|
|
18
|
+
export declare function rgb2hsv(rgb: RGB): HSV;
|
|
19
19
|
//# sourceMappingURL=converter.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { clamp } from '../core/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Converts hsv to rgb
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
* @param hsv - HSV components where H is in range [0:360] and S and V are in range [0:1]
|
|
7
|
+
* @returns RGB color components in range [0:1]
|
|
8
|
+
*/
|
|
9
|
+
export function hsv2rgb(hsv) {
|
|
10
|
+
let H = hsv.h % 360;
|
|
11
|
+
let S = clamp(hsv.s, 0, 1);
|
|
12
|
+
let V = clamp(hsv.v, 0, 1);
|
|
13
|
+
let C = V * S;
|
|
14
|
+
let X = C * (1 - Math.abs(((H / 60) % 2) - 1));
|
|
15
|
+
let m = V - C;
|
|
16
|
+
const rgb = { r: 0, g: 0, b: 0 };
|
|
17
|
+
if (H < 60) {
|
|
18
|
+
rgb.r = C;
|
|
19
|
+
rgb.g = X;
|
|
20
|
+
rgb.b = 0;
|
|
21
|
+
}
|
|
22
|
+
else if (H < 120) {
|
|
23
|
+
rgb.r = X;
|
|
24
|
+
rgb.g = C;
|
|
25
|
+
rgb.b = 0;
|
|
26
|
+
}
|
|
27
|
+
else if (H < 180) {
|
|
28
|
+
rgb.r = 0;
|
|
29
|
+
rgb.g = C;
|
|
30
|
+
rgb.b = X;
|
|
31
|
+
}
|
|
32
|
+
else if (H < 240) {
|
|
33
|
+
rgb.r = 0;
|
|
34
|
+
rgb.g = X;
|
|
35
|
+
rgb.b = C;
|
|
36
|
+
}
|
|
37
|
+
else if (H < 300) {
|
|
38
|
+
rgb.r = X;
|
|
39
|
+
rgb.g = 0;
|
|
40
|
+
rgb.b = C;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
rgb.r = C;
|
|
44
|
+
rgb.g = 0;
|
|
45
|
+
rgb.b = X;
|
|
46
|
+
}
|
|
47
|
+
rgb.r += m;
|
|
48
|
+
rgb.g += m;
|
|
49
|
+
rgb.b += m;
|
|
50
|
+
return rgb;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Converts rgb to hsv
|
|
54
|
+
*
|
|
55
|
+
* @public
|
|
56
|
+
* @remarks
|
|
57
|
+
* The RGB components are assumed to be in range [0:1].
|
|
58
|
+
* The resulting H component is in range [0:360] and S and V in range [0:1]
|
|
59
|
+
*/
|
|
60
|
+
export function rgb2hsv(rgb) {
|
|
61
|
+
let r = rgb.r;
|
|
62
|
+
let g = rgb.g;
|
|
63
|
+
let b = rgb.b;
|
|
64
|
+
let V = Math.max(r, g, b);
|
|
65
|
+
let d = V - Math.min(r, g, b);
|
|
66
|
+
let S = 0;
|
|
67
|
+
let H = 0;
|
|
68
|
+
if (d !== 0) {
|
|
69
|
+
S = d / V;
|
|
70
|
+
if (V === r) {
|
|
71
|
+
H = (g - b) / d + (g < b ? 6 : 0);
|
|
72
|
+
H = (H % 6) * 60;
|
|
73
|
+
}
|
|
74
|
+
else if (V === g) {
|
|
75
|
+
H = (b - r) / d + 2;
|
|
76
|
+
H = H * 60;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
H = (r - g) / d + 4;
|
|
80
|
+
H = H * 60;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return { h: H, s: S, v: V };
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../../../src/lib/color-formats/converter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAGrC;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,GAAQ;IAC9B,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAA;IACnB,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAC1B,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAE1B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACb,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAC9C,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAEb,MAAM,GAAG,GAAQ,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA;IACrC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QACX,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;QACT,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;QACT,GAAG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,CAAC,CAAC,CAAA;IAEb,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACzB,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAE7B,IAAI,CAAC,GAAG,CAAC,CAAA;IACT,IAAI,CAAC,GAAG,CAAC,CAAA;IACT,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACT,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACZ,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YACjC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAA;QAClB,CAAC;aAAM,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACnB,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACnB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;QACZ,CAAC;aAAM,CAAC;YACN,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACnB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;QACZ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA;AAC7B,CAAC","sourcesContent":["import { clamp } from '../core/utils'\r\nimport { HSV, RGB } from './types'\r\n\r\n/**\r\n * Converts hsv to rgb\r\n *\r\n * @public\r\n * @param hsv - HSV components where H is in range [0:360] and S and V are in range [0:1]\r\n * @returns RGB color components in range [0:1]\r\n */\r\nexport function hsv2rgb(hsv: HSV): RGB {\r\n let H = hsv.h % 360\r\n let S = clamp(hsv.s, 0, 1)\r\n let V = clamp(hsv.v, 0, 1)\r\n\r\n let C = V * S\r\n let X = C * (1 - Math.abs(((H / 60) % 2) - 1))\r\n let m = V - C\r\n\r\n const rgb: RGB = { r: 0, g: 0, b: 0 }\r\n if (H < 60) {\r\n rgb.r = C\r\n rgb.g = X\r\n rgb.b = 0\r\n } else if (H < 120) {\r\n rgb.r = X\r\n rgb.g = C\r\n rgb.b = 0\r\n } else if (H < 180) {\r\n rgb.r = 0\r\n rgb.g = C\r\n rgb.b = X\r\n } else if (H < 240) {\r\n rgb.r = 0\r\n rgb.g = X\r\n rgb.b = C\r\n } else if (H < 300) {\r\n rgb.r = X\r\n rgb.g = 0\r\n rgb.b = C\r\n } else {\r\n rgb.r = C\r\n rgb.g = 0\r\n rgb.b = X\r\n }\r\n\r\n rgb.r += m\r\n rgb.g += m\r\n rgb.b += m\r\n\r\n return rgb\r\n}\r\n\r\n/**\r\n * Converts rgb to hsv\r\n *\r\n * @public\r\n * @remarks\r\n * The RGB components are assumed to be in range [0:1].\r\n * The resulting H component is in range [0:360] and S and V in range [0:1]\r\n */\r\nexport function rgb2hsv(rgb: RGB): HSV {\r\n let r = rgb.r\r\n let g = rgb.g\r\n let b = rgb.b\r\n\r\n let V = Math.max(r, g, b)\r\n let d = V - Math.min(r, g, b)\r\n\r\n let S = 0\r\n let H = 0\r\n if (d !== 0) {\r\n S = d / V\r\n if (V === r) {\r\n H = (g - b) / d + (g < b ? 6 : 0)\r\n H = (H % 6) * 60\r\n } else if (V === g) {\r\n H = (b - r) / d + 2\r\n H = H * 60\r\n } else {\r\n H = (r - g) / d + 4\r\n H = H * 60\r\n }\r\n }\r\n\r\n return { h: H, s: S, v: V }\r\n}\r\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ColorFormatter, RGBA } from './types';
|
|
2
|
-
export declare class CssStringFormat implements ColorFormatter<string> {
|
|
3
|
-
private components;
|
|
4
|
-
constructor(components: string[]);
|
|
5
|
-
parse(value: string): RGBA;
|
|
6
|
-
format(rgba: RGBA): string;
|
|
7
|
-
}
|
|
1
|
+
import { ColorFormatter, RGBA } from './types';
|
|
2
|
+
export declare class CssStringFormat implements ColorFormatter<string> {
|
|
3
|
+
private components;
|
|
4
|
+
constructor(components: string[]);
|
|
5
|
+
parse(value: string): RGBA;
|
|
6
|
+
format(rgba: RGBA): string;
|
|
7
|
+
}
|
|
8
8
|
//# sourceMappingURL=css-string-format.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class CssStringFormat {
|
|
2
|
+
constructor(components) {
|
|
3
|
+
this.components = components;
|
|
4
|
+
}
|
|
5
|
+
parse(value) {
|
|
6
|
+
value = value || 'rgba(0, 0, 0)';
|
|
7
|
+
const result = { r: 0, g: 0, b: 0, a: 1 };
|
|
8
|
+
const values = value
|
|
9
|
+
.replace(/[rgba\(\)]/gi, '')
|
|
10
|
+
.split(/,\s*?/gi)
|
|
11
|
+
.map(Number);
|
|
12
|
+
this.components.forEach((key, i) => {
|
|
13
|
+
result[key] = (values[i] || 0) / (key === 'a' ? 1 : 255);
|
|
14
|
+
});
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
format(rgba) {
|
|
18
|
+
return (this.components.join('') +
|
|
19
|
+
'(' +
|
|
20
|
+
this.components
|
|
21
|
+
.map((key) => {
|
|
22
|
+
return key === 'a' ? rgba[key] : Math.round(rgba[key] * 255);
|
|
23
|
+
})
|
|
24
|
+
.join(', ') +
|
|
25
|
+
')');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=css-string-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-string-format.js","sourceRoot":"","sources":["../../../src/lib/color-formats/css-string-format.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,eAAe;IAC1B,YAAoB,UAAoB;QAApB,eAAU,GAAV,UAAU,CAAU;IAAG,CAAC;IACrC,KAAK,CAAC,KAAa;QACxB,KAAK,GAAG,KAAK,IAAI,eAAe,CAAA;QAChC,MAAM,MAAM,GAAS,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA;QAC/C,MAAM,MAAM,GAAG,KAAK;aACjB,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;aAC3B,KAAK,CAAC,SAAS,CAAC;aAChB,GAAG,CAAC,MAAM,CAAC,CAAA;QACd,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;YACjC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QAC1D,CAAC,CAAC,CAAA;QACF,OAAO,MAAM,CAAA;IACf,CAAC;IAEM,MAAM,CAAC,IAAU;QACtB,OAAO,CACL,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,GAAG;YACH,IAAI,CAAC,UAAU;iBACZ,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;gBACX,OAAO,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAA;YAC9D,CAAC,CAAC;iBACD,IAAI,CAAC,IAAI,CAAC;YACb,GAAG,CACJ,CAAA;IACH,CAAC;CACF","sourcesContent":["import { ColorFormatter, RGBA } from './types'\r\n\r\nexport class CssStringFormat implements ColorFormatter<string> {\r\n constructor(private components: string[]) {}\r\n public parse(value: string) {\r\n value = value || 'rgba(0, 0, 0)'\r\n const result: RGBA = { r: 0, g: 0, b: 0, a: 1 }\r\n const values = value\r\n .replace(/[rgba\\(\\)]/gi, '')\r\n .split(/,\\s*?/gi)\r\n .map(Number)\r\n this.components.forEach((key, i) => {\r\n result[key] = (values[i] || 0) / (key === 'a' ? 1 : 255)\r\n })\r\n return result\r\n }\r\n\r\n public format(rgba: RGBA) {\r\n return (\r\n this.components.join('') +\r\n '(' +\r\n this.components\r\n .map((key) => {\r\n return key === 'a' ? rgba[key] : Math.round(rgba[key] * 255)\r\n })\r\n .join(', ') +\r\n ')'\r\n )\r\n }\r\n}\r\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ColorFormatter } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Gets a formatter implementation for the given format
|
|
4
|
-
*
|
|
5
|
-
* @public
|
|
6
|
-
* @param format - The format code
|
|
7
|
-
*/
|
|
8
|
-
export declare function getColorFormatter(format?: string): ColorFormatter<any>;
|
|
1
|
+
import { ColorFormatter } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Gets a formatter implementation for the given format
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
* @param format - The format code
|
|
7
|
+
*/
|
|
8
|
+
export declare function getColorFormatter(format?: string): ColorFormatter<any>;
|
|
9
9
|
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ArrayColorFormat } from './array-format';
|
|
2
|
+
import { CssStringFormat } from './css-string-format';
|
|
3
|
+
import { HexStringFormat } from './hex-string-format';
|
|
4
|
+
import { NumberColorFormat } from './number-format';
|
|
5
|
+
import { ObjectColorFormat } from './object-format';
|
|
6
|
+
const formatter = {};
|
|
7
|
+
/**
|
|
8
|
+
* Gets a formatter implementation for the given format
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
* @param format - The format code
|
|
12
|
+
*/
|
|
13
|
+
export function getColorFormatter(format = 'rgb') {
|
|
14
|
+
if (format in formatter) {
|
|
15
|
+
return formatter[format];
|
|
16
|
+
}
|
|
17
|
+
const components = (format.match(/[rgba]+/)[0] || '').split('');
|
|
18
|
+
if (/(\[n?\])/.test(format)) {
|
|
19
|
+
formatter[format] = new ArrayColorFormat(components, /\[n\]/.test(format));
|
|
20
|
+
}
|
|
21
|
+
else if (/(\{n?\})/.test(format)) {
|
|
22
|
+
formatter[format] = new ObjectColorFormat(components, /\{n\}/.test(format));
|
|
23
|
+
}
|
|
24
|
+
else if (/0x/.test(format)) {
|
|
25
|
+
formatter[format] = new NumberColorFormat(components);
|
|
26
|
+
}
|
|
27
|
+
else if (/(\(\))/.test(format)) {
|
|
28
|
+
formatter[format] = new CssStringFormat(components);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
formatter[format] = new HexStringFormat(components);
|
|
32
|
+
}
|
|
33
|
+
return formatter[format];
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../src/lib/color-formats/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAGnD,MAAM,SAAS,GAA2C,EAAE,CAAA;AAE5D;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB,KAAK;IACtD,IAAI,MAAM,IAAI,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC,MAAM,CAAC,CAAA;IAC1B,CAAC;IACD,MAAM,UAAU,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAC/D,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5E,CAAC;SAAM,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACnC,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,iBAAiB,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;IAC7E,CAAC;SAAM,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7B,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,iBAAiB,CAAC,UAAU,CAAC,CAAA;IACvD,CAAC;SAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,eAAe,CAAC,UAAU,CAAC,CAAA;IACrD,CAAC;SAAM,CAAC;QACN,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,eAAe,CAAC,UAAU,CAAC,CAAA;IACrD,CAAC;IACD,OAAO,SAAS,CAAC,MAAM,CAAC,CAAA;AAC1B,CAAC","sourcesContent":["import { ArrayColorFormat } from './array-format'\r\nimport { CssStringFormat } from './css-string-format'\r\nimport { HexStringFormat } from './hex-string-format'\r\nimport { NumberColorFormat } from './number-format'\r\nimport { ObjectColorFormat } from './object-format'\r\nimport { ColorFormatter } from './types'\r\n\r\nconst formatter: { [key: string]: ColorFormatter<any> } = {}\r\n\r\n/**\r\n * Gets a formatter implementation for the given format\r\n *\r\n * @public\r\n * @param format - The format code\r\n */\r\nexport function getColorFormatter(format: string = 'rgb'): ColorFormatter<any> {\r\n if (format in formatter) {\r\n return formatter[format]\r\n }\r\n const components = (format.match(/[rgba]+/)[0] || '').split('')\r\n if (/(\\[n?\\])/.test(format)) {\r\n formatter[format] = new ArrayColorFormat(components, /\\[n\\]/.test(format))\r\n } else if (/(\\{n?\\})/.test(format)) {\r\n formatter[format] = new ObjectColorFormat(components, /\\{n\\}/.test(format))\r\n } else if (/0x/.test(format)) {\r\n formatter[format] = new NumberColorFormat(components)\r\n } else if (/(\\(\\))/.test(format)) {\r\n formatter[format] = new CssStringFormat(components)\r\n } else {\r\n formatter[format] = new HexStringFormat(components)\r\n }\r\n return formatter[format]\r\n}\r\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ColorFormatter, RGBA } from './types';
|
|
2
|
-
export declare class HexStringFormat implements ColorFormatter<string> {
|
|
3
|
-
private components;
|
|
4
|
-
constructor(components: string[]);
|
|
5
|
-
parse(value?: string): RGBA;
|
|
6
|
-
format(rgba: RGBA): string;
|
|
7
|
-
}
|
|
1
|
+
import { ColorFormatter, RGBA } from './types';
|
|
2
|
+
export declare class HexStringFormat implements ColorFormatter<string> {
|
|
3
|
+
private components;
|
|
4
|
+
constructor(components: string[]);
|
|
5
|
+
parse(value?: string): RGBA;
|
|
6
|
+
format(rgba: RGBA): string;
|
|
7
|
+
}
|
|
8
8
|
//# sourceMappingURL=hex-string-format.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { padLeft } from '../core/utils';
|
|
2
|
+
export class HexStringFormat {
|
|
3
|
+
constructor(components) {
|
|
4
|
+
this.components = components;
|
|
5
|
+
}
|
|
6
|
+
parse(value) {
|
|
7
|
+
value = value || '#000';
|
|
8
|
+
const result = { r: 0, g: 0, b: 0, a: 1 };
|
|
9
|
+
let v = value.match(/[0-9a-f]+/i)[0];
|
|
10
|
+
if (v.length === this.components.length) {
|
|
11
|
+
v = v
|
|
12
|
+
.split('')
|
|
13
|
+
.map((it) => `${it}${it}`)
|
|
14
|
+
.join('');
|
|
15
|
+
}
|
|
16
|
+
this.components.forEach((key, i) => {
|
|
17
|
+
result[key] = parseInt(v.substr(i * 2, 2), 16) / 255;
|
|
18
|
+
});
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
format(rgba) {
|
|
22
|
+
return ('#' +
|
|
23
|
+
this.components
|
|
24
|
+
.map((key) => padLeft(Math.round(rgba[key] * 255).toString(16), 2, '0'))
|
|
25
|
+
.join(''));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=hex-string-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex-string-format.js","sourceRoot":"","sources":["../../../src/lib/color-formats/hex-string-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,MAAM,OAAO,eAAe;IAC1B,YAAoB,UAAoB;QAApB,eAAU,GAAV,UAAU,CAAU;IAAG,CAAC;IACrC,KAAK,CAAC,KAAc;QACzB,KAAK,GAAG,KAAK,IAAI,MAAM,CAAA;QACvB,MAAM,MAAM,GAAS,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA;QAC/C,IAAI,CAAC,GAAW,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;QAC5C,IAAI,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACxC,CAAC,GAAG,CAAC;iBACF,KAAK,CAAC,EAAE,CAAC;iBACT,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC;iBACzB,IAAI,CAAC,EAAE,CAAC,CAAA;QACb,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;YACjC,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAA;QACtD,CAAC,CAAC,CAAA;QACF,OAAO,MAAM,CAAA;IACf,CAAC;IAEM,MAAM,CAAC,IAAU;QACtB,OAAO,CACL,GAAG;YACH,IAAI,CAAC,UAAU;iBACZ,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;iBACvE,IAAI,CAAC,EAAE,CAAC,CACZ,CAAA;IACH,CAAC;CACF","sourcesContent":["import { padLeft } from '../core/utils'\r\nimport { ColorFormatter, RGBA } from './types'\r\n\r\nexport class HexStringFormat implements ColorFormatter<string> {\r\n constructor(private components: string[]) {}\r\n public parse(value?: string) {\r\n value = value || '#000'\r\n const result: RGBA = { r: 0, g: 0, b: 0, a: 1 }\r\n let v: string = value.match(/[0-9a-f]+/i)[0]\r\n if (v.length === this.components.length) {\r\n v = v\r\n .split('')\r\n .map((it) => `${it}${it}`)\r\n .join('')\r\n }\r\n this.components.forEach((key, i) => {\r\n result[key] = parseInt(v.substr(i * 2, 2), 16) / 255\r\n })\r\n return result\r\n }\r\n\r\n public format(rgba: RGBA) {\r\n return (\r\n '#' +\r\n this.components\r\n .map((key) => padLeft(Math.round(rgba[key] * 255).toString(16), 2, '0'))\r\n .join('')\r\n )\r\n }\r\n}\r\n"]}
|