diff --git a/ng/doc/diff.svg b/ng/doc/diff.svg new file mode 100644 index 0000000..8c2bfb5 --- /dev/null +++ b/ng/doc/diff.svg @@ -0,0 +1,180 @@ + + + +1 diff --git a/ng/doc/fadeout.mp4 b/ng/doc/fadeout.mp4 new file mode 100644 index 0000000..be14614 Binary files /dev/null and b/ng/doc/fadeout.mp4 differ diff --git a/ng/doc/grid.png b/ng/doc/grid.png new file mode 100755 index 0000000..77b1422 Binary files /dev/null and b/ng/doc/grid.png differ diff --git a/ng/doc/header.svg b/ng/doc/header.svg new file mode 100644 index 0000000..6070aa4 --- /dev/null +++ b/ng/doc/header.svg @@ -0,0 +1,45 @@ + + + + + OpenSCAD Model + + diff --git a/ng/doc/module.png b/ng/doc/module.png new file mode 100755 index 0000000..e0ccf9e Binary files /dev/null and b/ng/doc/module.png differ diff --git a/ng/doc/weights.svg b/ng/doc/weights.svg new file mode 100644 index 0000000..484494a --- /dev/null +++ b/ng/doc/weights.svg @@ -0,0 +1,138 @@ + + + + + nix-gapless + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + nix-gapless + + + + diff --git a/ng/export-color-svgs.sh b/ng/export-color-svgs.sh new file mode 100755 index 0000000..0cfb358 --- /dev/null +++ b/ng/export-color-svgs.sh @@ -0,0 +1,43 @@ +TEMPDIR=$(mktemp -d) +INPUT_CSG='nix.scad' +PARAMFILE='nix.json' + +function export_svg() { +COLORS=$( + openscad -p "${PARAMFILE}" -P "${PROFILE}" "$INPUT_CSG" -o "${TEMPDIR}/no_color.svg" -D "module color(c) {echo(mowmow = str(c));}" 2>&1 | + grep -Po '(?<=(mowmow = \"))(#[0-9a-fA-F]{6}|[0-9a-fA-F]{8})' | + sort -u +); + +SVGFILE=out/${PROFILE}.svg + +{ +cat < + + +${PROFILE} +EOF +for color in $COLORS; do + openscad -p "${PARAMFILE}" -P "${PROFILE}" "$INPUT_CSG" --export-format svg -o - -D "module color(c) {if (c == \"${color}\") children();}" 2>/dev/null| + sed "s/stroke=\"black\"//g" | + sed "s/stroke-width=\"0.5\"//g" | + sed "s/lightgray/${color}/g" | + grep -Pzo '' | + # drop the Null + head -c-1 + echo +done +cat < +EOF + +} > ${SVGFILE} +inkscape --actions="file-open:${SVGFILE};select-all;fit-canvas-to-selection;export-filename:${SVGFILE};export-do;file-close" +} + +for profile in nix nix-megagrid nix-white; do + export PROFILE=$profile + export_svg +done diff --git a/ng/nix.json b/ng/nix.json new file mode 100644 index 0000000..22c4295 --- /dev/null +++ b/ng/nix.json @@ -0,0 +1,138 @@ +{ + "fileFormatVersion": "1", + "parameterSets": { + "nix": { + "$aperture": "2", + "$clipr": "8", + "$gaps": "1", + "$length": "4", + "$unit": "25", + "circle_h": "6", + "circle_r": "55", + "circle_t": "6", + "colors": "[\"#5277c3\", \"#7EBAE4\"]", + "hole_ratio": "1.07", + "invclip": "false", + "num": "6", + "pin_r": "3", + "printed_h": "30", + "printed_version": "none", + "show_full": "true", + "show_hexgrid": "false" + }, + "nix-gapless (unofficial)": { + "$aperture": "2", + "$clipr": "8", + "$gaps": "0", + "$length": "4", + "$unit": "25", + "circle_h": "6", + "circle_r": "55", + "circle_t": "6", + "colors": "[\"#5277c3\", \"#7EBAE4\"]", + "hole_ratio": "1.07", + "invclip": "false", + "num": "6", + "pin_r": "3", + "printed_h": "30", + "printed_version": "none", + "show_full": "true", + "show_hexgrid": "false" + }, + "nix-grid (unofficial)": { + "$aperture": "2", + "$clipr": "8", + "$gaps": "1", + "$length": "4", + "$unit": "25", + "circle_h": "6", + "circle_r": "55", + "circle_t": "6", + "colors": "[\"#5277c3\", \"#7EBAE4\"]", + "hole_ratio": "1.07", + "invclip": "false", + "num": "6", + "pin_r": "3", + "printed_h": "30", + "printed_version": "none", + "show_full": "true", + "show_hexgrid": "true" + }, + "nix-megagrid": { + "$aperture": "2", + "$clipr": "8", + "$gaps": "1", + "$length": "4", + "$unit": "25", + "circle_h": "6", + "circle_r": "55", + "circle_t": "6", + "colors": "[\"#5277c3\", \"#7EBAE4\"]", + "hole_ratio": "1.07", + "invclip": "false", + "num": "6", + "pin_r": "3", + "printed_h": "30", + "printed_version": "grid", + "show_full": "true", + "show_hexgrid": "false" + }, + "nix-printing-module": { + "$aperture": "2", + "$clipr": "8", + "$gaps": "1", + "$length": "4", + "$unit": "25", + "circle_h": "6", + "circle_r": "55", + "circle_t": "6", + "colors": "[\"#5277c3\", \"#7EBAE4\"]", + "hole_ratio": "1.07", + "invclip": "false", + "num": "6", + "pin_r": "3", + "printed_h": "30", + "printed_version": "module", + "show_full": "false", + "show_hexgrid": "false" + }, + "nix-printing-one-piece": { + "$aperture": "2", + "$clipr": "8", + "$gaps": "1", + "$length": "4", + "$unit": "25", + "circle_h": "6", + "circle_r": "55", + "circle_t": "6", + "colors": "[\"#5277c3\", \"#7EBAE4\"]", + "hole_ratio": "1.07", + "invclip": "false", + "num": "6", + "pin_r": "3", + "printed_h": "30", + "printed_version": "one piece", + "show_full": "false", + "show_hexgrid": "false" + }, + "nix-white": { + "$aperture": "2", + "$clipr": "8", + "$gaps": "1", + "$length": "4", + "$unit": "25", + "circle_h": "6", + "circle_r": "55", + "circle_t": "6", + "colors": "[\"#FFFFFF\"]", + "hole_ratio": "1.07", + "invclip": "false", + "num": "6", + "pin_r": "3", + "printed_h": "30", + "printed_version": "none", + "show_full": "true", + "show_hexgrid": "false" + } + } +} diff --git a/ng/nix.scad b/ng/nix.scad new file mode 100644 index 0000000..b022c02 --- /dev/null +++ b/ng/nix.scad @@ -0,0 +1,229 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +// === Nix logo specification + +// Central aperture diameter, in units. It does produce nice effects if animated. +$aperture = 2; + +// lambda height in units. fun to play with +$length = 4; + +// Clipping polygon diameter, in units +$clipr = 8; + + +// === Some calculated core stuff + +// number of lambdas. doesn't really work if changed in this model. +num = 6; + +// The angle™ +th = 360 / num / 2; + +// Unit value of Y when mapped to coordinate space with angle between axes of "th" +function tunit() = tan(th)*$unit; + +// === Rendering props + +// Lambda thickness, also a segment size. Should affect nothing except size and gaps. +$unit = 25; + +// Shrinkage for each of lambdas. Basically control inverse "font weight" +$gaps = 1; + +// colors to use +colors = ["#5277C3", "#7EBAE4"]; + +// inverse clipping order +invclip = false; +show_hexgrid = false; +show_full = true; + +printed_version = "none"; // ["none", "grid", "one piece", "module", "weights"] + +printed_h = 20; +circle_r = 55; +circle_t = 6; +circle_h = 6; +pin_l = 4*tunit(); +pin_r = 3; + +// Pin/hole size ratio, to account for plastic heat deformation +hole_ratio = 1.07; + +// copied from so customizer will work on thingiverse +module regular_polygon(sides, radius) +{ + function dia(r) = sqrt(pow(r*2,2)/2); //sqrt((r*2^2)/2) if only we had an exponention op + angles=[ for (i = [0:sides-1]) i*(360/sides) ]; + coords=[ for (th=angles) [radius*cos(th), radius*sin(th)] ]; + polygon(coords); +} + + +function minsym(x) = (x <= 3 || x % 2 > 0) ? x : minsym(x/2); + +module hexgrid(thickness=1.5) union() { + // Yes you can go lower for hexagonal grids. + s = minsym(num); + th_l = 180 / s; + for (i=[0:s-1]) { + rotate((i+0.5)*th_l) + for (i=[-$clipr:$clipr]) union() { + translate([i*$unit/2,0]) + square([thickness, $clipr * $unit * 2],center=true); + }; + }; +} + + +// draw a ~perfect~ 2D lambda +module lambda() { + intersection(){ + union() { + // Lambda arm + rotate(-th) + translate([0,-tunit()*$length]) + square([$unit,$length*tunit()*2], center=true); + // Lambda bar + rotate(th) + square([$unit,tunit()*($length*2 + 2)], center=true); + } + // Cutting top and bottom of squares to be left with a perfect lambda + // Lambda *almost* scales uniformly. + // We just need to account for corner triangles, making it + 2 wider. + square([tunit()*($length + 2), $unit*$length], center=true); + } +} + +// Subtracts a rotated child from itself +module diff(nextangle, debug=false) { + difference() { + children(); + rotate(invclip ? nextangle : -nextangle) children(); + } +} + +module clipper(){ + // that's not as easy to autotune as it would seem + intersection() { + regular_polygon(num, $clipr * tunit()); + children(); + } +} + +module placed_lambda() { + offset(delta = -$gaps) + clipper() + // cutting it up with the same lambda at the next place + diff(360/num) + // translation to endpoint + translate([tunit() * -$aperture, $unit * -$aperture]) + // initial in-place rotation + lambda(); +} + +module render_logo(segments=[0:num-1]) { + for (r=segments) + // color it with next color in array + color(colors[r % len(colors)]) + rotate(th*2*r) + placed_lambda(); +} + +module make_pin(scl = 1, r = pin_r) { + + // Only rescale crossection, so length doesn't change + scale([1,scl,scl]) + + translate([tunit() * -$aperture, $unit * -$aperture]) + rotate(th) + // extrude pin from the center to the side of a limbda + translate([0,pin_l/2,0]) + rotate([90,45]) + cube([r * 2, r * 2, pin_l], center=true); + //cylinder(50, r, r, center=true); +} + +module render_module() { + render() + difference() { + union() { + make_pin(1); + linear_extrude(printed_h, center=true) + + clipper() + placed_lambda(); + } + // ensuring that hole is slightly larger + rotate((invclip ? -1 : 1) * 360/num) make_pin(hole_ratio); + + // usually not needed, but you + // can actually thread stuff thru two next lambdas + rotate((invclip ? -2 : 2) * 360/num) make_pin(hole_ratio); + } +} +// Actual rendering +if (printed_version == "grid") { + for (x=[0:4], y=[0:4]) { + translate([tunit()*(-4.5*y+12*x), -$unit*(-6.5*y+1*x)]) difference() { + render_logo(); + if (show_hexgrid) + hexgrid(); + } + } +} + +if (printed_version == "none") { + difference() { + render_logo(); + if (show_hexgrid) + hexgrid(); + }; +} + +if (printed_version == "module") { + difference() { + render_module(); + if (show_hexgrid) + translate([0,0,printed_h/2-1]) + linear_extrude(2) + hexgrid(); + } + if (show_full) + translate([0,0, printed_h / -2]) + color("#ff000033") + render_logo(); +} + +if (printed_version == "one piece") +union() { + + linear_extrude(circle_h, center=true) + + difference() { + circle(circle_r); + circle(circle_r - circle_t); + } + + difference() { + linear_extrude(printed_h, center=true) + render_logo(); + + if (show_hexgrid) + translate([0,0,printed_h/2-1]) + linear_extrude(1) + hexgrid(); + } +}; + +if (printed_version == "weights") + for (gap=[1:5]) { + $gaps = 1; + $aperture = 2 * gap; + $length = 4 * gap; + $clipr = 8 * gap; + $unit = 25 / gap; + translate([(gap - 1) * 160,((gap - 1) % 2) * 160]) + render_logo(); + }; \ No newline at end of file diff --git a/ng/out/nix-megagrid.svg b/ng/out/nix-megagrid.svg new file mode 100644 index 0000000..22f4176 --- /dev/null +++ b/ng/out/nix-megagrid.svg @@ -0,0 +1,33 @@ + + + + + nix-megagrid + + + diff --git a/ng/out/nix-white.svg b/ng/out/nix-white.svg new file mode 100644 index 0000000..9c9d22b --- /dev/null +++ b/ng/out/nix-white.svg @@ -0,0 +1,29 @@ + + + + + nix-white + + diff --git a/ng/out/nix.svg b/ng/out/nix.svg new file mode 100644 index 0000000..a92178d --- /dev/null +++ b/ng/out/nix.svg @@ -0,0 +1,33 @@ + + + + + nix + + + diff --git a/ng/readme.md b/ng/readme.md new file mode 100644 index 0000000..5f1e1fe --- /dev/null +++ b/ng/readme.md @@ -0,0 +1,43 @@ +![](./doc/header.svg) +# Precise Nix logo rework (aka genix7000) + +Logo versions for use are in ["out" folder](./out) + +This is a Nix logo version, generated in OpenSCAD and pinned to a hex grid. Differences between generated and original versions are neglidgible: + +![Old and new logos, overlayed](./doc/diff.svg) + +*Blue is a newer version, red is an older version* + +Here's a "hexgrid" version, which shows the proportions better: + +![Nix logo with different weights](./doc/grid.png) + +## Why OpenSCAD? + +Having most of the logo parametrized allows to generate logos with different weights with ease + +```openscad + for (gap=[1:5]) { + $gaps = gap * 2; + translate([(gap - 1) * 160,((gap - 1) % 2) * 160]) + difference() + render_logo(); + }; +``` +![Nix logo with different weights](./doc/weights.svg) + +It also allows to easily animate the logo — [here's an example](./doc/fadeout.mp4) — e.g if you want to have minimalistic plymouth animation. + +## 3D Printing + +nix.scad can also export several 3D printing models — single-module smaller versions, and separate, composable lambdas — if you wish to build yourself a huge Nix logo. +![Nix logo module](./doc/module.png) + +## Hacking on it + +Run `nix-shell -p openscad` if you don't have an OpenSCAD yet, and then open nix.scad in it. + +If you wish to export colored logos, modify and use `./export-color-svgs.sh` in this folder. + +3D printing models