Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/tandem-core-variants/core-mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/tandem-core-variants/debug-segment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
196 changes: 196 additions & 0 deletions assets/tandem-core-variants/extract_flat_svg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
from PIL import Image
import math
import os

SRC_PATH = ".superpowers/brainstorm/20599-1787840406/content/tandem-logo-reference.png"
OUT_DIR = "assets/tandem-core-variants"

def smooth_polyline(points, window=6):
n = len(points)
smoothed = []
for i in range(n):
sx, sy, sw = 0.0, 0.0, 0.0
for j in range(-window, window + 1):
idx = (i + j) % n
w = (window + 1) - abs(j)
sx += points[idx][0] * w
sy += points[idx][1] * w
sw += w
smoothed.append((round(sx / sw, 3), round(sy / sw, 3)))
return smoothed

def catmull_rom_to_bezier(pts):
n = len(pts)
d = [f"M {pts[0][0]:.2f},{pts[0][1]:.2f}"]
for i in range(n):
p0 = pts[(i - 1) % n]
p1 = pts[i]
p2 = pts[(i + 1) % n]
p3 = pts[(i + 2) % n]

c1x = p1[0] + (p2[0] - p0[0]) / 6.0
c1y = p1[1] + (p2[1] - p0[1]) / 6.0
c2x = p2[0] - (p3[0] - p1[0]) / 6.0
c2y = p2[1] - (p3[1] - p1[1]) / 6.0

d.append(f"C {c1x:.2f},{c1y:.2f} {c2x:.2f},{c2y:.2f} {p2[0]:.2f},{p2[1]:.2f}")
d.append("Z")
return " ".join(d)

def main():
img = Image.open(SRC_PATH).convert("RGBA")
w, h = img.size
cx, cy = 628, 612

# 1. Identify ribbon pixels (threshold 28)
grid = [[False]*w for _ in range(h)]
for y in range(h):
for x in range(w):
r, g, b, a = img.getpixel((x, y))
dist_c = math.hypot(x - cx, y - cy)
if a > 40 and dist_c > 110:
l = 0.299*r + 0.587*g + 0.114*b
if l > 28:
grid[y][x] = True

# 2. Outer contour tracing
dirs = [(1,0), (1,1), (0,1), (-1,1), (-1,0), (-1,-1), (0,-1), (1,-1)]
start_x, start_y = None, None
for y in range(h):
for x in range(w):
if grid[y][x]:
start_x, start_y = x, y
break
if start_x is not None:
break

curr = (start_x, start_y)
dir_idx = 7
outer_raw = [curr]
while True:
found = False
search_dir = (dir_idx + 5) % 8
for i in range(8):
check_dir = (search_dir + i) % 8
dx, dy = dirs[check_dir]
nx, ny = curr[0] + dx, curr[1] + dy
if 0 <= nx < w and 0 <= ny < h and grid[ny][nx]:
curr = (nx, ny)
dir_idx = check_dir
found = True
break
if not found or curr == (start_x, start_y):
break
outer_raw.append(curr)

# 3. Inner hole contour tracing
hole_grid = [[False]*w for _ in range(h)]
queue = [(cx, cy)]
hole_grid[cy][cx] = True
while queue:
qx, qy = queue.pop()
for dx, dy in [(-1,0), (1,0), (0,-1), (0,1)]:
nx, ny = qx + dx, qy + dy
if 0 <= nx < w and 0 <= ny < h and not grid[ny][nx] and not hole_grid[ny][nx]:
hole_grid[ny][nx] = True
queue.append((nx, ny))

h_start_x, h_start_y = None, None
for y in range(h):
for x in range(w):
if hole_grid[y][x]:
h_start_x, h_start_y = x, y
break
if h_start_x is not None:
break

curr = (h_start_x, h_start_y)
dir_idx = 7
inner_raw = [curr]
while True:
found = False
search_dir = (dir_idx + 5) % 8
for i in range(8):
check_dir = (search_dir + i) % 8
dx, dy = dirs[check_dir]
nx, ny = curr[0] + dx, curr[1] + dy
if 0 <= nx < w and 0 <= ny < h and hole_grid[ny][nx]:
curr = (nx, ny)
dir_idx = check_dir
found = True
break
if not found or curr == (h_start_x, h_start_y):
break
inner_raw.append(curr)

print(f"Total raw points: outer={len(outer_raw)}, inner={len(inner_raw)}")

# Smooth the polyline
outer_smooth = smooth_polyline(outer_raw, window=8)
inner_smooth = smooth_polyline(inner_raw, window=8)

# Subsample points evenly for smooth cubic Bezier fitting
# Outer perimeter is ~3000px, 48 points gives 1 spline per ~60px
# Inner perimeter is ~1200px, 28 points gives 1 spline per ~42px
num_outer_ctrl = 54
num_inner_ctrl = 32

outer_pts = [outer_smooth[int(i * len(outer_smooth) / num_outer_ctrl)] for i in range(num_outer_ctrl)]
inner_pts = [inner_smooth[int(i * len(inner_smooth) / num_inner_ctrl)] for i in range(num_inner_ctrl)]

outer_bezier = catmull_rom_to_bezier(outer_pts)
inner_bezier = catmull_rom_to_bezier(inner_pts)
combined_ribbon = f"{outer_bezier} {inner_bezier}"

core_cx = 628.0
core_cy = 612.0
core_r = 104.0

THEMES = {
"orange": ("#ff3811", "Orange (Original)"),
"green": ("#10e850", "Emerald Green"),
"blue": ("#12a8ff", "Electric Blue"),
"yellow": ("#ffc812", "Golden Yellow"),
"purple": ("#ba41ff", "Neon Purple"),
"cyan": ("#00f0ff", "Cyan Aqua"),
"pink": ("#ff2e93", "Hot Pink / Magenta"),
}

# Generate SVGs
for name, (color_hex, label) in THEMES.items():
# 1. With dark squircle background
svg_with_bg = f'''<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1254 1254" width="100%" height="100%">
<!-- Background Squircle Container -->
<rect id="bg" width="1254" height="1254" rx="275" fill="#000000"/>

<!-- Flat White Ribbon (Continuous Curved Toroid Loop) -->
<path id="ribbon" fill="#FFFFFF" fill-rule="evenodd" d="{combined_ribbon}"/>

<!-- Flat Colored Core (Target for Lottie scale/pulse/glow) -->
<circle id="core" cx="{core_cx:.1f}" cy="{core_cy:.1f}" r="{core_r:.1f}" fill="{color_hex}"/>
</svg>'''
with open(os.path.join(OUT_DIR, f"tandem-flat-{name}.svg"), "w", encoding="utf-8") as f:
f.write(svg_with_bg)

# 2. Transparent background version (pure mark)
svg_transparent = f'''<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1254 1254" width="100%" height="100%">
<!-- Flat White Ribbon -->
<path id="ribbon" fill="#FFFFFF" fill-rule="evenodd" d="{combined_ribbon}"/>

<!-- Flat Colored Core -->
<circle id="core" cx="{core_cx:.1f}" cy="{core_cy:.1f}" r="{core_r:.1f}" fill="{color_hex}"/>
</svg>'''
with open(os.path.join(OUT_DIR, f"tandem-flat-transparent-{name}.svg"), "w", encoding="utf-8") as f:
f.write(svg_transparent)

# Primary aliases
with open(os.path.join(OUT_DIR, "tandem-flat.svg"), "w", encoding="utf-8") as f:
f.write(open(os.path.join(OUT_DIR, "tandem-flat-orange.svg")).read())

with open(os.path.join(OUT_DIR, "tandem-flat-transparent.svg"), "w", encoding="utf-8") as f:
f.write(open(os.path.join(OUT_DIR, "tandem-flat-transparent-orange.svg")).read())

print("All flat SVGs generated successfully!")

if __name__ == "__main__":
main()
135 changes: 135 additions & 0 deletions assets/tandem-core-variants/generate_variants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
from PIL import Image
import colorsys
import math
import os

