|
1 | | -import blobs from "../../../legacy/blobs"; |
2 | | - |
3 | 1 | import {interpolateBetweenLoop} from "../interpolate"; |
4 | 2 | import {divideShape, prepShapes} from "../prepare"; |
5 | 3 | import {Coord, Point, Shape} from "../../types"; |
6 | 4 | import {length, insertAt, insertCount, rad, mod} from "../../util"; |
7 | 5 | import {clear, drawInfo, drawShape} from "../../render/canvas"; |
| 6 | +import {genBlob} from "../../blobs"; |
| 7 | +import {rand} from "../../rand"; |
8 | 8 |
|
9 | 9 | const animationSpeed = 2; |
10 | 10 | const animationStart = 0.3; |
@@ -103,38 +103,32 @@ const testInterpolateBetween = (percentage: number) => { |
103 | 103 | }; |
104 | 104 |
|
105 | 105 | const testPrepShapesA = (percentage: number) => { |
106 | | - const a = genBlob("a", 0.6, 0.6, 0.3, {x: 0.5, y: 0.2}); |
107 | | - const b = genBlob("b", 1, 0.6, 0.3, {x: 0.5, y: 0.2}); |
| 106 | + const a = blob("a", 6, 0.2, {x: 0.5, y: 0.2}); |
| 107 | + const b = blob("b", 10, 0.2, {x: 0.5, y: 0.2}); |
108 | 108 | drawShape(ctx, debug, interpolateBetweenLoop(percentage, ...prepShapes(a, b))); |
109 | 109 | }; |
110 | 110 |
|
111 | 111 | const testPrepShapesB = (percentage: number) => { |
112 | | - const a = genBlob("a", 0.6, 0.6, 0.3, {x: 0.5, y: 0.5}); |
| 112 | + const a = blob("a", 8, 0.2, {x: 0.5, y: 0.5}); |
113 | 113 | const b: Shape = [ |
114 | | - point(0.55, 0.5, 0, 0, 0, 0), |
115 | | - point(0.75, 0.5, 0, 0, 0, 0), |
116 | | - point(0.75, 0.7, 0, 0, 0, 0), |
117 | | - point(0.55, 0.7, 0, 0, 0, 0), |
| 114 | + point(0.5, 0.5, 0, 0, 0, 0), |
| 115 | + point(0.7, 0.5, 0, 0, 0, 0), |
| 116 | + point(0.7, 0.7, 0, 0, 0, 0), |
| 117 | + point(0.5, 0.7, 0, 0, 0, 0), |
118 | 118 | ]; |
119 | 119 | drawShape(ctx, debug, interpolateBetweenLoop(percentage, ...prepShapes(a, b))); |
120 | 120 | }; |
121 | 121 |
|
122 | | -const genBlob = ( |
123 | | - seed: string, |
124 | | - complexity: number, |
125 | | - contrast: number, |
126 | | - s: number, |
127 | | - offset: Coord, |
128 | | -): Shape => { |
129 | | - const shape = blobs.path({ |
130 | | - complexity, |
131 | | - contrast, |
132 | | - size: s * size, |
133 | | - seed, |
134 | | - }); |
| 122 | +const blob = (seed: string, count: number, scale: number, offset: Coord): Shape => { |
| 123 | + const rgen = rand(seed); |
| 124 | + const shape = genBlob(count, () => 0.3 + 0.2 * rgen()); |
135 | 125 | for (let i = 0; i < shape.length; i++) { |
| 126 | + shape[i].x *= scale * size; |
| 127 | + shape[i].y *= scale * size; |
136 | 128 | shape[i].x += offset.x * size; |
137 | 129 | shape[i].y += offset.y * size; |
| 130 | + shape[i].handleIn.length *= scale * size; |
| 131 | + shape[i].handleOut.length *= scale * size; |
138 | 132 | } |
139 | 133 | return shape; |
140 | 134 | }; |
|
0 commit comments