CreativeInquiry / PEmbroider

Embroidery Library for Processing
Other
443 stars 28 forks source link

culling question. #97

Open stephanschulz opened 3 years ago

stephanschulz commented 3 years ago

I am doing some Anton Stankowski inspired coding with shapes inside shapes. When using culling the distribution of the stitches is not as even as it is when not using culling. I guess that due to having different start and stop points for the polylines. Do you have any tips to counter act that effect and get a nice clean distributed look? Here two image with and without culling. thx anton_2020_8_28_10_26_44 anton_2020_8_28_10_26_38

LingDong- commented 3 years ago

Hi @stephanschulz

I think a better alternative to culling is to use PEmbroiderBooleanGraphics. Culling is done after the whole design is baked into polylines, so it has to make guesses and compromises. It always look nicer if the correct shape is prepared in the first place (with PEmbroiderBooleanGraphics)

See:

https://github.com/CreativeInquiry/PEmbroider/issues/54

https://github.com/CreativeInquiry/PEmbroider/issues/62

stephanschulz commented 3 years ago

Thanks for the advice. I am not sure if the library is able to accept PShape objects? Right now I am constructing my arrow shape from a bunch of vertices. In this specific case I could combine a triangle and a rectangle, but it would not work for more complicated shapes I guess.

PShape testShape;
BSG.testShape;

Syntax error, insert "VariableDeclarators" to complete LocalVariableDeclaration

LingDong- commented 3 years ago

HI @stephanschulz ,

Basically PEmbroiderBooleanGraphics is just a wrapper on PGraphics that's more specialized on binary images. It works exactly like regular PGraphics, and the syntax is also exactly the same, so to draw a PShape on it:

PShape testShape;
testShape.disableStyle();
BSG.fill(255);
BSG.image(testShape,0,0);

The idea is to just construct a binary image where white part should be stitched and black part is void. Then feed it to PEmbroider's image() function.