diff --git a/src/pixel/px_sphere.scad b/src/pixel/px_sphere.scad index c95709c5..3893630c 100644 --- a/src/pixel/px_sphere.scad +++ b/src/pixel/px_sphere.scad @@ -1,16 +1,17 @@ function px_sphere(radius, filled = true) = + let(range = [-radius: radius - 1]) filled ? [ - for(x = -radius; x < radius; x = x + 1) - for(y = -radius; y < radius; y = y + 1) - for(z = -radius; z < radius; z = z + 1) + for(x = range) + for(y = range) + for(z = range) let(v = [x, y, z]) if(norm(v) < radius) v ] : let(ishell = radius * radius - 2 * radius) [ - for(z = -radius; z < radius; z = z + 1) - for(y = -radius; y < radius; y = y + 1) - for(x = -radius; x < radius; x = x + 1) + for(z = range) + for(y = range) + for(x = range) let( v = [x, y, z], leng = norm(v)