@lightningjs/blits 0.8.0 → 0.9.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/CHANGELOG.md +19 -0
- package/boilerplate/js/default/src/index.js +2 -8
- package/docs/README.md +0 -21
- package/docs/_sidebar.md +25 -13
- package/docs/built-in/directives.md +44 -0
- package/docs/{component_state.md → components/component_state.md} +37 -5
- package/docs/components/computed_properties.md +48 -0
- package/docs/{lifecycle_events.md → components/lifecycle_events.md} +4 -2
- package/docs/components/methods.md +47 -0
- package/docs/components/props.md +58 -0
- package/docs/{user_input.md → components/user_input.md} +31 -26
- package/docs/components/utilities.md +4 -0
- package/docs/components/watchers.md +36 -0
- package/docs/essentials/application_root.md +21 -0
- package/docs/{components.md → essentials/components.md} +17 -5
- package/docs/{displaying_images.md → essentials/displaying_images.md} +7 -7
- package/docs/essentials/displaying_text.md +77 -0
- package/docs/{element_attributes.md → essentials/element_attributes.md} +17 -12
- package/docs/essentials/template_syntax.md +85 -0
- package/docs/getting_started/file_structure.md +61 -0
- package/docs/getting_started/getting_started.md +47 -0
- package/docs/{introduction.md → getting_started/intro.md} +2 -1
- package/docs/sidebar.json +70 -26
- package/docs/transitions_animations/transitions.md +132 -0
- package/package.json +2 -3
- package/src/component.js +12 -3
- package/src/element.js +3 -0
- package/src/fontLoader.js +20 -21
- package/src/launch.d.ts +5 -6
- package/src/launch.js +12 -2
- package/src/lib/codegenerator/generator.js +2 -2
- package/src/lib/colors/colors.js +50 -40
- package/src/lib/colors/colors.test.js +149 -49
- package/src/lib/colors/htmlColors.js +149 -149
- package/src/lib/hooks.js +7 -7
- package/src/lib/lifecycle.js +3 -2
- package/src/lib/setup/base.js +19 -11
- package/src/lib/setup/state.js +1 -1
- package/src/lib/symbols.js +2 -0
- package/src/lib/templateparser/parser.js +50 -12
- package/src/lib/templateparser/parser.test.js +378 -71
- package/src/router/router.js +6 -6
- package/vite/msdfGenerator.js +1 -1
- package/boilerplate/js/default/src/fontloader.js +0 -4
- package/docs/computed_properties.md +0 -18
- package/docs/getting_started.md +0 -40
- package/docs/props.md +0 -46
- package/docs/template_syntax.md +0 -65
- package/docs/watchers.md +0 -38
- /package/docs/{text-to-speech-announcer.md → plugins/text-to-speech-announcer.md} +0 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Blits - Lightning 3 App Development Framework
|
|
2
|
+
|
|
3
|
+
## Transitions
|
|
4
|
+
|
|
5
|
+
So far we have explored how to create components and draw elements on the screen. But everything has
|
|
6
|
+
been rather static so far.
|
|
7
|
+
|
|
8
|
+
We did learn how to _reactively_ changes values and trigger rerenders based on that. So if you try the example below, you'll see that indeed our golden element changes position. But it just jumps from one place to another:
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
export default Blits('Gold', {
|
|
12
|
+
template: `
|
|
13
|
+
<Element color="gold" w="100" h="100" :x="$x" :y=:"$y" />
|
|
14
|
+
`,
|
|
15
|
+
state() {
|
|
16
|
+
return {
|
|
17
|
+
x: 0,
|
|
18
|
+
y: 0,
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
input: {
|
|
22
|
+
enter() {
|
|
23
|
+
this.x = this.x + 100
|
|
24
|
+
this.y = this.y + 50
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Using _transitions_ we really make our App come alive.
|
|
30
|
+
|
|
31
|
+
### Applying a transition
|
|
32
|
+
|
|
33
|
+
Blits offers an easy and intuitive way to apply transitions. All you need to do is add the `.transition` modifier to a reactive attribute, and now whenever you change the value referenced in the attribute, it will automatically _smooth_ into the new value.
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
export default Blits('Gold', {
|
|
37
|
+
template: `
|
|
38
|
+
<Element color="gold" w="100" h="100" :x.transiton="$x" :y.transition=:"$y" />
|
|
39
|
+
`,
|
|
40
|
+
state() {
|
|
41
|
+
return {
|
|
42
|
+
x: 0,
|
|
43
|
+
y: 0,
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
input: {
|
|
47
|
+
enter() {
|
|
48
|
+
this.x = this.x + 100
|
|
49
|
+
this.y = this.y + 50
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
If we try out the modified example above, you'll notice how difference adding a simple transition makes.
|
|
55
|
+
|
|
56
|
+
When the `.transition`-modifier is added to a reactive attribute, a default `ease-in` transition with a duration of `300ms` is applied
|
|
57
|
+
|
|
58
|
+
### Customizing transitions
|
|
59
|
+
|
|
60
|
+
While the default transition will look pretty good out of the box and is great for quickly improving the look of your App, you may want to customize specific transitions.
|
|
61
|
+
|
|
62
|
+
Blits gives you full control over your transitions, with a simple to use format, right inside your template.
|
|
63
|
+
|
|
64
|
+
Instead of referencing your component's state variable directly, you can also supply an inlien `object literal` in the attribute with a `.transition`-modifier. This will allow you to pass a number of options to change the way the transition will work.
|
|
65
|
+
|
|
66
|
+
The transition object must have a `value` key, which references the state variable (or prop or computed property) that triggers the transition.
|
|
67
|
+
|
|
68
|
+
Further more you can specify:
|
|
69
|
+
|
|
70
|
+
- `duration` - the duration of the transition in `ms`
|
|
71
|
+
- `delay` - the time in `ms` after which the transition should initiate
|
|
72
|
+
- `easing` - the easing function of the transition. Can be one of the defaults easing options listed below, or a custom `cubic-bezier` definitions (i.e. `cubic-bezier(0,1.35,.99,-0.07)`).
|
|
73
|
+
|
|
74
|
+
```xml
|
|
75
|
+
<Element color="gold" w="100" h="100"
|
|
76
|
+
:x.transiton="{value: $x, duration: 300, easing: 'ease-in-back', delay: 400}"
|
|
77
|
+
:y.transition=:"{value: $x, duration: 300, easing: 'cubic-bezier(1,-0.64,0.39,1.44)'}">
|
|
78
|
+
</Element>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Besides a reference to the `value`, you can also use dynamic values for the other keys in the transition object. This way you'll be able to dynamically control the delay, duration or easing function.
|
|
82
|
+
|
|
83
|
+
```xml
|
|
84
|
+
<Element color="gold" w="100" h="100"
|
|
85
|
+
:x.transiton="{value: $x, duration: $dynamicDuration, delay: $dynamicDelay}">
|
|
86
|
+
</Element>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### Available easing functions
|
|
90
|
+
|
|
91
|
+
- `ease-in`
|
|
92
|
+
- `ease-out`
|
|
93
|
+
- `ease-in-out`
|
|
94
|
+
- `ease-in-sine`
|
|
95
|
+
- `ease-out-sine`
|
|
96
|
+
- `ease-in-out-sine`
|
|
97
|
+
- `ease-in-cubic`
|
|
98
|
+
- `ease-out-cubic`
|
|
99
|
+
- `ease-in-out-cubic`
|
|
100
|
+
- `ease-in-circ`
|
|
101
|
+
- `ease-out-circ`
|
|
102
|
+
- `ease-in-out-circ`
|
|
103
|
+
- `ease-in-back`
|
|
104
|
+
- `ease-out-back`
|
|
105
|
+
- `ease-in-out-back`
|
|
106
|
+
|
|
107
|
+
### Listening to transition events
|
|
108
|
+
|
|
109
|
+
Sometimes you may want to perform an action when a transition ends or when it starts.
|
|
110
|
+
|
|
111
|
+
You can easily hook into these transiti)on events by adding a `start` and `end` key to the transition object. Both value should be a function (or a reference to a `method` on your component).
|
|
112
|
+
|
|
113
|
+
The `start` function will be called when the transition actually starts (after a possible specified delay) and the `end` function is called as soon as the transitions is finished.
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
export default Blits('Gold', {
|
|
117
|
+
template: `
|
|
118
|
+
<Element color="gold" w="100" h="100"
|
|
119
|
+
:x.transiton="{value: $x, start: $transitionBegin, end: $transitionEnd}"
|
|
120
|
+
/>
|
|
121
|
+
`,
|
|
122
|
+
///
|
|
123
|
+
methods: {
|
|
124
|
+
transitionBegin() {
|
|
125
|
+
//
|
|
126
|
+
},
|
|
127
|
+
transitionEnd() {
|
|
128
|
+
//
|
|
129
|
+
},
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightningjs/blits",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Blits: The Lightning 3 App Development Framework",
|
|
5
5
|
"bin": "bin/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -40,13 +40,12 @@
|
|
|
40
40
|
"husky": "^7.0.4",
|
|
41
41
|
"jsdom": "24.0.0",
|
|
42
42
|
"lint-staged": "^12.3.3",
|
|
43
|
-
"ora": "^7.0.1",
|
|
44
43
|
"prettier": "^2.5.1",
|
|
45
44
|
"tap-diff": "^0.1.1",
|
|
46
45
|
"tape": "^5.5.0"
|
|
47
46
|
},
|
|
48
47
|
"dependencies": {
|
|
49
|
-
"@lightningjs/renderer": "^0.7.
|
|
48
|
+
"@lightningjs/renderer": "^0.7.5",
|
|
50
49
|
"@lightningjs/vite-plugin-import-chunk-url": "^0.3.0",
|
|
51
50
|
"execa": "^8.0.1",
|
|
52
51
|
"kolorist": "^1.8.0",
|
package/src/component.js
CHANGED
|
@@ -40,6 +40,8 @@ import lifecycle from './lib/lifecycle.js'
|
|
|
40
40
|
import Settings from './settings.js'
|
|
41
41
|
import symbols from './lib/symbols.js'
|
|
42
42
|
|
|
43
|
+
let counter = 0
|
|
44
|
+
|
|
43
45
|
const stage = {
|
|
44
46
|
element,
|
|
45
47
|
}
|
|
@@ -56,10 +58,12 @@ const Component = (name = required('name'), config = required('config')) => {
|
|
|
56
58
|
config.code = codegenerator.call(config, parser(config.template, name, parentComponent))
|
|
57
59
|
}
|
|
58
60
|
|
|
61
|
+
component[symbols.identifier] = ++counter
|
|
62
|
+
|
|
59
63
|
setupBase(component, name)
|
|
60
64
|
|
|
61
65
|
// setup hooks
|
|
62
|
-
registerHooks(config.hooks,
|
|
66
|
+
registerHooks(config.hooks, component[symbols.identifier])
|
|
63
67
|
|
|
64
68
|
// setup props
|
|
65
69
|
// if (config.props) // because of the default props like id - might change this
|
|
@@ -97,7 +101,9 @@ const Component = (name = required('name'), config = required('config')) => {
|
|
|
97
101
|
setupComponent(parentComponent)
|
|
98
102
|
}
|
|
99
103
|
if (config.hooks && config.hooks.frameTick) {
|
|
100
|
-
renderer.on('frameTick', (r, data) =>
|
|
104
|
+
renderer.on('frameTick', (r, data) =>
|
|
105
|
+
emit('frameTick', component[symbols.identifier], this, [data])
|
|
106
|
+
)
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
this.parent = parentComponent
|
|
@@ -137,7 +143,10 @@ const Component = (name = required('name'), config = required('config')) => {
|
|
|
137
143
|
})
|
|
138
144
|
|
|
139
145
|
Object.defineProperty(this, symbols.originalState, {
|
|
140
|
-
value:
|
|
146
|
+
value: {
|
|
147
|
+
...((config.state && typeof config.state === 'function' && config.state.apply(this)) || {}),
|
|
148
|
+
...{ hasFocus: false },
|
|
149
|
+
},
|
|
141
150
|
writable: false,
|
|
142
151
|
enumerable: false,
|
|
143
152
|
configurable: false,
|
package/src/element.js
CHANGED
package/src/fontLoader.js
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WebTrFontFace, SdfTrFontFace } from '@lightningjs/renderer/core'
|
|
2
2
|
|
|
3
3
|
import Settings from './settings'
|
|
4
|
+
import { renderer } from './launch'
|
|
4
5
|
|
|
5
|
-
export default
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
stage.fontManager.addFontFace(
|
|
19
|
-
new SdfTrFontFace(font.family, {}, font.type, stage, font.png, font.json)
|
|
20
|
-
)
|
|
21
|
-
} else if (font.type === 'web') {
|
|
22
|
-
stage.fontManager.addFontFace(new WebTrFontFace(font.family, {}, font.file))
|
|
6
|
+
export default () => {
|
|
7
|
+
const stage = renderer.driver.stage
|
|
8
|
+
Settings.get('fonts', []).forEach((font) => {
|
|
9
|
+
if (font.type === 'sdf' || font.type === 'msdf') {
|
|
10
|
+
// automatically map png key to file name
|
|
11
|
+
if (!font.png && font.file) {
|
|
12
|
+
font.png = font.file.replace(/\.[^.]+$/, `.${font.type}.png`)
|
|
13
|
+
}
|
|
14
|
+
// automatically map json to file name
|
|
15
|
+
if (!font.json && font.file) {
|
|
16
|
+
font.json = font.file.replace(/\.[^.]+$/, `.${font.type}.json`)
|
|
23
17
|
}
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
stage.fontManager.addFontFace(
|
|
19
|
+
new SdfTrFontFace(font.family, {}, font.type, stage, font.png, font.json)
|
|
20
|
+
)
|
|
21
|
+
} else if (font.type === 'web') {
|
|
22
|
+
stage.fontManager.addFontFace(new WebTrFontFace(font.family, {}, font.file))
|
|
23
|
+
}
|
|
24
|
+
})
|
|
26
25
|
}
|
package/src/launch.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import ApplicationInstance from './application'
|
|
19
|
-
|
|
19
|
+
import {type Stage} from '@lightningjs/renderer'
|
|
20
20
|
interface WebFont {
|
|
21
21
|
/**
|
|
22
22
|
* Name of the font family
|
|
@@ -70,6 +70,9 @@ export type DebugLevel = 0 | 1 | 2
|
|
|
70
70
|
export type LogTypes = 'info' | 'warn' | 'error' | 'debug'
|
|
71
71
|
export type ReactivityModes = 'Proxy' | 'defineProperty'
|
|
72
72
|
|
|
73
|
+
interface ExtensionLoader {
|
|
74
|
+
async (stage: Stage): void
|
|
75
|
+
}
|
|
73
76
|
/**
|
|
74
77
|
* Settings
|
|
75
78
|
*
|
|
@@ -92,11 +95,7 @@ export interface Settings {
|
|
|
92
95
|
/**
|
|
93
96
|
* Debug level for console log messages
|
|
94
97
|
*/
|
|
95
|
-
debugLevel?: DebugLevel | LogTypes[]
|
|
96
|
-
/**
|
|
97
|
-
* Font loader file
|
|
98
|
-
*/
|
|
99
|
-
fontLoader?: any
|
|
98
|
+
debugLevel?: DebugLevel | LogTypes[],
|
|
100
99
|
/**
|
|
101
100
|
* Fonts to be used in the Application
|
|
102
101
|
*/
|
package/src/launch.js
CHANGED
|
@@ -21,6 +21,7 @@ import Settings from './settings.js'
|
|
|
21
21
|
import { initLog, Log } from './lib/log.js'
|
|
22
22
|
import { screenResolutions } from './lib/utils.js'
|
|
23
23
|
import colors from './lib/colors/colors.js'
|
|
24
|
+
import fontLoader from './fontLoader.js'
|
|
24
25
|
|
|
25
26
|
export let renderer
|
|
26
27
|
|
|
@@ -36,11 +37,20 @@ export default (App, target, settings) => {
|
|
|
36
37
|
// })
|
|
37
38
|
// : new MainCoreDriver()
|
|
38
39
|
|
|
40
|
+
if ('fontLoader' in settings) {
|
|
41
|
+
Log.warn(
|
|
42
|
+
`
|
|
43
|
+
|
|
44
|
+
Starting version 0.9.0 of Blits, the Launch setting \`fontLoader\` is not supported / required anymore.
|
|
45
|
+
You can remove the option from your \`src/index.js\`-file. And you can safely remove the file \`src/fontLoader.js\` from your project.
|
|
46
|
+
`
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
39
50
|
renderer = new RendererMain(
|
|
40
51
|
{
|
|
41
52
|
appWidth: settings.w || 1920,
|
|
42
53
|
appHeight: settings.h || 1080,
|
|
43
|
-
coreExtensionModule: settings.fontLoader,
|
|
44
54
|
fpsUpdateInterval: settings.fpsInterval || 1000,
|
|
45
55
|
deviceLogicalPixelRatio:
|
|
46
56
|
settings.pixelRatio ||
|
|
@@ -68,5 +78,5 @@ export default (App, target, settings) => {
|
|
|
68
78
|
}
|
|
69
79
|
}
|
|
70
80
|
|
|
71
|
-
renderer.init().then((
|
|
81
|
+
renderer.init().then(fontLoader).then(initApp)
|
|
72
82
|
}
|
|
@@ -223,7 +223,7 @@ const generateForLoopCode = function (templateObject, parent) {
|
|
|
223
223
|
parent = ${parent}
|
|
224
224
|
if(!component.key) keys.length = 0
|
|
225
225
|
const scope = Object.assign(component, {
|
|
226
|
-
key: Math.random(),
|
|
226
|
+
key: Math.random().toString(),
|
|
227
227
|
${index}: __index,
|
|
228
228
|
${item}: collection[__index],
|
|
229
229
|
`)
|
|
@@ -241,7 +241,7 @@ const generateForLoopCode = function (templateObject, parent) {
|
|
|
241
241
|
|
|
242
242
|
if ('key' in templateObject) {
|
|
243
243
|
ctx.renderCode.push(`
|
|
244
|
-
keys.push(${interpolate(templateObject.key, 'scope.')})
|
|
244
|
+
keys.push(${interpolate(templateObject.key, 'scope.')}.toString())
|
|
245
245
|
`)
|
|
246
246
|
} else {
|
|
247
247
|
ctx.renderCode.push(`
|
package/src/lib/colors/colors.js
CHANGED
|
@@ -19,52 +19,62 @@ import htmlColors from './htmlColors.js'
|
|
|
19
19
|
import { Log } from '../log.js'
|
|
20
20
|
|
|
21
21
|
export default {
|
|
22
|
-
|
|
22
|
+
// The defaultColor parameter should be set to null when utilizing this function within the template parser.
|
|
23
|
+
// Because the template parser evaluates attribute values, even if they are not color codes,
|
|
24
|
+
// to determine whether they represent color values or not.
|
|
25
|
+
normalize(color = '', defaultColor = '0xffffffff') {
|
|
23
26
|
color = color.toString()
|
|
24
27
|
|
|
25
|
-
if (color.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
if (color.length > 0) {
|
|
29
|
+
const normalized = /^0x[0-9a-f]{8}$/
|
|
30
|
+
const hex = /^#?([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i
|
|
31
|
+
const rgba =
|
|
32
|
+
/^(rgba?)\((\s*(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\s*),(\s*(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\s*),(\s*(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\s*)(,(\s*(-?\d+(?:\.\d+)?)\s*))?\)$/
|
|
33
|
+
const hsla =
|
|
34
|
+
/^(hsla?)\((\s*(360|3[0-5][0-9]|[12]?[0-9]{1,2})\s*),(\s*(100|[1-9]?[0-9])\s*)%,(\s*(100|[1-9]?[0-9])\s*)%(,(\s*(1|0(?:\.\d+)?)\s*))?\)$/
|
|
35
|
+
|
|
36
|
+
if (normalized.test(color)) {
|
|
37
|
+
return color
|
|
38
|
+
}
|
|
28
39
|
|
|
29
|
-
|
|
30
|
-
|
|
40
|
+
if (hex.test(color)) {
|
|
41
|
+
color = color.replace('#', '').toLowerCase()
|
|
42
|
+
if (color.length === 3) {
|
|
43
|
+
color = color
|
|
44
|
+
.split('')
|
|
45
|
+
.map((c) => c + c)
|
|
46
|
+
.join('')
|
|
47
|
+
}
|
|
31
48
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
return '0x' + color.padEnd(8, 'f')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//rgb/a
|
|
53
|
+
const rgbaMatch = rgba.exec(color)
|
|
54
|
+
if (rgbaMatch) {
|
|
55
|
+
return (
|
|
56
|
+
'0x' +
|
|
57
|
+
parseInt(rgbaMatch[3]).toString(16).padStart(2, '0') +
|
|
58
|
+
parseInt(rgbaMatch[5]).toString(16).padStart(2, '0') +
|
|
59
|
+
parseInt(rgbaMatch[7]).toString(16).padStart(2, '0') +
|
|
60
|
+
(rgbaMatch[10] && rgbaMatch[1] === 'rgba'
|
|
61
|
+
? Math.min(Math.max(Math.round(parseFloat(rgbaMatch[10]) * 255), 0), 255)
|
|
62
|
+
.toString(16)
|
|
63
|
+
.padStart(2, '0')
|
|
64
|
+
: 'ff')
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (hsla.test(color)) {
|
|
69
|
+
Log.warn('HSL(A) color format is not supported yet')
|
|
70
|
+
return '0xffffffff'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (color in htmlColors) {
|
|
74
|
+
return htmlColors[color]
|
|
46
75
|
}
|
|
47
|
-
}
|
|
48
|
-
// HSL(A) color format
|
|
49
|
-
else if (hslaRegex.test(color)) {
|
|
50
|
-
Log.warn('HSL(A) color format is not supported yet')
|
|
51
|
-
return 0xffffffff
|
|
52
|
-
}
|
|
53
|
-
// HTMl name color format
|
|
54
|
-
else if (color in htmlColors) {
|
|
55
|
-
return htmlColors[color]
|
|
56
|
-
}
|
|
57
|
-
// hex rgba format
|
|
58
|
-
else if (color.startsWith('#')) {
|
|
59
|
-
color = color.substring(1)
|
|
60
|
-
}
|
|
61
|
-
if (color.length === 3) {
|
|
62
|
-
color = color
|
|
63
|
-
.split('')
|
|
64
|
-
.map((c) => c + c)
|
|
65
|
-
.join('')
|
|
66
76
|
}
|
|
67
77
|
|
|
68
|
-
return
|
|
78
|
+
return defaultColor
|
|
69
79
|
},
|
|
70
80
|
}
|