CreativeInquiry / PEmbroider

Embroidery Library for Processing
Other
443 stars 28 forks source link

simple E.rect problem #93

Closed stephanschulz closed 3 years ago

stephanschulz commented 3 years ago

This code should draw 2 noFill rectangles with a strokeWeight > 1 But only one gets drawn.

Screen Shot 2020-08-21 at 2 30 40 PM
import processing.embroider.*;
PEmbroiderGraphics E;

void setup() {
  noLoop(); 
  size (1400, 1400);

  //700 is half hoop size
  String name = "grid";
  E = new PEmbroiderGraphics(this, width, height);
  String outputFilePath = sketchPath(name+".jef");
  E.setPath(outputFilePath); 
  E.strokeWeight(1);

  E.beginDraw(); 
  E.clear();
  E.noFill(); 

  E.pushMatrix();
  E.translate(210, 100);
  E.strokeWeight(10);
  E.rect(0, 0, 90, 90);
  E.popMatrix();

  E.strokeWeight(3);
  E.rect(110, 100, 90, 90);

  //E.strokeWeight(1);
  //E.rect(10, 100, 90, 90);
  //-----------------------
  E.optimize(); // slow, but very good and important
  E.visualize(true, false, false);
  E.endDraw(); // write out the file
  save(name+".png");
}

If I uncomment the 3rd E.rect then all 3 get drawn properly.

Screen Shot 2020-08-21 at 2 32 38 PM
LingDong- commented 3 years ago

Thanks for the report, now fixed: 0da654983a826d1b85871fc2c4e9dc9d28f211a2 It's actually a problem derived from E.optimize(). i.e., one of the rects is "optimized out" by mistake, which is itself derived from the border making code, which generated a bunch of empty segments which confused the optimizer.

golanlevin commented 3 years ago

😍 Thanks for addressing this @LingDong- !