CreativeInquiry / PEmbroider

Embroidery Library for Processing
Other
442 stars 28 forks source link

Disabling resampling of straight lines (e.g. for AxiDraw output) #9

Open golanlevin opened 4 years ago

golanlevin commented 4 years ago

Another idea for the PEmbroider library... a modification that removes stitch-down points that break up lines that are otherwise straight. The goal would be to reuse the hatching code for something like an AxiDraw plotter, where there’s no need to make individual “stitches” in a long straight line.

IMG_8629

This could take the form of something like noResample() or resample(true/false).

LingDong- commented 4 years ago

Added: 0ca31e8c67d1051d9a891f5ed52f2bc34979fdd2

E.toggleResample(false); //plotter
E.toggleResample(true); //embroidery
stephanschulz commented 3 years ago

We just got an axidraw se/a3 at the studio. What would be the best way to go about interfacing with it and take advantage of the PEmbroider functions? Axidraw works well through Inkspace and also their live draw Processing examples.

I assume I would try to export not to .jef but .svg, open that file again in their live draw Processing examples and have it trace the paths. I wonder though if you have a quicker method ?

golanlevin commented 3 years ago

If you're controlling the AxiDraw "offline" (from a file), then I would do your designs with toggleResample(false) set, and then export .SVG files, then load those files in InkScape and control the AxiDraw from there.

If you were controlling the AxiDraw in real-time from Processing (it's possible), then you would need to reach into the PEmbroider object to get the locations of the stitch points, and then (in separate Processing code) tell the AxiDraw to move there. See https://github.com/evil-mad/AxiDraw-Processing, https://github.com/koblin/AxiDrawProcessing2 .

stephanschulz commented 3 years ago

Thanks for the marching directions. For now I will test different fills to see what works best for my use case.

When setting the output file path to use .SVG is there a way to not export the connecting island lines? The Axidraw draw those lines too even though they are not part of the image. I know I could manually delete them, but ...

Screen Shot 2020-09-03 at 3 05 15 PM
golanlevin commented 3 years ago

Hi @LingDong- , Omitting the connecting lines would be very important for plotter stuff! Could you please add this option? Thanks for testing this @stephanschulz! Golan

stephanschulz commented 3 years ago

thx for looking in to this. we are trying to draw in seeds, similar to sand animation.

2020-09-03 15 10 19

LingDong- commented 3 years ago

Hi @golanlevin @stephanschulz

The easiest hack to omit the connecting lines is to use a different color for each stroke. For example, iterate through E.colors and assign each a different random color. (e.g. alternate between #000000 and #010101 to make it invisible to human eye)

However don't worry about the hack since now SVG and PDF exports will omit the connecting lines in the newest commit: e8a945af3f441bb4aac3528a8f8bad65fdf78214 :)

stephanschulz commented 3 years ago

thanks. Indeed your new commit solved it.

stephanschulz commented 3 years ago

This seems to have solved it for most cases. But when using satin it still safe the connecting lines in the SVG

  //E.noStroke(); 
    E.fill(int(red(layerColors[colorIndex])), int(green(layerColors[colorIndex])), int(blue(layerColors[colorIndex]))); 

    E.hatchSpacing(6);
    E.PARALLEL_RESAMPLING_OFFSET_FACTOR = 0.5;
    E.hatchAngleDeg(0);
    E.hatchMode(PEmbroiderGraphics.SATIN);
    E.setStitch(10, 50, 0); 
    E.image(myImage, 0, 0);
Screen Shot 2020-09-09 at 12 08 23 PM