@lightningjs/blits 1.14.1 → 1.16.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 +16 -0
- package/docs/essentials/element_attributes.md +32 -0
- package/package.json +1 -1
- package/src/components/Circle.js +12 -1
- package/src/components/FPScounter.js +325 -42
- package/src/components/RouterView.js +12 -1
- package/src/components/Sprite.js +15 -4
- package/src/components/Sprite.orig.js +3 -3
- package/src/engines/L3/element.js +31 -0
- package/src/engines/L3/element.test.js +138 -4
- package/src/lib/codegenerator/generator.js +53 -17
- package/src/lib/reactivity/reactive.js +8 -8
- package/vite/blitsFileConverter.js +37 -8
- package/vite/preCompiler.js +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.16.0
|
|
4
|
+
|
|
5
|
+
_16 jan 2025_
|
|
6
|
+
|
|
7
|
+
- Fixed issue with component scope in Slots
|
|
8
|
+
- Fixed issue with sprites (regression since v1.14.0)
|
|
9
|
+
- Changed reactive state to only make plain objects reactive, and return custom Classes, Blits components, Renderer texture etc in raw form
|
|
10
|
+
|
|
11
|
+
## v1.15.0
|
|
12
|
+
|
|
13
|
+
_14 jan 2025_
|
|
14
|
+
|
|
15
|
+
- Added `placement`-attribute for easily aligning Elements to predefined locations (i.e. `center`, `right`, `middle`, `bottom`)
|
|
16
|
+
- Removed automatic injection of `index` variable into forloop-scope to prevent unexpected naming collisions
|
|
17
|
+
|
|
18
|
+
|
|
3
19
|
## v1.14.1
|
|
4
20
|
|
|
5
21
|
_8 jan 2025_
|
|
@@ -36,6 +36,38 @@ Besides using values in pixels (i.e. `w="100" h="300"`), you can also specify _p
|
|
|
36
36
|
The percentage value specified for `w` and `x` will be calculated as the percentage of the _width_ (`w`) of the parent element.
|
|
37
37
|
And the percentage specified for `h` and `y` will use the _height_ (`h`) of the parent element as the base of the percentage calculation.
|
|
38
38
|
|
|
39
|
+
### Predefined placement options
|
|
40
|
+
|
|
41
|
+
In addition to the absolute positions that Blits and Lightning use, there are a few predefined placement options available. By adding the `placement`-attribute to an Element we can easily align it to the _center_, _left_, _right_, _top_, _bottom_, or even a combination like `{y: 'middle', x: 'left'}`, without having to calculate the positions yourself.
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
On the `x`-axis the following _placement_ options can be used: `left` (default), `center` and `right`. On the `y`-axis the _placement_ attribute accepts `top` (default), `middle` and `bottom`.
|
|
45
|
+
|
|
46
|
+
The _placement_ attribute also accepts and object with an `x` and a `y` key, to specify a placement for both axes.
|
|
47
|
+
|
|
48
|
+
The placement of an Element is calculated based on the dimensions of it's direct parent. This means that the containing Element _must_ have it's own dimensions (i.e. a `w` and a `h` attribute).
|
|
49
|
+
|
|
50
|
+
```xml
|
|
51
|
+
<Element w="300" h="300">
|
|
52
|
+
<!-- x placement -->
|
|
53
|
+
<Element w="40" h="40" placement="left" color="#818cf8" />
|
|
54
|
+
<Element w="40" h="40" placement="center" color="#2563eb" />
|
|
55
|
+
<Element w="40" h="40" placement="right" color="#1e40af" />
|
|
56
|
+
|
|
57
|
+
<!-- y placement -->
|
|
58
|
+
<Element w="40" h="40" x="54" placement="top" color="#f472b6" />
|
|
59
|
+
<Element w="40" h="40" x="54" placement="middle" color="#db2777" />
|
|
60
|
+
<Element w="40" h="40" x="54" placement="bottom" color="#be185d" />
|
|
61
|
+
|
|
62
|
+
<!-- x/y placement -->
|
|
63
|
+
<Element w="40" h="40" placement="{x: 'center', y: 'bottom'}" color="#a3e635" />
|
|
64
|
+
<Element w="40" h="40" placement="{x: 'right', y: 'middle'}" color="#65a30d" />
|
|
65
|
+
<Element w="40" h="40" placement="{x: 'center', y: 'middle'}" color="#4d7c0f" />
|
|
66
|
+
</Element>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> note: the `x` or `y` attributes on the Element are ignored for those axes defined in the `placement`-attribute
|
|
70
|
+
|
|
39
71
|
## Colors
|
|
40
72
|
|
|
41
73
|
By default, Elements have a transparent background color. The `color` attribute can be used to give an Element a color.
|
package/package.json
CHANGED
package/src/components/Circle.js
CHANGED
|
@@ -26,15 +26,26 @@ export default () =>
|
|
|
26
26
|
let componentType
|
|
27
27
|
const rootComponent = component
|
|
28
28
|
let propData
|
|
29
|
+
let slotComponent
|
|
30
|
+
let inSlot = false
|
|
31
|
+
let slotChildCounter = 0
|
|
29
32
|
const elementConfig0 = {}
|
|
30
33
|
|
|
31
|
-
elms[0] = this.element(
|
|
34
|
+
elms[0] = this.element(
|
|
35
|
+
{ parent: parent || 'root' },
|
|
36
|
+
inSlot === true ? slotComponent : component
|
|
37
|
+
)
|
|
32
38
|
|
|
33
39
|
elementConfig0['color'] = component.color
|
|
34
40
|
elementConfig0['w'] = component.size
|
|
35
41
|
elementConfig0['h'] = component.size
|
|
36
42
|
elementConfig0['effects'] = [component.shader('radius', { radius: component.radius })]
|
|
37
43
|
elms[0].populate(elementConfig0)
|
|
44
|
+
|
|
45
|
+
if (inSlot === true) {
|
|
46
|
+
slotChildCounter -= 1
|
|
47
|
+
}
|
|
48
|
+
|
|
38
49
|
return elms
|
|
39
50
|
},
|
|
40
51
|
effects: [
|