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

Potentially helpful sizing function #110

Open
anneschoonmaker opened this issue May 19, 2023 · 0 comments
Open

Potentially helpful sizing function #110

anneschoonmaker opened this issue May 19, 2023 · 0 comments

Comments

@anneschoonmaker
Copy link

Hi! I have been using this library for my thesis and have really loved it! One thing I built out that helped me was a function allowing the user to dictate the hoop size in inches so that when I transfer my designs to my machine, less resizing is needed. However, I have only tested it on the PE800 embroidery machine, so not sure how it would work for other brands. For it to show up as the right size, I had to use the settings function to call the hoop function created since you cannot set size() with variables regularly.
Hope this can help some people with their art as well!
Here is an example below:

import processing.embroider.*;
PEmbroiderGraphics E;
 int[] xy = new int[2];
 int x = 0;
 int y = 0;
 
//need to use the settings function so that the hoop function can be called and have 
//size width and height be a variable not hard coded
void settings(){
  int[] xy = hoop(4,4, "in"); 
  x= xy[0];
  y= xy[1];
  size(x,y);
}

void setup(){
  noLoop();  
  String outputFilePath = sketchPath("hoopdemo.pes");

  //the space for the embroidery is the same size as the gray window
  E = new PEmbroiderGraphics(this, x, y);
  E.setPath(outputFilePath);  
  E.beginDraw(); 
  E.clear();
  E.textSize(4); 
  E.text("Hello World! :)", 50, 100); 
  E.beginRepeatEnd(2);
  //E.optimize(); // VERY SLOW -- can take MINUTES -- but ESSENTIAL!!!
  E.visualize(true, false,false);
  E.endDraw(); // write out the file
  save("hoopdemo.png");

}

int[] hoop(int width, int height, String type){
  
  //width and height is the value of the hoop size so if you want it to be 4*4 inches it will create
  //a boundary of roughly that size  
  int tandb = 0;
  int landr = 0;
  if(type.equals("in")){
  float inch = 25.4*10; 
  tandb = int(width * inch);
  landr = int(height * inch);    
  }
  int[] xy = new int[2]; 
  xy[0] = tandb; 
  xy[1] = landr; 
  return xy;
}

hoopdemo

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

1 participant