Skip to content

Instantly share code, notes, and snippets.

@idcrook
Last active July 1, 2020 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idcrook/1eef0fa371d356a3791ebc5f7ea2598b to your computer and use it in GitHub Desktop.
Save idcrook/1eef0fa371d356a3791ebc5f7ea2598b to your computer and use it in GitHub Desktop.
Improved version of attempt at reverse engineering Xcode 12 Instruments icon, modeled in OpenSCAD
// Reverse-engineer model an Xcode 12 Instruments icon mesh in OpenSCAD
// idcrook@users.noreply.github.com
// Inspired to create by
// https://twitter.com/edwardsanchez/status/1278152030645698560
// Turn on Animate in App menu bar
// [x] Check Dump Pictures
// - creates files in sequence frame00000.png
// - Select FPS: 12 and Steps: 60
//
// Time ($t) sweeps from 0.0 to 1.0
size = 100;
// https://openscadsnippetpad.blogspot.com/2017/06/figure-eight-path.html
function figure8(m=size)=[for(t=[0:1:360])
let(scale = 2 / (3 - cos(2*t)),x =m* scale * cos(t),y =m* scale * sin(2*t) / 2)
[x,y]];
function close(p)= concat(p,[p[0]]);
module polyline(p) {for(i=[0:max(0,len(p)-2)])line(p[i],p[i+1]);}
module line(p1, p2, width=(size/7)/2.0)
{
hull() {
translate(p1) sphere(width);
translate(p2) sphere(width);
}
}
module one_symbol() {
polyline(close(figure8(size/2)));
}
module assembly2 () {
x_off = 16.5;
z_off = 23;
translate([-x_off,0,0])
//rotate([45/2 , 90 + 30, 45/2])
rotate([0 , 90 + 30, 0])
rotate([0 , 0, -15])
one_symbol();
translate([x_off,0,0])
rotate([0, -(90 + 30), 0])
rotate([0 , 0, -15])
one_symbol();
translate([0,0,-z_off])
rotate([0 , 0, -15])
rotate([0 , 0, 0])
one_symbol();
}
show_assembly = true;
// $preview requires version 2019.05
fn = $preview ? 30 : 100;
// can only _assign_ viewpoint variables at top-level
$vpt = [0,0,0];
$vpr = [90, 0, $t * 360]; // rotate viewpoint
$vpd = 415;
if (show_assembly) {
scale ([1.0,1.0,1.0])
translate([0,0,0])
rotate([0,0,0])
assembly2();
} else {
scale ([1.0,1.0,1.0])
translate([0,0,0])
rotate([0,0,0])
one_symbol();
}
#!/bin/bash -x
# ImageMagick has these utilities
convert 'frame000*.png' -set delay 1x24 animated.gif
convert animated.gif -scale 25% animated_25pct.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment