This commit is contained in:
mehbark 2023-11-15 03:00:23 -05:00
parent e47c310ce5
commit e3bb900bab
2 changed files with 12 additions and 17 deletions

View file

@ -231,6 +231,7 @@ export const svg_url = (svg: string) => `data:image/svg+xml,${encodeURI(svg)}`;
// something higher-level might be worthwhile... // something higher-level might be worthwhile...
// could namespace; e.g. css.font.sans_serif // could namespace; e.g. css.font.sans_serif
// could put various beziers
export const css = { export const css = {
url(href: string) { url(href: string) {
return `url('${href}')`; return `url('${href}')`;

View file

@ -1,24 +1,18 @@
import { render_and_copy } from "./common.tsx"; import { render_and_copy } from "./common.tsx";
const Drop = ({ const Drop = ({ color = "red", i }: { color?: string; i: number }) => (
color = "red",
i,
duration_s,
}: {
color?: string;
i: number;
duration_s: number;
}) => (
<div <div
style={{ style={{
backgroundColor: color, backgroundColor: color,
animation: `${(Math.random() + 1).toFixed(2)}s linear ${( animation: `${(Math.random() * 2 + 5).toFixed(
-Math.random() * 10 2
).toFixed(2)}s spin alternate-reverse infinite`, )}s cubic-bezier(.55,.09,.68,.53) ${(-Math.random() * 10).toFixed(
2
)}s spin infinite reverse`,
gridRow: "1", gridRow: "1",
gridColumn: `${i}`, gridColumn: `${i}`,
width: "0.1rem", width: "1px",
height: "0.1rem", height: "1px",
marginTop: "-1rem", marginTop: "-1rem",
transform: "translateY(20rem)", transform: "translateY(20rem)",
}} }}
@ -39,7 +33,7 @@ const Water = ({
gridRow: "1 / 2", gridRow: "1 / 2",
gridColumn: "1 / 100000", gridColumn: "1 / 100000",
transform: "translateY(100%)", transform: "translateY(100%)",
animation: `${duration_s}s linear 0s alternate infinite spin`, animation: `${duration_s}s linear 0s 1 spin forwards`,
}} }}
></div> ></div>
); );
@ -64,10 +58,10 @@ const Rain = ({
}} }}
> >
{...Array.from({ length: drops }, (_, i) => ( {...Array.from({ length: drops }, (_, i) => (
<Drop i={i} duration_s={duration_s} color={color} /> <Drop i={i} color={color} />
))} ))}
<Water color={color} duration_s={duration_s} /> <Water color={color} duration_s={duration_s} />
</div> </div>
); );
render_and_copy(<Rain duration_s={5} />); render_and_copy(<Rain duration_s={600} drops={150} />);