"""Generates the three tide curves in brand/graphley-icon.svg. Each edge is one smooth function, sampled and turned into cubic Béziers with matching tangents at every join (Catmull-Rom), so the waves have no kinks or flat spots. The bands are offsets of the same curve, so they stay parallel and widen a little toward the right. Run: python3 scripts/icon-waves.py (prints the three path d= strings) """ import math X0, X1 = -80.0, 1104.0 def smooth(t): t = min(1.0, max(0.0, t)) return t * t * t * (t * (6 * t - 15) + 10) def crest(x): # A soft trough on the left, then one long, even rise to the upper right. dip = 34 * math.exp(-((x - 300) / 230) ** 2) rise = 470 * smooth((x - 220) / 1050) return 585 + dip - rise def edge(offset, spread): return lambda x: crest(x) + offset + spread * (x - X0) / (X1 - X0) def path(f, n=12): xs = [X0 + (X1 - X0) * i / n for i in range(n + 1)] pts = [(x, f(x)) for x in xs] d = f"M{pts[0][0]:.1f} {pts[0][1]:.1f}" for i in range(n): p0 = pts[max(i - 1, 0)]; p1 = pts[i]; p2 = pts[i + 1]; p3 = pts[min(i + 2, n)] c1 = (p1[0] + (p2[0] - p0[0]) / 6, p1[1] + (p2[1] - p0[1]) / 6) c2 = (p2[0] - (p3[0] - p1[0]) / 6, p2[1] - (p3[1] - p1[1]) / 6) d += f" C{c1[0]:.1f} {c1[1]:.1f} {c2[0]:.1f} {c2[1]:.1f} {p2[0]:.1f} {p2[1]:.1f}" return d + " L1104 1100 L-80 1100 Z" if __name__ == "__main__": print("crest", path(crest)) print("band-teal", path(edge(162, 40))) print("band-amber", path(edge(325, 70)))