Skip to content

Commit db34aae

Browse files
committed
animate handle length in bezier demo
1 parent 0cf029a commit db34aae

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

demo/content.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,18 @@ addCanvas(2, (ctx, width, height, animate) => {
130130
const startPeriod = Math.E * 1000;
131131
const endPeriod = Math.PI * 1000;
132132

133-
// TODO animate handle length.
134133
animate((frameTime) => {
135134
const startPercentage = calcBouncePercentage(startPeriod, timingFunctions.ease, frameTime);
136135
const startAngle = split(startPercentage, -45, +45);
137-
const start = point(width * 0.2, height * 0.5, 0, 0, startAngle, width * 0.25);
136+
const startLengthPercentage = mod(startPercentage * 0.8, 1);
137+
const startLength = width * 0.2 + width * 0.1 * startLengthPercentage;
138+
const start = point(width * 0.2, height * 0.5, 0, 0, startAngle, startLength);
138139

139140
const endPercentage = calcBouncePercentage(endPeriod, timingFunctions.ease, frameTime);
140141
const endAngle = split(endPercentage, 135, 225);
141-
const end = point(width * 0.8, height * 0.5, endAngle, width * 0.25, 0, 0);
142+
const endLengthPercentage = mod(endPercentage * 0.8, 1);
143+
const endLength = width * 0.2 + width * 0.1 * endLengthPercentage;
144+
const end = point(width * 0.8, height * 0.5, endAngle, endLength, 0, 0);
142145

143146
drawOpen(ctx, start, end, true);
144147
});

demo/example.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import {CanvasKeyframe, canvasPath} from "../public/animate";
22
import {colors} from "./internal/layout";
33

4-
// TODO add click me prompt before clicked.
5-
64
// Fetch reference to example container.
75
const exampleContainer = document.querySelector(".example")!;
86

demo/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
height: 6rem;
2525
}
2626

27-
header nav a, .how-it-works {
27+
header nav a,
28+
.how-it-works {
2829
color: #aaa;
2930
display: inline-block;
3031
font-size: 0.7rem;

demo/internal/debug.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// If debug is initially set to false it will not be toggleable.
22
let debug = true;
3-
export const isDebug = () => {
4-
return debug;
5-
};
3+
export const isDebug = () => debug;
64

75
const debugListeners: ((debug: boolean) => void)[] = [];
86
export const onDebugStateChange = (fn: (debug: boolean) => void) => {

0 commit comments

Comments
 (0)