Geomerative and strokeWeight()
              in 
             Contributed Library Questions 
              •  
              1 month ago    
            
 
           
             Hi, I am trying to make a 
            RShape that is made of lines with different 
            strokeWeight overlapping or crossing.  The reason behind it is that I just want one vector object when I export it, rather than lots of small vectors. 
            
             
            
            
             
            
            
             
            
            
             
            
            
             
              
            
            
             
             
           
 
            
           
             Adding 
             RShape objects seem to work, but when I try to vary the 
             strokeWeight, it does not change the stroke weight of lines. Could someone advise me how to achieve this?
            
            
             The following is the code what I have:
            
            - RShape grp;
 - //coordinates
 - int[] x_pos = {50, 100, 150, 200, 250, 300};
 - int[][] y_pos = {{100, 100, 60, 60, 100, 100},
 - {120, 120, 160, 160, 120, 120},
 - {200, 200, 200, 200, 200, 200}};
 - int[] line_width = {10, 30, 15};
 - void setup() {
 - size(600, 400);
 - background(255);
 - RG.init(this);
 - noFill();
 - stroke(0, 120);
 - strokeCap(SQUARE);
 - strokeJoin(ROUND);
 - grp = new RShape();
 - for (int i = 0; i < line_width.length; i++) {
 - strokeWeight(line_width[i]);
 - RShape newShape = new RShape();
 - RPath path = new RPath(x_pos[0], y_pos[i][0]);
 - for (int j = 1; j< x_pos.length; j++) {
 - path.addLineTo(x_pos[j], y_pos[i][j]);
 - }
 - newShape.addShape(path.toShape());
 - grp.addShape(newShape);
 - }
 - }
 - void draw() {
 - background(255);
 - grp.draw();
 - // this is what I want them to look like
 - // for (int i = 0; i < line_width.length; i++) {
 - // strokeWeight(line_width[i]);
 - // strokeCap(SQUARE);
 - // noFill();
 - // stroke(color(234, 46, 75, 120));
 - // beginShape();
 - // for (int j = 0; j< x_pos.length; j++) {
 - // vertex(x_pos[j], y_pos[i][j]);
 - // }
 - // endShape();
 - // }
 - }
 
 
              
              1  
            
 
            