Optimize parallax

This commit is contained in:
Schmelczer András 2019-12-25 22:30:44 +01:00
parent 5a87d2db71
commit da9d0a1136
15 changed files with 135 additions and 207 deletions

View file

@ -1,25 +1,23 @@
import { html } from "../../model/misc";
import "./background.scss";
import { fixedSeedRandom } from "../../framework/helper";
export const generate = (
count: number,
probability: number,
width: number,
color: string,
translateZ: number
color?: () => string,
height?: () => number,
transform?: () => string
): html => `
<section class="background">
${new Array(count)
.fill(0, 0, count)
.map(_ =>
fixedSeedRandom() < probability
? `<div style="width: ${width}px; height: ${width *
(fixedSeedRandom() + 0.1) *
10}px; background-color: ${color}; transform: translateZ(${translateZ}px) rotate(-20deg);"
></div>`
: `<div class="gap"></div>`
)
.join("")}
${
count > 0
? new Array(count)
.fill(0, 0, count)
.map(
_ =>
`<div style="background-color: ${color()}; height: ${height()}px; transform: ${transform()}"></div>`
)
.join("")
: ""
}
</section>
`;