Skip to content

Instantly share code, notes, and snippets.

View shinchu's full-sized avatar

SHU shinchu

View GitHub Profile

Twitter abuses all media file uploads, each type in its own way. If we want to upload a good looking animation loop from some low-color, high-detail generative art, we have to game their system's mechanisms.

  • don't upload a video file, they will re-encode it into absolute 💩

  • create a GIF, which they will auto-convert into a video file 😱

  • The frames of the GIF will be resized to an even-sized width using an extremely naive algorithm. Your GIF should be an even size (1000, 2000,

@simoncozens
simoncozens / harmonization.md
Last active October 23, 2023 06:42
Harmonizing two Bezier curves

To harmonize (with G2 curvature) two cubic Bézier curves a0,a1,a2,a3 and b0,b1,b2,b3 where a2, a3 = b0, and b1 are colinear:

  • First find d = intersection point of line a1--a2 and line b1--b2.
  • Now find ratios p0 = |a1, a2| / |a2, d| and p1 = |d1, b1| / |b1, b2|.
  • Determine ratio p = sqrt(p0 * p1)
  • Now set position of a3 = b0 such that |a2, a3| / |a3, b1| == p.
  • To do this, set t = p / (p+1).
  • Adjust the position of a3=b0 so that it sits t of the way between a2 and b1.

Of course, you may prefer to keep the position of a3 because it's the on-curve point. Fine. Instead, compute where a3 should go according to this algorithm, work out the delta between the new position and the current position, and apply that delta to the handles a2 and b1 instead.