From febf25566d12ec90a0ecd64a34ca2cab5f86246c Mon Sep 17 00:00:00 2001 From: polyfloyd Date: Sun, 4 May 2025 19:24:04 +0200 Subject: [PATCH] Add cat ears --- .forgejo/workflows/stl.yaml | 5 +++ bottle-clip.scad | 89 +++++++++++++++++++++++-------------- ci-template.scad | 2 +- 3 files changed, 61 insertions(+), 35 deletions(-) diff --git a/.forgejo/workflows/stl.yaml b/.forgejo/workflows/stl.yaml index 8bf8825..9284e2f 100644 --- a/.forgejo/workflows/stl.yaml +++ b/.forgejo/workflows/stl.yaml @@ -26,6 +26,10 @@ on: - pixel-cats/spooked-right.svg - pixel-cats/standing-left.svg - pixel-cats/standing-right.svg + ears: + description: 'Cat Ears' + default: false + type: boolean jobs: @@ -47,6 +51,7 @@ jobs: env: LABEL: "${{ inputs.label }}" ICON: "${{ inputs.icon }}" + EARS: "${{ inputs.ears }}" - name: Render to STL run: openscad --export-format binstl -o bottle-clip.stl ci.scad diff --git a/bottle-clip.scad b/bottle-clip.scad index 9fa682e..ac26c58 100644 --- a/bottle-clip.scad +++ b/bottle-clip.scad @@ -58,50 +58,71 @@ module multicolor(color) { * text_color: The color of the text * logo_color: The color of the logo */ -module bottle_clip(ru=13, rl=17.5, ht=26, width=2.5, name="", gap=90, +module bottle_clip(ru=13, rl=17.5, ht=26, width=2.5, name="", gap=90, ears=false, logo="thing-logos/stratum0-lowres.dxf", font="write/orbitron.dxf", bg_color="DEFAULT", text_color="DEFAULT", logo_color="DEFAULT") { e=100; // should be big enough, used for the outer boundary of the text/logo + difference() { - rotate([0,0,-45]) union() { - // main cylinder - multicolor(bg_color) cylinder(r1=rl+width, r2=ru+width, h=ht); - // text and logo - if(logo == "") { - multicolor(text_color) writecylinder(name, [0,0,3], rl+0.5, ht/13*7, h=ht/13*8, t=max(rl,ru), - font=font); - } else { - multicolor(text_color) writecylinder(name, [0,0,0], rl+0.5, ht/13*7, h=ht/13*4, t=max(rl,ru), - font=font); - multicolor(logo_color) translate([0,0,ht*3/4-0.1]) - rotate([90,0,0]) - scale([ht/100,ht/100,1]) - translate([-25,-25,0.5]) - linear_extrude(height=max(ru,rl)*2) - import(logo); + union() { + difference() { + rotate([0,0,-45]) union() { + // main cylinder + multicolor(bg_color) cylinder(r1=rl+width, r2=ru+width, h=ht); + // text and logo + if(logo == "") { + multicolor(text_color) writecylinder(name, [0,0,3], rl+0.5, ht/13*7, h=ht/13*8, t=max(rl,ru), + font=font); + } else { + multicolor(text_color) writecylinder(name, [0,0,0], rl+0.5, ht/13*7, h=ht/13*4, t=max(rl,ru), + font=font); + multicolor(logo_color) translate([0,0,ht*3/4-0.1]) + rotate([90,0,0]) + scale([ht/100,ht/100,1]) + translate([-25,-25,0.5]) + linear_extrude(height=max(ru,rl)*2) + import(logo); + } + } + // outer cylinder which is substracted, so the text and the logo end + // somewhere on the outside ;-) + difference () { + cylinder(r1=rl+e, r2=ru+e, h=ht); + translate([0,0,-1]) + // Note: bottom edges of characters are hard to print when character + // depth is > 0.7 + cylinder(r1=rl+width+0.7, r2=ru+width+0.7, h=ht+2); + } + + // finally, substract an equilateral triangle as a gap so we can clip it to + // the bottle + gap_x=50*sin(45-gap/2); + gap_y=50*cos(45-gap/2); + translate([0,0,-1]) + linear_extrude(height=50) + polygon(points=[[0,0], [gap_x, gap_y], [50,50], [gap_y, gap_x]]); + } + + // Cat ears! + if (ears) { + ear_size = 8; + rotate([0, 0, 45]) + for (m = [0 : 1]) mirror([0, m, 0]) + rotate([0, 0, -60]) + translate([0, 0, ht-3]) + rotate([0, -90, 0]) + translate([0, 0, ru]) + rotate([0, -30, 0]) + // Ear solid + translate([0,0,-1]) + linear_extrude(2) + polygon(points = [ [0, -ear_size], [0, ear_size], [ear_size*2, 1], [ear_size*2, -1] ]); } } // inner cylinder which is substracted translate([0,0,-1]) cylinder(r1=rl, r2=ru, h=ht+2); - // outer cylinder which is substracted, so the text and the logo end - // somewhere on the outside ;-) - difference () { - cylinder(r1=rl+e, r2=ru+e, h=ht); - translate([0,0,-1]) - // Note: bottom edges of characters are hard to print when character - // depth is > 0.7 - cylinder(r1=rl+width+0.7, r2=ru+width+0.7, h=ht+2); - } - - // finally, substract an equilateral triangle as a gap so we can clip it to - // the bottle - gap_x=50*sin(45-gap/2); - gap_y=50*cos(45-gap/2); - translate([0,0,-1]) - linear_extrude(height=50) - polygon(points=[[0,0], [gap_x, gap_y], [50,50], [gap_y, gap_x]]); } } diff --git a/ci-template.scad b/ci-template.scad index 50d756a..ac1840c 100644 --- a/ci-template.scad +++ b/ci-template.scad @@ -1,3 +1,3 @@ include -bottle_clip(name="$LABEL", logo="$ICON"); +bottle_clip(name="$LABEL", logo="$ICON", ears=$EARS);