Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 318bc74

Browse files
committed
add wiggle animation to readme
1 parent 137fc75 commit 318bc74

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

‎README.md

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,37 +98,46 @@ ctx.stroke(path);
9898
const ctx = /* ... */;
9999
const animation = blobs2Animate.canvasPath();
100100

101-
TODO wiggle
102-
103-
// Set up "requestAnimationFrame" rendering loop.
101+
// Set up rendering loop.
104102
const renderAnimation = () => {
105103
ctx.clearRect(0, 0, width, height);
106104
ctx.fill(animation.renderFrame());
107105
requestAnimationFrame(renderAnimation);
108106
};
109107
requestAnimationFrame(renderAnimation);
110108

111-
// Keyframe loop.
112-
constloopAnimation = () => {
109+
// Transition to new blob on canvas click.
110+
ctx.canvas.onclick = () => {
113111
animation.transition({
114112
duration: 4000,
115113
timingFunction: "ease",
116114
callback: loopAnimation,
117115
blobOptions: {...},
118116
});
119117
};
118+
```
120119

121-
// Initial frame.
122-
animation.transition({
123-
duration: 0, // Render immediately.
124-
callback: loopAnimation,
125-
blobOptions: {...},
126-
});
120+
## Canvas Wiggle
127121

128-
// Toggle play/pause animation on canvas click.
129-
ctx.canvas.onclick = () => {
130-
animation.playPause();
122+
```js
123+
const ctx = /* ... */;
124+
const animation = blobs2Animate.canvasPath();
125+
126+
// Set up rendering loop.
127+
const renderAnimation = () => {
128+
ctx.clearRect(0, 0, width, height);
129+
ctx.fill(animation.renderFrame());
130+
requestAnimationFrame(renderAnimation);
131131
};
132+
requestAnimationFrame(renderAnimation);
133+
134+
// Begin wiggle animation.
135+
blobs2Animate.wigglePreset(
136+
animation
137+
/* blobOptions= */ {...},
138+
/* canvasOptions= */ {},
139+
/* wiggleOptions= */ {speed: 2},
140+
)
132141
```
133142

134143
## Complete API

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /