@rokkit/chart 1.0.0-next.36 → 1.0.0-next.38
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/package.json +12 -10
- package/src/chart/Chart.svelte +1 -1
- package/src/chart/FacetGrid.svelte +6 -6
- package/src/chart/Swatch.svelte +2 -3
- package/src/chart/TexturedShape.svelte +1 -1
- package/src/chart/TimelapseChart.svelte +2 -2
- package/src/elements/ColorRamp.svelte +1 -1
- package/src/elements/ContinuousLegend.svelte +1 -1
- package/src/index.js +1 -2
- package/src/lib/axis.js +8 -6
- package/src/{components/lib → lib}/chart.js +12 -0
- package/src/lib/color.js +59 -0
- package/src/lib/constants.js +41 -0
- package/src/lib/geom.js +106 -0
- package/src/lib/index.js +0 -0
- package/src/lib/{colors.js → palette.js} +3 -3
- package/src/{components/lib → lib}/pattern.js +4 -6
- package/src/lib/shape.js +46 -0
- package/src/{swatch.js → lib/swatch.js} +4 -4
- package/src/lib/utils.js +6 -0
- package/src/plots/BarPlot.svelte +1 -1
- package/src/plots/FunnelPlot.svelte +2 -3
- package/src/plots/HeatMapCalendar.svelte +1 -1
- package/src/plots/LinePlot.svelte +1 -1
- package/src/plots/Plot.svelte +1 -1
- package/src/plots/ScatterPlot.svelte +1 -1
- package/src/chart/Symbol.svelte +0 -40
- package/src/chart.js +0 -11
- package/src/components/index.js +0 -2
- package/src/components/lib/color.js +0 -327
- package/src/components/lib/index.js +0 -19
- package/src/components/lib/shape.js +0 -199
- package/src/components/lib/timer.js +0 -41
- package/src/components/lib/utils.js +0 -165
- package/src/constants.js +0 -66
- package/src/elements/PatternDefs.svelte +0 -13
- package/src/elements/PatternMask.svelte +0 -20
- package/src/elements/Symbol.svelte +0 -38
- package/src/funnel.svelte +0 -35
- package/src/geom.js +0 -105
- package/src/lib/shapes.js +0 -144
- package/src/plots/old_ScatterPlot.svelte +0 -20
- /package/src/chart/{Grid.svelte → AxisGrid.svelte} +0 -0
- /package/src/{components/lib → lib}/funnel.js +0 -0
- /package/src/{plots → lib}/heatmap.js +0 -0
- /package/src/{lookup.js → lib/lookup.js} +0 -0
- /package/src/{components/lib → lib}/rollup.js +0 -0
- /package/src/{components → lib}/store.js +0 -0
- /package/src/{components/lib → lib}/summary.js +0 -0
- /package/src/{components/lib → lib}/theme.js +0 -0
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
export const colors = [
|
|
2
|
-
'#FFDE6B',
|
|
3
|
-
'#EF89EE',
|
|
4
|
-
'#F79F1E',
|
|
5
|
-
'#02B8FF',
|
|
6
|
-
'#9F84EC',
|
|
7
|
-
'#15CBC4',
|
|
8
|
-
'#0092FD',
|
|
9
|
-
'#F63A57',
|
|
10
|
-
'#A2CB39',
|
|
11
|
-
'#FF6E2F',
|
|
12
|
-
'#FEB8B9',
|
|
13
|
-
'#af7aa1',
|
|
14
|
-
'#7EFFF5'
|
|
15
|
-
]
|
|
16
|
-
export const palette = {
|
|
17
|
-
indigo: {
|
|
18
|
-
50: '#eef2ff',
|
|
19
|
-
100: '#e0e7ff',
|
|
20
|
-
200: '#c7d2fe',
|
|
21
|
-
300: '#a5b4fc',
|
|
22
|
-
400: '#818cf8',
|
|
23
|
-
500: '#6366f1',
|
|
24
|
-
600: '#4f46e5',
|
|
25
|
-
700: '#4338ca',
|
|
26
|
-
800: '#3730a3',
|
|
27
|
-
900: '#312e81'
|
|
28
|
-
},
|
|
29
|
-
blue: {
|
|
30
|
-
50: '#eff6ff',
|
|
31
|
-
100: '#dbeafe',
|
|
32
|
-
200: '#bfdbfe',
|
|
33
|
-
300: '#93c5fd',
|
|
34
|
-
400: '#60a5fa',
|
|
35
|
-
500: '#3b82f6',
|
|
36
|
-
600: '#2563eb',
|
|
37
|
-
700: '#1d4ed8',
|
|
38
|
-
800: '#1e40af',
|
|
39
|
-
900: '#1e3a8a'
|
|
40
|
-
},
|
|
41
|
-
sky: {
|
|
42
|
-
50: '#f0f9ff',
|
|
43
|
-
100: '#e0f2fe',
|
|
44
|
-
200: '#bae6fd',
|
|
45
|
-
300: '#7dd3fc',
|
|
46
|
-
400: '#38bdf8',
|
|
47
|
-
500: '#0ea5e9',
|
|
48
|
-
600: '#0284c7',
|
|
49
|
-
700: '#0369a1',
|
|
50
|
-
800: '#075985',
|
|
51
|
-
900: '#0c4a6e'
|
|
52
|
-
},
|
|
53
|
-
cyan: {
|
|
54
|
-
50: '#ecfeff',
|
|
55
|
-
100: '#cffafe',
|
|
56
|
-
200: '#a5f3fc',
|
|
57
|
-
300: '#67e8f9',
|
|
58
|
-
400: '#22d3ee',
|
|
59
|
-
500: '#06b6d4',
|
|
60
|
-
600: '#0891b2',
|
|
61
|
-
700: '#0e7490',
|
|
62
|
-
800: '#155e75',
|
|
63
|
-
900: '#164e63'
|
|
64
|
-
},
|
|
65
|
-
teal: {
|
|
66
|
-
50: '#f0fdfa',
|
|
67
|
-
100: '#ccfbf1',
|
|
68
|
-
200: '#99f6e4',
|
|
69
|
-
300: '#5eead4',
|
|
70
|
-
400: '#2dd4bf',
|
|
71
|
-
500: '#14b8a6',
|
|
72
|
-
600: '#0d9488',
|
|
73
|
-
700: '#0f766e',
|
|
74
|
-
800: '#115e59',
|
|
75
|
-
900: '#134e4a'
|
|
76
|
-
},
|
|
77
|
-
emerald: {
|
|
78
|
-
50: '#ecfdf5',
|
|
79
|
-
100: '#d1fae5',
|
|
80
|
-
200: '#a7f3d0',
|
|
81
|
-
300: '#6ee7b7',
|
|
82
|
-
400: '#34d399',
|
|
83
|
-
500: '#10b981',
|
|
84
|
-
600: '#059669',
|
|
85
|
-
700: '#047857',
|
|
86
|
-
800: '#065f46',
|
|
87
|
-
900: '#064e3b'
|
|
88
|
-
},
|
|
89
|
-
green: {
|
|
90
|
-
50: '#f0fdf4',
|
|
91
|
-
100: '#dcfce7',
|
|
92
|
-
200: '#bbf7d0',
|
|
93
|
-
300: '#86efac',
|
|
94
|
-
400: '#4ade80',
|
|
95
|
-
500: '#22c55e',
|
|
96
|
-
600: '#16a34a',
|
|
97
|
-
700: '#15803d',
|
|
98
|
-
800: '#166534',
|
|
99
|
-
900: '#14532d'
|
|
100
|
-
},
|
|
101
|
-
lime: {
|
|
102
|
-
50: '#f7fee7',
|
|
103
|
-
100: '#ecfccb',
|
|
104
|
-
200: '#d9f99d',
|
|
105
|
-
300: '#bef264',
|
|
106
|
-
400: '#a3e635',
|
|
107
|
-
500: '#84cc16',
|
|
108
|
-
600: '#65a30d',
|
|
109
|
-
700: '#4d7c0f',
|
|
110
|
-
800: '#3f6212',
|
|
111
|
-
900: '#365314'
|
|
112
|
-
},
|
|
113
|
-
yellow: {
|
|
114
|
-
50: '#fefce8',
|
|
115
|
-
100: '#fef9c3',
|
|
116
|
-
200: '#fef08a',
|
|
117
|
-
300: '#fde047',
|
|
118
|
-
400: '#facc15',
|
|
119
|
-
500: '#eab308',
|
|
120
|
-
600: '#ca8a04',
|
|
121
|
-
700: '#a16207',
|
|
122
|
-
800: '#854d0e',
|
|
123
|
-
900: '#713f12'
|
|
124
|
-
},
|
|
125
|
-
amber: {
|
|
126
|
-
50: '#fffbeb',
|
|
127
|
-
100: '#fef3c7',
|
|
128
|
-
200: '#fde68a',
|
|
129
|
-
300: '#fcd34d',
|
|
130
|
-
400: '#fbbf24',
|
|
131
|
-
500: '#f59e0b',
|
|
132
|
-
600: '#d97706',
|
|
133
|
-
700: '#b45309',
|
|
134
|
-
800: '#92400e',
|
|
135
|
-
900: '#78350f'
|
|
136
|
-
},
|
|
137
|
-
orange: {
|
|
138
|
-
50: '#fff7ed',
|
|
139
|
-
100: '#ffedd5',
|
|
140
|
-
200: '#fed7aa',
|
|
141
|
-
300: '#fdba74',
|
|
142
|
-
400: '#fb923c',
|
|
143
|
-
500: '#f97316',
|
|
144
|
-
600: '#ea580c',
|
|
145
|
-
700: '#c2410c',
|
|
146
|
-
800: '#9a3412',
|
|
147
|
-
900: '#7c2d12'
|
|
148
|
-
},
|
|
149
|
-
red: {
|
|
150
|
-
50: '#fef2f2',
|
|
151
|
-
100: '#fee2e2',
|
|
152
|
-
200: '#fecaca',
|
|
153
|
-
300: '#fca5a5',
|
|
154
|
-
400: '#f87171',
|
|
155
|
-
500: '#ef4444',
|
|
156
|
-
600: '#dc2626',
|
|
157
|
-
700: '#b91c1c',
|
|
158
|
-
800: '#991b1b',
|
|
159
|
-
900: '#7f1d1d'
|
|
160
|
-
},
|
|
161
|
-
rose: {
|
|
162
|
-
50: '#fff1f2',
|
|
163
|
-
100: '#ffe4e6',
|
|
164
|
-
200: '#fecdd3',
|
|
165
|
-
300: '#fda4af',
|
|
166
|
-
400: '#fb7185',
|
|
167
|
-
500: '#f43f5e',
|
|
168
|
-
600: '#e11d48',
|
|
169
|
-
700: '#be123c',
|
|
170
|
-
800: '#9f1239',
|
|
171
|
-
900: '#881337'
|
|
172
|
-
},
|
|
173
|
-
pink: {
|
|
174
|
-
50: '#fdf2f8',
|
|
175
|
-
100: '#fce7f3',
|
|
176
|
-
200: '#fbcfe8',
|
|
177
|
-
300: '#f9a8d4',
|
|
178
|
-
400: '#f472b6',
|
|
179
|
-
500: '#ec4899',
|
|
180
|
-
600: '#db2777',
|
|
181
|
-
700: '#be185d',
|
|
182
|
-
800: '#9d174d',
|
|
183
|
-
900: '#831843'
|
|
184
|
-
},
|
|
185
|
-
fuchsia: {
|
|
186
|
-
50: '#fdf4ff',
|
|
187
|
-
100: '#fae8ff',
|
|
188
|
-
200: '#f5d0fe',
|
|
189
|
-
300: '#f0abfc',
|
|
190
|
-
400: '#e879f9',
|
|
191
|
-
500: '#d946ef',
|
|
192
|
-
600: '#c026d3',
|
|
193
|
-
700: '#a21caf',
|
|
194
|
-
800: '#86198f',
|
|
195
|
-
900: '#701a75'
|
|
196
|
-
},
|
|
197
|
-
purple: {
|
|
198
|
-
50: '#faf5ff',
|
|
199
|
-
100: '#f3e8ff',
|
|
200
|
-
200: '#e9d5ff',
|
|
201
|
-
300: '#d8b4fe',
|
|
202
|
-
400: '#c084fc',
|
|
203
|
-
500: '#a855f7',
|
|
204
|
-
600: '#9333ea',
|
|
205
|
-
700: '#7e22ce',
|
|
206
|
-
800: '#6b21a8',
|
|
207
|
-
900: '#581c87'
|
|
208
|
-
},
|
|
209
|
-
violet: {
|
|
210
|
-
50: '#f5f3ff',
|
|
211
|
-
100: '#ede9fe',
|
|
212
|
-
200: '#ddd6fe',
|
|
213
|
-
300: '#c4b5fd',
|
|
214
|
-
400: '#a78bfa',
|
|
215
|
-
500: '#8b5cf6',
|
|
216
|
-
600: '#7c3aed',
|
|
217
|
-
700: '#6d28d9',
|
|
218
|
-
800: '#5b21b6',
|
|
219
|
-
900: '#4c1d95'
|
|
220
|
-
},
|
|
221
|
-
warmGray: {
|
|
222
|
-
50: '#fafaf9',
|
|
223
|
-
100: '#f5f5f4',
|
|
224
|
-
200: '#e7e5e4',
|
|
225
|
-
300: '#d6d3d1',
|
|
226
|
-
400: '#a8a29e',
|
|
227
|
-
500: '#78716c',
|
|
228
|
-
600: '#57534e',
|
|
229
|
-
700: '#44403c',
|
|
230
|
-
800: '#292524',
|
|
231
|
-
900: '#1c1917'
|
|
232
|
-
},
|
|
233
|
-
trueGray: {
|
|
234
|
-
50: '#fafafa',
|
|
235
|
-
100: '#f5f5f5',
|
|
236
|
-
200: '#e5e5e5',
|
|
237
|
-
300: '#d4d4d4',
|
|
238
|
-
400: '#a3a3a3',
|
|
239
|
-
500: '#737373',
|
|
240
|
-
600: '#525252',
|
|
241
|
-
700: '#404040',
|
|
242
|
-
800: '#262626',
|
|
243
|
-
900: '#171717'
|
|
244
|
-
},
|
|
245
|
-
gray: {
|
|
246
|
-
50: '#fafafa',
|
|
247
|
-
100: '#f4f4f5',
|
|
248
|
-
200: '#e4e4e7',
|
|
249
|
-
300: '#d4d4d8',
|
|
250
|
-
400: '#a1a1aa',
|
|
251
|
-
500: '#71717a',
|
|
252
|
-
600: '#52525b',
|
|
253
|
-
700: '#3f3f46',
|
|
254
|
-
800: '#27272a',
|
|
255
|
-
900: '#18181b'
|
|
256
|
-
},
|
|
257
|
-
blueGray: {
|
|
258
|
-
50: '#f8fafc',
|
|
259
|
-
100: '#f1f5f9',
|
|
260
|
-
200: '#e2e8f0',
|
|
261
|
-
300: '#cbd5e1',
|
|
262
|
-
400: '#94a3b8',
|
|
263
|
-
500: '#64748b',
|
|
264
|
-
600: '#475569',
|
|
265
|
-
700: '#334155',
|
|
266
|
-
800: '#1e293b',
|
|
267
|
-
900: '#0f172a'
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export class ColorBrewer {
|
|
272
|
-
constructor() {
|
|
273
|
-
this.colors = ['blue', 'pink', 'teal', 'indigo', 'purple', 'amber', 'rose']
|
|
274
|
-
this.palette = palette
|
|
275
|
-
this.grayscale = this.palette['trueGray']
|
|
276
|
-
this.fill = 100
|
|
277
|
-
this.stroke = 600
|
|
278
|
-
this.contrast = 600
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
dark() {
|
|
282
|
-
this.fill = 500
|
|
283
|
-
this.stroke = 700
|
|
284
|
-
this.contrast = 100
|
|
285
|
-
return this
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
mix(fill, stroke, contrast) {
|
|
289
|
-
this.fill = Object.keys(this.grayscale).includes(fill) ? fill : this.fill
|
|
290
|
-
this.stroke = Object.keys(this.grayscale).includes(stroke)
|
|
291
|
-
? stroke
|
|
292
|
-
: this.stroke
|
|
293
|
-
this.contrast = Object.keys(this.grayscale).includes(contrast)
|
|
294
|
-
? contrast
|
|
295
|
-
: this.contrast
|
|
296
|
-
|
|
297
|
-
return this
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
swatch(colors) {
|
|
301
|
-
this.palette = colors
|
|
302
|
-
return this
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
filter(colors) {
|
|
306
|
-
this.colors = colors
|
|
307
|
-
return this
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
gray() {
|
|
311
|
-
return {
|
|
312
|
-
fill: this.grayscale[this.fill],
|
|
313
|
-
stroke: this.grayscale[this.stroke],
|
|
314
|
-
contrast: this.grayscale[this.contrast]
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
brew() {
|
|
319
|
-
const palette = this.colors.map((color) => ({
|
|
320
|
-
fill: this.palette[color][this.fill],
|
|
321
|
-
stroke: this.palette[color][this.stroke],
|
|
322
|
-
contrast: this.palette[color][this.contrast]
|
|
323
|
-
}))
|
|
324
|
-
|
|
325
|
-
return palette
|
|
326
|
-
}
|
|
327
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ChartBrewer } from './chart'
|
|
2
|
-
import { ColorBrewer } from './color'
|
|
3
|
-
import { ShapeBrewer } from './shape'
|
|
4
|
-
import { ThemeBrewer } from './theme'
|
|
5
|
-
import { PatternBrewer } from './pattern'
|
|
6
|
-
|
|
7
|
-
export { toHexString, swatch } from './utils'
|
|
8
|
-
export { uniques, slidingWindow } from './rollup'
|
|
9
|
-
export { colors } from './color'
|
|
10
|
-
|
|
11
|
-
export function brewer() {
|
|
12
|
-
return {
|
|
13
|
-
pattern: () => new PatternBrewer(),
|
|
14
|
-
color: () => new ColorBrewer(),
|
|
15
|
-
theme: () => new ThemeBrewer(),
|
|
16
|
-
shape: () => new ShapeBrewer(),
|
|
17
|
-
chart: (data, x, y) => new ChartBrewer(data, x, y)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { ColorBrewer } from './color'
|
|
2
|
-
|
|
3
|
-
export const namedShapes = {
|
|
4
|
-
square: (s) =>
|
|
5
|
-
`M${0.1 * s} 0` +
|
|
6
|
-
`A${0.1 * s} ${0.1 * s} 0 0 0 0 ${0.1 * s}V${0.9 * s}` +
|
|
7
|
-
`A${0.1 * s} ${0.1 * s} 0 0 0 ${0.1 * s} ${s}H${0.9 * s}` +
|
|
8
|
-
`A${0.1 * s} ${0.1 * s} 0 0 0 ${s} ${0.9 * s}V${0.1 * s}` +
|
|
9
|
-
`A${0.1 * s} ${0.1 * s} 0 0 0 ${0.9 * s} 0Z`,
|
|
10
|
-
circle: (s) =>
|
|
11
|
-
`M0 ${0.5 * s}` +
|
|
12
|
-
`A${0.5 * s} ${0.5 * s} 0 0 0 ${s} ${0.5 * s}` +
|
|
13
|
-
`A${0.5 * s} ${0.5 * s} 0 0 0 0 ${0.5 * s}`,
|
|
14
|
-
diamond: (s) =>
|
|
15
|
-
`M${0.5 * s} 0` +
|
|
16
|
-
`A${0.6 * s} ${0.6 * s} 0 0 0 ${s} ${0.5 * s}` +
|
|
17
|
-
`A${0.6 * s} ${0.6 * s} 0 0 0 ${0.5 * s} ${s}` +
|
|
18
|
-
`A${0.6 * s} ${0.6 * s} 0 0 0 0 ${0.5 * s}` +
|
|
19
|
-
`A${0.6 * s} ${0.6 * s} 0 0 0 ${0.5 * s} 0`,
|
|
20
|
-
triangle: (s) =>
|
|
21
|
-
`M${0.5 * s} ${0.0866 * s}L0 ${0.9234 * s}L${s} ${0.9234 * s}Z`,
|
|
22
|
-
rhombus: (s) =>
|
|
23
|
-
`M${0.5 * s} 0` +
|
|
24
|
-
`L${s} ${0.5 * s}` +
|
|
25
|
-
`L${0.5 * s} ${s}` +
|
|
26
|
-
`L0 ${0.5 * s}Z`,
|
|
27
|
-
star: (s) =>
|
|
28
|
-
`M${0.5 * s} ${0.05 * s}` +
|
|
29
|
-
`L${0.606 * s} ${0.36 * s}` +
|
|
30
|
-
`L${s} ${0.36 * s}` +
|
|
31
|
-
`L${0.685 * s} ${0.59 * s}` +
|
|
32
|
-
`L${0.81 * s} ${0.95 * s}` +
|
|
33
|
-
`L${0.5 * s} ${0.725 * s}` +
|
|
34
|
-
`L${0.19 * s} ${0.95 * s}` +
|
|
35
|
-
`L${0.315 * s} ${0.59 * s}` +
|
|
36
|
-
`L0 ${0.36 * s}` +
|
|
37
|
-
`L${0.394 * s} ${0.36 * s}Z`,
|
|
38
|
-
heart: (s) =>
|
|
39
|
-
`M${0.9 * s} ${0.5 * s}` +
|
|
40
|
-
`A${0.08 * s} ${0.08 * s} 0 0 0 ${0.5 * s} ${0.2 * s}` +
|
|
41
|
-
`A${0.08 * s} ${0.08 * s} 0 0 0 ${0.1 * s} ${0.5 * s}` +
|
|
42
|
-
`L${0.5 * s} ${0.9 * s}` +
|
|
43
|
-
`L${0.9 * s} ${0.5 * s}`,
|
|
44
|
-
shurikan: (s) =>
|
|
45
|
-
`M${0.3 * s} ${0.1 * s}L${0.5 * s} 0L${0.7 * s} ${0.1 * s}` +
|
|
46
|
-
`A ${0.05 * s} ${0.05 * s} 0 0 0 ${0.9 * s} ${0.35 * s}` +
|
|
47
|
-
`L${s} ${0.5 * s}L${0.9 * s} ${0.7 * s}` +
|
|
48
|
-
`A ${0.05 * s} ${0.05 * s} 0 0 0 ${0.7 * s} ${0.9 * s}` +
|
|
49
|
-
`L${0.5 * s} ${s}L${0.3 * s} ${0.9 * s}` +
|
|
50
|
-
`A${0.05 * s} ${0.05 * s} 0 0 0 ${0.1 * s} ${0.7 * s}` +
|
|
51
|
-
`L0 ${0.5 * s}L${0.1 * s} ${0.3 * s}` +
|
|
52
|
-
`A${0.05 * s} ${0.05 * s} 0 0 0 ${0.3 * s} ${0.1 * s}` +
|
|
53
|
-
`M${0.4 * s} ${0.5 * s}` +
|
|
54
|
-
`A${0.1 * s} ${0.1 * s} 0 0 0 ${0.6 * s} ${0.5 * s}` +
|
|
55
|
-
`A${0.1 * s} ${0.1 * s} 0 0 0 ${0.4 * s} ${0.5 * s}`,
|
|
56
|
-
target: (s) =>
|
|
57
|
-
`M${0.2 * s} ${0.5 * s}` +
|
|
58
|
-
`A${0.3 * s} ${0.3 * s} 0 0 0 ${0.8 * s} ${0.5 * s}` +
|
|
59
|
-
`A${0.3 * s} ${0.3 * s} 0 0 0 ${0.2 * s} ${0.5 * s}` +
|
|
60
|
-
`M0 ${0.5 * s}` +
|
|
61
|
-
`L${s} ${0.5 * s}` +
|
|
62
|
-
`M${0.5 * s} 0` +
|
|
63
|
-
`L${0.5 * s} ${s}`
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export const builtIn = [
|
|
67
|
-
...Object.keys(namedShapes).map((key) => ({ shape: namedShapes[key] })),
|
|
68
|
-
{
|
|
69
|
-
shape: (s) =>
|
|
70
|
-
`M${0.1 * s} ${0.1 * s}` +
|
|
71
|
-
`A${0.5 * s} ${0.5 * s} 0 0 0 ${0.9 * s} ${0.1 * s}` +
|
|
72
|
-
`A${0.5 * s} ${0.5 * s} 0 0 0 ${0.9 * s} ${0.9 * s}` +
|
|
73
|
-
`A${0.5 * s} ${0.5 * s} 0 0 0 ${0.1 * s} ${0.9 * s}` +
|
|
74
|
-
`A${0.5 * s} ${0.5 * s} 0 0 0 ${0.1 * s} ${0.1 * s}`
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
shape: (s) =>
|
|
78
|
-
`M${0.5 * s} ${0.3 * s}` +
|
|
79
|
-
`A${0.2 * s} ${0.1 * s} 0 0 0 ${0.5 * s} ${0.1 * s}` +
|
|
80
|
-
`L${0.5 * s} ${0.9 * s}` +
|
|
81
|
-
`M${0.5 * s} ${0.7 * s}` +
|
|
82
|
-
`A${0.2 * s} ${0.1 * s} 0 0 0 ${0.5 * s} ${0.9 * s}` +
|
|
83
|
-
`M${0.3 * s} ${0.5 * s}` +
|
|
84
|
-
`A${0.1 * s} ${0.2 * s} 0 0 0 ${0.1 * s} ${0.5 * s}` +
|
|
85
|
-
`L${0.9 * s} ${0.5 * s}` +
|
|
86
|
-
`M${0.7 * s} ${0.5 * s}` +
|
|
87
|
-
`A${0.1 * s} ${0.2 * s} 0 0 0 ${0.9 * s} ${0.5 * s}`
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
shape: (s) =>
|
|
91
|
-
`M${0.1 * s} ${0.3 * s}` +
|
|
92
|
-
`L${0.7 * s} ${0.9 * s}` +
|
|
93
|
-
`L${0.9 * s} ${0.7 * s}` +
|
|
94
|
-
`L${0.3 * s} ${0.1 * s}Z` +
|
|
95
|
-
`M${0.1 * s} ${0.7 * s}` +
|
|
96
|
-
`L${0.7 * s} ${0.1 * s}` +
|
|
97
|
-
`L${0.9 * s} ${0.3 * s}` +
|
|
98
|
-
`L${0.3 * s} ${0.9 * s}Z`
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
shape: (s) =>
|
|
102
|
-
`M${0.1 * s} ${0.4 * s}` +
|
|
103
|
-
`L${0.9 * s} ${0.4 * s}` +
|
|
104
|
-
`L${0.9 * s} ${0.6 * s}` +
|
|
105
|
-
`L${0.1 * s} ${0.6 * s}Z` +
|
|
106
|
-
`M${0.4 * s} ${0.1 * s}` +
|
|
107
|
-
`L${0.4 * s} ${0.9 * s}` +
|
|
108
|
-
`L${0.6 * s} ${0.9 * s}` +
|
|
109
|
-
`L${0.6 * s} ${0.1 * s}Z`
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
shape: (s) =>
|
|
113
|
-
`M${0.5 * s} ${0.05 * s}` +
|
|
114
|
-
`L${0.19 * s} ${0.95 * s}` +
|
|
115
|
-
`L${s} ${0.36 * s}` +
|
|
116
|
-
`L0 ${0.36 * s}` +
|
|
117
|
-
`L${0.81 * s} ${0.95 * s}Z`
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
shape: (s) =>
|
|
121
|
-
`M${0.1 * s} ${0.1 * s}` +
|
|
122
|
-
`L${0.1 * s} ${0.9 * s}` +
|
|
123
|
-
`L${0.9 * s} ${0.9 * s}` +
|
|
124
|
-
`L${0.9 * s} ${0.1 * s}Z` +
|
|
125
|
-
`M${0.1 * s} ${0.1 * s}` +
|
|
126
|
-
`L${0.1 * s} ${0.5 * s}` +
|
|
127
|
-
`L${0.5 * s} ${0.5 * s}` +
|
|
128
|
-
`L${0.5 * s} ${0.1 * s}Z` +
|
|
129
|
-
`M${0.5 * s} ${0.5 * s}` +
|
|
130
|
-
`L${0.5 * s} ${0.9 * s}` +
|
|
131
|
-
`L${0.9 * s} ${0.9 * s}` +
|
|
132
|
-
`L${0.9 * s} ${0.5 * s}Z`
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
shape: (s) =>
|
|
136
|
-
`M${0.5 * s} 0` +
|
|
137
|
-
`L${s} ${0.5 * s}` +
|
|
138
|
-
`L${0.5 * s} ${s}` +
|
|
139
|
-
`L0 ${0.5 * s}Z` +
|
|
140
|
-
`M${0.5 * s} 0` +
|
|
141
|
-
`L${s} ${0.5 * s}` +
|
|
142
|
-
`L${0.5 * s} ${s}Z`
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
shape: (s) =>
|
|
146
|
-
`M0 ${0.5 * s}` +
|
|
147
|
-
`A${0.6 * s} ${0.4 * s} 0 0 0 ${s} ${0.5 * s}` +
|
|
148
|
-
`A${0.6 * s} ${0.4 * s} 0 0 0 0 ${0.5 * s}` +
|
|
149
|
-
`M${0.5 * s} 0` +
|
|
150
|
-
`A${0.4 * s} ${0.6 * s} 0 0 0 ${0.5 * s} ${s}` +
|
|
151
|
-
`A${0.4 * s} ${0.6 * s} 0 0 0 ${0.5 * s} 0`
|
|
152
|
-
}
|
|
153
|
-
]
|
|
154
|
-
|
|
155
|
-
export class ShapeBrewer {
|
|
156
|
-
constructor() {
|
|
157
|
-
this.shapes = builtIn
|
|
158
|
-
this.repeat = false
|
|
159
|
-
this.indices = [...this.shapes.keys()]
|
|
160
|
-
this.gray = new ColorBrewer().gray()
|
|
161
|
-
this.shades = []
|
|
162
|
-
this.repeat = false
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
clear() {
|
|
166
|
-
this.shapes = []
|
|
167
|
-
return this
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
add(shape) {
|
|
171
|
-
const shapes = Array.isArray(shape) ? shape : [shape]
|
|
172
|
-
this.shapes = [...shapes]
|
|
173
|
-
|
|
174
|
-
return this
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
filter(indices) {
|
|
178
|
-
indices = Array.isArray(indices) ? indices : [indices]
|
|
179
|
-
this.indices = indices.filter((i) => i > 0 && i < this.shapes.length)
|
|
180
|
-
|
|
181
|
-
return this
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
colors(shades, repeat = false) {
|
|
185
|
-
this.shades = Array.isArray(shades) ? shades : [shades]
|
|
186
|
-
this.repeat = repeat
|
|
187
|
-
return this
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
brew() {
|
|
191
|
-
return this.indices
|
|
192
|
-
.map((i) => this.shapes[i])
|
|
193
|
-
.map((shape, i) => {
|
|
194
|
-
return i < this.shades.length || this.repeat
|
|
195
|
-
? { ...shape, ...this.shades[i % this.shades.length] }
|
|
196
|
-
: { ...shape, ...this.gray }
|
|
197
|
-
})
|
|
198
|
-
}
|
|
199
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { writable } from 'svelte/store'
|
|
2
|
-
|
|
3
|
-
let req
|
|
4
|
-
let prev
|
|
5
|
-
const elapsed = writable(0)
|
|
6
|
-
|
|
7
|
-
const tick = (timestamp) => {
|
|
8
|
-
if (!prev) prev = timestamp
|
|
9
|
-
const diff = Math.round(timestamp - prev)
|
|
10
|
-
prev = timestamp
|
|
11
|
-
elapsed.update((e) => e + diff)
|
|
12
|
-
req = window.requestAnimationFrame(tick)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const timer = {
|
|
16
|
-
start() {
|
|
17
|
-
if (typeof window === 'undefined') return
|
|
18
|
-
else if (!req) {
|
|
19
|
-
prev = null
|
|
20
|
-
req = window.requestAnimationFrame(tick)
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
stop() {
|
|
24
|
-
if (typeof window === 'undefined') return
|
|
25
|
-
else if (req) {
|
|
26
|
-
window.cancelAnimationFrame(req)
|
|
27
|
-
req = null
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
toggle() {
|
|
31
|
-
req ? timer.stop() : timer.start()
|
|
32
|
-
},
|
|
33
|
-
set(val) {
|
|
34
|
-
if (typeof val === 'number') elapsed.set(val)
|
|
35
|
-
},
|
|
36
|
-
reset() {
|
|
37
|
-
timer.set(0)
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export { timer, elapsed }
|