1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-06 06:47:46 +02:00
This commit is contained in:
Justin Lin
2020-03-14 09:56:23 +08:00
parent 5d02009ead
commit 5acb525881

View File

@@ -23,13 +23,13 @@ module voronoi_fibonacci() {
to = to, to = to,
point_distance = point_distance point_distance = point_distance
); );
points = [for(pa = points_angles) pa[0]]; spiral = [for(pa = points_angles) pa[0]];
a_step = 360 / spirals; a_step = 360 / spirals;
pts = [ pts = [
for(a = [0:a_step:360 - a_step]) for(a = [0:a_step:360 - a_step])
each [for(p = points) rotate_p(p, a)] each [for(p = spiral) rotate_p(p, a)]
]; ];
function default_region_size(points) = function default_region_size(points) =
@@ -39,21 +39,21 @@ module voronoi_fibonacci() {
) )
max([(max(xs) - min(xs) / 2), (max(ys) - min(ys)) / 2]); max([(max(xs) - min(xs) / 2), (max(ys) - min(ys)) / 2]);
size = default_region_size(pts);
region_shape = shape_square(size);
cells = voronoi2d_cells(pts, region_shape);
half_line_thicness = line_thickness / 2; half_line_thicness = line_thickness / 2;
lst_r = norm(points[len(points) - 1]) + half_line_thicness; lst_r = norm(spiral[len(spiral) - 1]) + half_line_thicness;
cells = voronoi2d_cells(pts,
shape_square(default_region_size(pts))
);
for(i = [0:len(pts) - 1]) { for(i = [0:len(pts) - 1]) {
pt = pts[i];
cell = cells[i]; cell = cells[i];
if(style == "BLOCK") { if(style == "BLOCK") {
linear_extrude(line_thickness) linear_extrude(line_thickness)
circle(lst_r); circle(lst_r);
pt = pts[i];
color(rands(0, 1, 3)) color(rands(0, 1, 3))
translate(pt) translate(pt)
linear_extrude(cell_thickness, scale = cell_top_scale) linear_extrude(cell_thickness, scale = cell_top_scale)