SRC_PATH = ".superpowers/brainstorm/20599-1787840406/content/tandem-logo-reference.png"
OUT_DIR = "assets/tandem-core-variants"

COLOR_CONFIGS = [
{
"name": "orange",
"label": "Orange (Original)",
"hue": 6.2,
"sat_mult": 1.0,
"val_mult": 1.0
},
{
"name": "green",
"label": "Emerald Green",
"hue": 138.0,
"sat_mult": 1.05,
"val_mult": 1.0
},
{
"name": "blue",
"label": "Electric Blue",
"hue": 218.0,
"sat_mult": 1.05,
"val_mult": 1.05
},
{
"name": "yellow",
"label": "Golden Yellow",
"hue": 46.0,
"sat_mult": 1.1,
"val_mult": 1.0
},
{
"name": "purple",
"label": "Neon Purple",
"hue": 278.0,
"sat_mult": 1.05,
"val_mult": 1.05
},
{
"name": "cyan",
"label": "Cyan Aqua",
"hue": 182.0,
"sat_mult": 1.05,
"val_mult": 1.0
},
{
"name": "pink",
"label": "Hot Pink / Magenta",
"hue": 328.0,
"sat_mult": 1.05,
"val_mult": 1.05
},
]

def process():
orig = Image.open(SRC_PATH).convert("RGBA")
w, h = orig.size
cx, cy = 628.0, 612.0

# Pre-calculate masks and coordinates for pixels inside core circle
# Core radius is ~106. Feather out to 109.
r_inner = 103.0
r_outer = 108.5

core_coords = []
for y in range(int(cy - r_outer - 2), int(cy + r_outer + 2)):
for x in range(int(cx - r_outer - 2), int(cx + r_outer + 2)):
d = math.hypot(x - cx, y - cy)
if d <= r_outer:
if d <= r_inner:
w_mask = 1.0
else:
# Smooth cosine falloff
w_mask = 0.5 * (1.0 + math.cos(math.pi * (d - r_inner) / (r_outer - r_inner)))
core_coords.append((x, y, w_mask))

print(f"Core pixels to process: {len(core_coords)}")

for cfg in COLOR_CONFIGS:
name = cfg["name"]
target_hue = cfg["hue"]
sat_mult = cfg["sat_mult"]
val_mult = cfg["val_mult"]

img = orig.copy()
pixels = img.load()
orig_pixels = orig.load()

if name == "orange":
# Exact original copy
out_path = os.path.join(OUT_DIR, f"tandem-core-{name}.png")
img.save(out_path, optimize=True)
print(f"Saved {out_path}")
continue

delta_hue = (target_hue - 6.2) / 360.0

for x, y, mask in core_coords:
r, g, b, a = orig_pixels[x, y]
if a < 5:
continue

h_val, s_val, v_val = colorsys.rgb_to_hsv(r / 255.0, g / 255.0, b / 255.0)

# Shift hue smoothly with weight
new_h = (h_val + delta_hue * mask) % 1.0
new_s = min(1.0, max(0.0, s_val * (1.0 + (sat_mult - 1.0) * mask)))
new_v = min(1.0, max(0.0, v_val * (1.0 + (val_mult - 1.0) * mask)))

nr, ng, nb = colorsys.hsv_to_rgb(new_h, new_s, new_v)

# Blend by mask with original pixel
final_r = int(round(nr * 255.0 * mask + r * (1.0 - mask)))
final_g = int(round(ng * 255.0 * mask + g * (1.0 - mask)))
final_b = int(round(nb * 255.0 * mask + b * (1.0 - mask)))

pixels[x, y] = (final_r, final_g, final_b, a)

out_path = os.path.join(OUT_DIR, f"tandem-core-{name}.png")
img.save(out_path, optimize=True)
print(f"Saved {out_path}")

# Also create a crisp 128x128 preview
thumb = img.resize((128, 128), Image.Resampling.LANCZOS)
thumb_path = os.path.join(OUT_DIR, f"tandem-core-{name}-128.png")
thumb.save(thumb_path, optimize=True)

if __name__ == "__main__":
process()
Loading
Loading