Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

satin hatching does not catch all polygons #99

Open
stephanschulz opened this issue Sep 6, 2020 · 7 comments
Open

satin hatching does not catch all polygons #99

stephanschulz opened this issue Sep 6, 2020 · 7 comments

Comments

@stephanschulz
Copy link

I have many .png images which I all want to be executed with E.SATIN
But depending on the size of these images not all polygon shaped images get hatched.
Here the resulting file with the missing shapes circled.
polarbear_2020_9_6_9_23_23
this shows all the different shapes that should be executed.
Screen Shot 2020-09-06 at 9 29 44 AM
Is it possible that the satin hatch get overwhelmed with too many shapes?

thx

@LingDong-
Copy link
Collaborator

Hi @stephanschulz , I'm wondering what is your input to SATIN? Is the input polygons vertices, or binary images? Is each color input separately to SATIN, or is each polygon input separately to SATIN, or are they given all at the same time? Do the missing parts share the same color, and of what color should they actually be? What does gray values of the second grayscale image indicate, do they correspond to the colors of the first image?

Thanks and sorry for so many questions, but I need the info to pinpoint the problem :)

@stephanschulz
Copy link
Author

  • input is a bunch of binary images
  • each image has a different color
  • the missing parts do share the same color but are also part of the same binary image
  • the second image is a illustrator file to show you the different layers.

Embroider_test.zip

@LingDong-
Copy link
Collaborator

Screen Shot 2020-09-07 at 5 22 58 PM

import java.io.*;
import processing.embroider.*;
PEmbroiderGraphics E;


void setup(){
  size(800,800);
  background(0);
  
  E = new PEmbroiderGraphics(this);
  
  String[] filenames = new File(dataPath("")).list(new FilenameFilter() {
    public boolean accept(File dir, String name) {
        return name.toLowerCase().endsWith(".png");
    }
  });
  

  for (int i = 0; i < filenames.length; i++){
    println("working on layer "+i+" ...");
    PImage img = loadImage(dataPath(filenames[i]));
    img.resize(width,height);
    
    E.noStroke();
    E.fill((int)random(100,255),(int)random(100,255),(int)random(100,255));
    E.hatchSpacing(5);
    E.hatchMode(E.SATIN);
    E.image(img,0,0);

  }
  
  E.visualize(true,false,false);

}

@stephanschulz
Copy link
Author

as soon as I add

  E.optimize();
  E.visualize(true, false, false);
  E.printStats();
  E.endDraw(); // write out the file

to your code I see the problem again

@LingDong-
Copy link
Collaborator

fixed: 7099df3

btw, optimize shouldn't be used with SATIN, since it might flip the order of the centerline and the hatch, see #82

@golanlevin
Copy link
Member

@stephanschulz also, be aware that beginOptimize()/endOptimize() does exist, in case you need to combine SATIN with other stuff.

@stephanschulz
Copy link
Author

thanks for the tips.

I saw E.optimize(); being used in the PEmbroider_satin_hatching_2 example. But now I know better.

thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants