Skip to content

Commit a15e1d1

Browse files
committed
create new homepage that displays animated logo
1 parent 8bca5b8 commit a15e1d1

File tree

6 files changed

+151
-3
lines changed

6 files changed

+151
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
[![](https://img.shields.io/npm/v/blobs.svg)](https://www.npmjs.com/package/blobs)
1515

16+
<!-- TODO make sure these don't look broken on npm-rendered markdown -->
17+
1618
```ts
1719
// $ npm install blobs
1820
import * as blobs2 from "blobs/v2";

assets/logo-color.svg

Lines changed: 1 addition & 1 deletion
Loading

assets/logo-grey.svg

Lines changed: 1 addition & 1 deletion
Loading

assets/logo-word-white.svg

Lines changed: 34 additions & 0 deletions
Loading

index.animated.html

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head lang="en">
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
6+
<title>blobs</title>
7+
<script src="./v2/animate/index.js"></script>
8+
</head>
9+
<body>
10+
<style>
11+
html,
12+
body,
13+
main {
14+
height: 100%;
15+
width: 100%;
16+
margin: 0;
17+
}
18+
19+
header {
20+
padding-top: 2rem;
21+
position: fixed;
22+
top: 0;
23+
text-align: center;
24+
width: 100%;
25+
}
26+
27+
a {
28+
color: #aaa;
29+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
30+
Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
31+
font-weight: 600;
32+
padding: 1rem;
33+
text-decoration: none;
34+
user-select: none;
35+
}
36+
37+
main {
38+
align-items: center;
39+
display: flex;
40+
justify-content: center;
41+
}
42+
43+
main canvas {
44+
cursor: pointer;
45+
}
46+
</style>
47+
48+
<header>
49+
<a href="mailto:gabrielj.harel@gmail.com">contact</a>
50+
<a href="https://github.com/g-harel/blobs">github</a>
51+
<a href="https://npmjs.com/package/blobs">npm</a>
52+
</header>
53+
54+
<main>
55+
<canvas id="canvas"></canvas>
56+
</main>
57+
58+
<script>
59+
// Set blob size relative to window, but limit to 600.
60+
const size = Math.min(600, window.innerWidth - 64);
61+
62+
// Fetch reference to canvas and resize dynamically.
63+
const canvas = document.getElementById("canvas");
64+
canvas.width = size;
65+
canvas.height = size;
66+
67+
// Set blob color and set context to erase intersection of content.
68+
const ctx = canvas.getContext("2d");
69+
ctx.fillStyle = "#ec576b";
70+
ctx.globalCompositeOperation = "xor";
71+
72+
// Use logo word asset to cut out from the generated blob.
73+
const logoWord = new Image();
74+
logoWord.src = "./assets/logo-word-white.svg";
75+
76+
// Create animation and draw its frames in `requestAnimationFrame` callbacks.
77+
const animation = blobs2Animate.canvasPath();
78+
const renderFrame = () => {
79+
ctx.clearRect(0, 0, size, size);
80+
ctx.drawImage(logoWord, size / 10, size / 10, (size * 4) / 5, (size * 4) / 5);
81+
ctx.fill(animation.renderFrame());
82+
requestAnimationFrame(renderFrame);
83+
};
84+
requestAnimationFrame(renderFrame);
85+
86+
// Generate a keyframe with overridable default values.
87+
const genFrame = (overrides) => ({
88+
duration: 4000,
89+
timingFunction: "easeInOut",
90+
callback: loopAnimation,
91+
blobOptions: {
92+
extraPoints: 3,
93+
randomness: 4,
94+
seed: Math.random(),
95+
size: size,
96+
},
97+
...overrides,
98+
});
99+
100+
// Callback for every frame which starts transition to a new frame.
101+
const loopAnimation = () => animation.transition(genFrame());
102+
103+
// Immediately show a shape.
104+
animation.transition(genFrame({duration: 0}));
105+
106+
// Quickly animate to a new frame when canvas is clicked.
107+
canvas.onclick = () => {
108+
animation.transition(genFrame({duration: 400, timingFunction: "elasticIn0"}));
109+
};
110+
</script>
111+
</body>
112+
</html>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"tslib": "^1.9.3",
3030
"typescript": "^3.1.3"
3131
},
32-
"homepage": "https://github.com/g-harel/blobs#readme",
32+
"homepage": "https://blobs.dev",
3333
"repository": {
3434
"type": "git",
3535
"url": "git+https://github.com/g-harel/blobs"

0 commit comments

Comments
 (0)