/ examples / voxel_vase.scad
voxel_vase.scad
 1  use <bezier_curve.scad>
 2  use <voxel/vx_polyline.scad>
 3  use <voxel/vx_cylinder.scad>
 4  
 5  x1 = 5;
 6  x2 = 20;
 7  x3 = 8;
 8  thickness = 1;
 9  
10  module pixel_vase(x1, x2, x3, thickness) {
11      p0 = [x1, 0, 0];
12      p1 = [10, 0, 4];
13      p2 = [x2, 0, 8];
14      p3 = [3, 0, 20];
15      p4 = [x3, 0, 30];
16  
17      rounded_points = [for(pt = bezier_curve(0.1, 
18          [p0, p1, p2, p3, p4]
19      )) [round(pt[0]), round(pt[1]), round(pt[2])]];
20  
21      vx_path = vx_polyline(rounded_points);
22      leng = len(vx_path);
23  
24      for(p = vx_cylinder(vx_path[0][0], 1, true)) { 
25          linear_extrude(1)
26          translate([p[0], p[1]])
27              square(1.1, center = true);
28      }
29  
30      for(i = [0:leng - 1]) {
31          r = vx_path[i][0];
32          for(p = vx_cylinder(r, 1, thickness = thickness)) { 
33              translate([0, 0, i]) 
34              linear_extrude(1) 
35              translate([p[0], p[1]])
36                  square(1.1, center = true);
37          }
38      }  
39  }    
40  
41  pixel_vase(x1, x2, x3, thickness);