JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://unpkg.com/wpe-lightning@1.10.0/dist/lightning.js"></script>
<div id="app"></div>
JavaScript
const IMG = "https://image.shutterstock.com/image-vector/example-signlabel-features-speech-bubble-260nw-1223219848.jpg";
function title(text) {
return {w: 150, text: { text: text, textColor: 0xff000000, fontSize: 24, shadowColor: 0xffffccaa, shadow: true, textAlign: 'center'}, shader: null}
}
class BaseTile extends lng.Component {
static _template() {
return {
w: 150,
h: 150,
src: IMG
}
}
}
class Combined extends lng.Component {
static _template() {
return {
w: 300, h: 300, rtt: true,
shader: {type: lng.shaders.Perspective, ry: 1.2},
Inner1: {
Title: title('Combined'),
shader: {type: lng.shaders.Vignette},
src: IMG
},
Inner2: {
w: 150, h: 150, y: 25,
rect: true,
color: 0x00000000,
shader: {type: lng.shaders.Spinner, width: 10, radius: 30, smooth: 0.05, color: 0xff558800},
}
}
}
_init() {
this.animation({
repeat: -1,
duration: 5,
actions: [{p: 'shader.ry', v: {0: 1.2, 0.5: 0.3, 1: 1.2}}]
}).start();
this.tag('Inner1').animation({
repeat: -1,
duration: 5,
actions: [{p: 'shader.magnitude', v: {0: 3.3, 0.5: 0.5, 1: 3.3}}]
}).start()
this.tag('Inner2').animation({
repeat: -1,
duration: 2,
actions: [
{p: 'x', v: {0: 0, 0.5: 100, 1: 0}},
]
}).start();
}
}
class Example extends lng.Application {
static _template() {
return {
flex: true,
Tile1: {
Title: title('Vignette'),
type: BaseTile,
shader: {
type: lng.shaders.Vignette,
}
},
Tile2: {
Title: title('Spinner'),
type: BaseTile,
shader: {
type: lng.shaders.Spinner,
smooth: 0.01,
radius: 30,
width: 10,
color: 0xffccffaa,
backgroundColor: 0x99000000,
},
},
Tile3: {
Title:...