mirror of
https://github.com/NixOS/nixos-artwork
synced 2024-10-18 00:06:24 -04:00
replaced inkscape ported open scad flake with parametric model.
This commit is contained in:
parent
e7e665687f
commit
094e780dd7
|
@ -1,83 +0,0 @@
|
|||
|
||||
// Module names are of the form poly_<inkscape-path-id>(). As a result,
|
||||
// you can associate a polygon in this OpenSCAD program with the corresponding
|
||||
// SVG element in the Inkscape document by looking for the XML element with
|
||||
// the attribute id="inkscape-path-id".
|
||||
|
||||
// fudge value is used to ensure that subtracted solids are a tad taller
|
||||
// in the z dimension than the polygon being subtracted from. This helps
|
||||
// keep the resulting .stl file manifold.
|
||||
fudge = 0.1;
|
||||
|
||||
resize = 1.2;
|
||||
h = 1.3;
|
||||
hole = 1.6;
|
||||
|
||||
module poly_use4877(h)
|
||||
{
|
||||
scale([25.4/90, -25.4/90, 1]) union()
|
||||
{
|
||||
linear_extrude(height=h)
|
||||
polygon([[14.207302,24.606074],[49.535701,-36.577571],[57.571512,-22.955866],[48.295577,-6.991831],[66.717461,-6.943450],[70.643564,-0.136878],[66.634395,6.824948],[40.412750,6.742153],[30.078745,24.607594]]);
|
||||
}
|
||||
}
|
||||
|
||||
module poly_use4867(h)
|
||||
{
|
||||
scale([25.4/90, -25.4/90, 1]) union()
|
||||
{
|
||||
linear_extrude(height=h)
|
||||
polygon([[28.458722,0.008829],[24.048793,-7.633090],[19.638494,-15.274795],[15.227887,-22.916323],[10.817037,-30.557711],[6.406008,-38.198996],[1.994864,-45.840215],[-6.827516,-61.122604],[8.987139,-61.270958],[18.174426,-45.255754],[27.427286,-61.185376],[35.285004,-61.182278],[39.309521,-54.229323],[26.127003,-31.562097],[36.358720,-13.756949]]);
|
||||
}
|
||||
}
|
||||
|
||||
module poly_use4875(h)
|
||||
{
|
||||
scale([25.4/90, -25.4/90, 1]) union()
|
||||
{
|
||||
linear_extrude(height=h)
|
||||
polygon([[6.242489,-38.482132],[-14.321266,-38.519856],[-27.360264,-61.269896],[-35.393881,-61.261111],[-39.325426,-54.457909],[-30.156475,-38.479555],[-48.619947,-38.530715],[-56.398803,-24.761012],[14.165366,-24.757388],[6.242489,-38.482132]]);
|
||||
}
|
||||
}
|
||||
|
||||
module poly_use4865(h)
|
||||
{
|
||||
scale([25.4/90, -25.4/90, 1]) union()
|
||||
{
|
||||
linear_extrude(height=h)
|
||||
polygon([[-14.163043,24.603341],[56.353710,24.610099],[48.574866,38.380159],[30.111644,38.328989],[39.280671,54.306992],[35.349053,61.110382],[27.315368,61.119393],[14.276240,38.369401],[-6.191601,38.327891]]);
|
||||
}
|
||||
}
|
||||
|
||||
module poly_use4863(h)
|
||||
{
|
||||
scale([25.4/90, -25.4/90, 1]) union()
|
||||
{
|
||||
linear_extrude(height=h)
|
||||
polygon([[-14.126419,-24.758850],[-49.535698,36.564898],[-57.571510,22.943194],[-48.295574,6.979159],[-66.717461,6.930749],[-70.643564,0.124177],[-66.634393,-6.837620],[-40.412747,-6.754854],[-29.997860,-24.764369]]);
|
||||
}
|
||||
}
|
||||
|
||||
module poly_path4861(h)
|
||||
{
|
||||
scale([25.4/90, -25.4/90, 1]) union()
|
||||
{
|
||||
linear_extrude(height=h)
|
||||
polygon([[-28.291283,-0.227362],[6.874205,61.122604],[-8.940450,61.270958],[-18.127737,45.255754],[-27.380597,61.185376],[-35.238315,61.182278],[-39.262832,54.229323],[-26.080314,31.562097],[-36.191280,13.454298]]);
|
||||
}
|
||||
}
|
||||
|
||||
$fn=25;
|
||||
difference() {
|
||||
union() {
|
||||
scale([resize,resize,1]){
|
||||
poly_use4877(h);
|
||||
poly_use4867(h);
|
||||
poly_use4875(h);
|
||||
poly_use4865(h);
|
||||
poly_use4863(h);
|
||||
poly_path4861(h);
|
||||
}
|
||||
}
|
||||
translate([resize*4.5,resize*9.7,-0.1]) cylinder(h=h+0.2, r=resize*hole);
|
||||
}
|
151
logo/parametric-flake.scad
Normal file
151
logo/parametric-flake.scad
Normal file
|
@ -0,0 +1,151 @@
|
|||
unit = [1, 0];
|
||||
origin = [0, 0];
|
||||
|
||||
|
||||
/*
|
||||
Returns a 2D rotation matrix given an angle.
|
||||
*/
|
||||
function rot2d(angle) = [
|
||||
[+cos(angle), -sin(angle)],
|
||||
[+sin(angle), +cos(angle)]
|
||||
];
|
||||
|
||||
|
||||
/*
|
||||
Calculates the points for a hexagon.
|
||||
Used to reference off of for creating the lambda.
|
||||
Points are created starting from the right and moving counter-clockwise.
|
||||
|
||||
2 1
|
||||
|
||||
3 0
|
||||
|
||||
4 5
|
||||
*/
|
||||
function inner_hex_points(data) = [
|
||||
for (angle = [0 : 60 : 300])
|
||||
dict_get(data, "scale") * rot2d(angle) * unit
|
||||
];
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Calculates the points for making a lambda.
|
||||
|
||||
Returns two a list of two lists.
|
||||
The first list contains the offset for making a flake.
|
||||
The second list is used to form the lambda polygon.
|
||||
*/
|
||||
function lambda_points(data) =
|
||||
let (
|
||||
hex_points = inner_hex_points(data),
|
||||
thickness = dict_get(data, "thickness") / 2,
|
||||
top_left = hex_points[2],
|
||||
bottom_left = hex_points[4],
|
||||
bottom_right = hex_points[5],
|
||||
v_0 = thickness * unit,
|
||||
v_p60 = thickness * rot2d(60) * unit,
|
||||
v_n60 = thickness * rot2d(-60) * unit,
|
||||
v_n90 = thickness * rot2d(-90) * unit,
|
||||
gap = dict_get(data, "gap") * rot2d(-60) * unit
|
||||
)
|
||||
[
|
||||
[
|
||||
top_left + v_p60,
|
||||
],
|
||||
[
|
||||
top_left - v_p60 + gap,
|
||||
top_left + v_p60 + gap,
|
||||
bottom_right + v_0,
|
||||
bottom_right - v_0,
|
||||
sqrt(3) * v_n90,
|
||||
bottom_left + v_0,
|
||||
bottom_left,
|
||||
bottom_left - v_n60,
|
||||
-v_0
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
/*
|
||||
Generates a single lambda at the origin.
|
||||
*/
|
||||
module lambda(data) {
|
||||
new_data = update_params(data);
|
||||
linear_extrude(dict_get(new_data, "height"))
|
||||
polygon(lambda_points(new_data)[1]);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Generates a NixOS flake.
|
||||
*/
|
||||
module flake(data) {
|
||||
new_data = update_params(data);
|
||||
colors = dict_get(data, "colors");
|
||||
echo(colors);
|
||||
for (idx = [0 : 5]) {
|
||||
color(colors[idx % len(colors)])
|
||||
rotate([0, 0, idx * 60])
|
||||
translate(-lambda_points(new_data)[0][0])
|
||||
translate([-dict_get(new_data, "scale"), 0, 0])
|
||||
linear_extrude(dict_get(new_data, "height"))
|
||||
polygon(lambda_points(new_data)[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Returns the value from a associative array/dictionary type structure given some key.
|
||||
|
||||
Values can be of any type.
|
||||
The dictionary must of be of the form:
|
||||
[
|
||||
[ "key0", <value0> ],
|
||||
[ "key1", <value1> ],
|
||||
...
|
||||
]
|
||||
*/
|
||||
function dict_get(dict, key) =
|
||||
dict[search([key], dict)[0]][1];
|
||||
|
||||
|
||||
/*
|
||||
Updates the user parameters so the flake is unit size when `scale = 1`.
|
||||
*/
|
||||
function update_params(data) = let
|
||||
// factor was empirically found. It gives a flake that is circumscribed by the unit circle.
|
||||
(factor = 2.25) [
|
||||
[ "gap", 0.75 * dict_get(data, "scale") * dict_get(data, "gap") / factor ],
|
||||
[ "height", dict_get(data, "height") ],
|
||||
[ "scale", dict_get(data, "scale") / factor ],
|
||||
[ "thickness", dict_get(data, "scale") * dict_get(data, "thickness") / factor ],
|
||||
];
|
||||
|
||||
|
||||
/*
|
||||
The parameters for generating a NixOS flake.
|
||||
|
||||
`gap` - The gap between lambdas.
|
||||
`height` - The z-height of the flake.
|
||||
`scale` - The radial (x,y) size of the flake.
|
||||
`thickness` - The thickness of the lambda legs.
|
||||
|
||||
`scale` updates `gap` and `thickness` so there is no need to compesate these values.
|
||||
A `gap` of 0 will leave no gap between the lambdas.
|
||||
A `gap` of 1 will remove the top portion of the long lambda leg until the point where the two lambda legs intersect.
|
||||
|
||||
A `gap` of 0.05 to 0.15 is a good value for replicating the official NixOS flake.
|
||||
A `thickness` of 0.5 is a good value for replicating the official NixOS flake.
|
||||
OpenSCAD doesn't have a concept of units so use `scale` and `height` values in the desired ratio.
|
||||
*/
|
||||
params = [
|
||||
[ "gap", 0.1 ],
|
||||
[ "height", 1 ],
|
||||
[ "scale", 10 ],
|
||||
[ "thickness", 0.5 ],
|
||||
[ "colors", ["#5277C3", "#7EBAE4"]],
|
||||
];
|
||||
|
||||
|
||||
flake(params);
|
11
logo/simple-flake.scad
Normal file
11
logo/simple-flake.scad
Normal file
|
@ -0,0 +1,11 @@
|
|||
use <parametric-flake.scad>
|
||||
|
||||
params = [
|
||||
[ "gap", 0.1 ],
|
||||
[ "height", 1 ],
|
||||
[ "scale", 10 ],
|
||||
[ "thickness", 0.5 ],
|
||||
[ "colors", ["#5277C3", "#7EBAE4"]],
|
||||
];
|
||||
|
||||
flake(params);
|
Loading…
Reference in a new issue