Giter Club home page Giter Club logo

pembroider's Introduction

PEmbroider

PEmbroider is an open library for computational embroidery with Processing. PEmbroider was developed during Endless March 2020 at the CMU Frank-Ratchye STUDIO for Creative Inquiry by Golan Levin, Lingdong Huang, and Tatyana Mustakos, with generous support from an anonymous donor and the Clinic for Open Source Arts (COSA) at the University of Denver. For questions, please contact Golan Levin. If you found this project useful, please consider making a donation.

PEmbroider includes file-writing code adapted from the EmbroidePy EmbroideryIO project, under EmbroidePy's MIT License. Additional thanks to our beta-test community; Chris Coleman, and the Processing Foundation; Huw Messie, Bryce Summers, Lea Albaugh, Dan Moore, and the staff of the STUDIO.

Intended primarily for artists, craftspersons, educators, makers, and schools, PEmbroider is free, open-source software released under both the GNU General Public Licence (GPLv3) and the Anti-Capitalist Software License (ACSL 1.4). In short: you are encouraged to use PEmbroider to make art; you are required to share your improvements to PEmbroider; and you are expressly forbidden from using PEmbroider to profiteer. More information on PEmbroider's license is below.


TL;DR

Download the PEmbroider Library for Processing


Contents


Motivation

Commercial embroidery software can cost more than a car.

As this comparison of embroidery software shows, existing software for the creation of custom embroidery designs frequently costs thousands of dollars; is rarely cross-platform; and is almost never open-source. The free and open-source tools which do exist are either full-featured standalone GUI tools (Ink/Stitch, Embroidermodder) or large-scale libraries (EmbroidePy)—neither of which integrate easily with popular "creative coding" toolkits, nor easily allow for the creation of generative and computational designs.

PEmbroider, by contrast, is a free, cross-platform, open-source, lightweight Java library for generative embroidery design. It integrates with the popular Processing creative coding framework, providing ready access to a vast and diverse ecosystem of functionality including high quality typography, live interaction, motion capture, computer vision, GIS cartography, physics simulation, and much more.


Features

PEmbroider is a embroidery library for the Java flavor of the Processing creative coding environment, suitable for generating embroidery designs computationally. PEmbroider has the following features:

  • PEmbroider is structured similarly to other alternative renderers for Processing, providing basic drawing functions (lines, shapes, typography, etc.) that have drop-in compatibility with Processing code.
  • PEmbroider is able to generate embroidery files in .DST, .EXP, .JEF, .PEC, .PES, .VP3, and .XXX file formats, suitable for consumer CNC embroidery machines such as those made by Brother, Janome, or Husqvarna-Viking.
  • PEmbroider is also able to export .PDF, .SVG, .TSV, and .GCODE files for other 2D output devices such as CNC routers, AxiDraw pen plotters, etc. Although PEmbroider has not been primarily designed for plotter output, some of our hatching algorithms may be useful for this community.
  • PEmbroider is able to generate embroidery designs from vector (.SVG) and black-and-white bitmap files (.PNG, .GIF).
  • PEmbroider allows a variety of ways of composing shapes (including overlapping, cropping, and merging) using various computer vision and computational geometry algorithms.
  • PEmbroider offers a wide range of embroidery hatching (fill) methods.
  • PEmbroider generates optimized (shortest) paths using a modified Traveling Salesperson Problem solver, dramatically reducing embroidery time and material use.

PEmbroider has been tested on MacOS 10.13.6+ and Windows 10, using the STUDIO's Husqvarna Viking Designer Jade 35 embroidery machine.

Note: PEmbroider provides a visualization of the embroidery files it generates. However, PEmbroider has no functionality for loading or previewing pre-existing embroidery files; this is outside the scope of the project. To preview the contents of a .PES, .VP3, or other embroidery file, you will need to use embroidery viewing software, such as this or this. That said, it is possible to load SVGs and other images in Processing and use PEmbroider to generate embroidery designs from those.


Examples

PEmbroider comes with a variety of examples which demonstrate how to achieve different sorts of embroidery effects with lines, shapes, typography, images and more. Here are just some of them:

Examples


Getting Started with PEmbroider in Processing

This section is primarily intended for end-users who wish to get started using PEmbroider to make embroidery designs.

  • Be sure you have already installed Processing v.4.0a6 or higher.
  • Download the precompiled PEmbroider library .ZIP directly from here. (If you're still on Processing 3, use this link instead).
  • For an automated install, try using Processing's Contribution Manager. Navigate as follows in the Processing app: SketchImport LibraryPEmbroider. This will open the Contribution Manager, where you can browse for PEmbroider.
  • For a manual install, Unzip the PEmbroider .ZIP file and install it in your Processing Libraries directory. More detailed instructions for doing this can be found here.
  • Restart Processing. You should now be able to open and run the included example programs, which you can find inside the PEmbroider directory, or here.
  • To export embroidery files, make sure that optimize() and endDraw() are called in your code. The optimize() function produces much, much more efficient embroidery paths, while endDraw() is the code that actually exports the file. Note that optimize() may take up to a minute to execute.
  • In the code for your sketch, be sure you have specified the correct file format extension for your embroidery machine. PEmbroider currently supports .DST, .EXP, .JEF, .PEC, .PES, .VP3, and .XXX. If your machine's format is not yet supported, try using this online converter, Ink/Stitch, or Embird.
  • PEmbroider provides the visualize() function to view the planned stitches. You can also preview and validate your embroidery files with software such as this online viewer, Husqvarna/Viking PREMIER+ 2, or Brother PE-Design.
  • See here for instructions on using the STUDIO's Husqvarna Viking Designer Jade 35 embroidery machine.

Loading the PEmbroider library in Processing


How to Build PEmbroider From Source

This section is primarily intended for developers who wish to modify, extend, or contribute to the PEmbroider library itself.

To compile the library from source: First, open the project in Eclipse; then:

Follow this excerpt from processing/processing-library-template:

  • From the Eclipse menu bar, choose WindowShow ViewAnt. A tab with the title "Ant" will pop up on the right side of your Eclipse editor.
  • Drag the resources/build.xml file in there, and a new item "ProcessingLibs" will appear.
  • Press the "Play" button inside the "Ant" tab.

If BUILD SUCCESSFUL: The Library template will start to compile, control messages will appear in the console window, warnings can be ignored. When finished it should say BUILD SUCCESSFUL. Congratulations, you're set and you can start modifying the library by making changes to the source code in the src directory.

If BUILD FAILED: In case the compile process fails, check the output in the console, which will give you a closer idea of what went wrong. Errors may have been caused by Incorrect path settings in the build.properties file.

Here are the same steps, in screenshots:

Compilation steps in Eclipse

If there are any issues, download a fresh copy of this repository, and try carefully following Processing's official documentation.


FAQ

  • Which output file formats are supported? .DST, .EXP, .JEF, .PEC, .PES, .VP3, and .XXX, as well as .PDF, .SVG, .TSV, and .GCODE.
  • Which embroidery machine do you recommend? We cannot recommend which hardware is best for you. However, this review website has good things to say about the Janome Memory Craft 9850 ($1800, takes .JEF) and the Brother PE800 ($900, takes .PES and .DST). We developed our code using the Viking Jade 35 ($1000) and are pleased. The majority of our beta-testers have different kinds of Brother machines, for which our .DST files appear to behave well.
  • Why can't PEmbroider read pre-existing embroidery design files? This is a purposeful limitation of the project's scope. Philosophically, PEmbroider is intended to do one thing well: to allow you to generate new embroidery designs, with code. There is already plenty of software that allows you to load other people's designs. If you would like to manipulate pre-existing embroidery files computationally, we recommend the EmbroidePy project.
  • How can I learn to code in Processing? There's great documentation at the main Processing website, or you can check out Dan Shiffman's amazing Coding Train tutorials on YouTube.
  • How can I learn to do machine embroidery? Here are YouTube tutorials for the Viking Jade 35, the Brother PE800, and the Brother SE600.

License

PEmbroider is Copyright © 2020, the Frank-Ratchye STUDIO for Creative Inquiry at Carnegie Mellon University. Intended primarily for artists, craftspersons, educators, makers, and schools, PEmbroider is free, open-source software released under both the GNU General Public Licence (GPLv3) and the Anti-Capitalist Software License (ACSL v. 1.4). In short:

  • you are encouraged to use PEmbroider to make art;
  • you are required to share your improvements to PEmbroider;
  • and you are expressly forbidden from using PEmbroider to profiteer on the backs of artists, craftspersons, educators, makers, and schools. An example of this would be using PEmbroider to make commercial software such as (e.g.) Floriani Total Control Embroidery Software ($3499), DIME Designs in Machine Embroidery ($2999), Viking Premier Plus 2 Ultra ($2979), Hatch Embroidery Digitizer ($1099), Janome Artistic Digitizer Software ($1199), DesignerPlus Full Version ($1874), DRAWings PRO XI ($1299), etcetera.

ANTI-CAPITALIST SOFTWARE LICENSE (v 1.4)

This is anti-capitalist software, released for free use by individuals and organizations that do not operate by capitalist principles.

Permission is hereby granted, free of charge, to any person or organization (the "User") obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, merge, distribute, and/or sell copies of the Software, subject to the following conditions:

  1. The above copyright notice and this permission notice shall be included in all copies or modified versions of the Software.
  2. The User is one of the following:
    • a. An individual person, laboring for themselves
    • b. A non-profit organization
    • c. An educational institution
    • d. An organization that seeks shared profit for all of its members, and allows non-members to set the cost of their labor
  3. If the User is an organization with owners, then all owners are workers and all workers are owners with equal equity and/or equal vote.
  4. If the User is an organization, then the User is not law enforcement or military, or working for or under either.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

pembroider's People

Contributors

danzeeeman avatar golanlevin avatar lingdong- avatar tatyanade avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pembroider's Issues

Clamp ranges on property setters

It should be impossible to set a stitch length which is zero or negative.
Other properties with setter functions should impose reasonable safeties as well.

End angle is incorrect for arc()

@LingDong- ,
There's an error with the end-angle for the arc() function; it should be about 10 degrees bigger. This rendering is supposed to be an arc with 1.5xPI radians (3/4 of a circle):

Screen Shot 2020-06-14 at 9 57 04 PM

Color Based Optimization

image

Was doing this small test to see what order the colors would go - strokes are all the same color and fill is a different color but all the fills are the same. The second column is STROKE_OVER_FILL and the 3rd is FILL_OVER_STROKE. This is how it ran: It did the stroke for 1, then had me switch colors, did the fill for 2, had me switch color, did the stroke for 2 and 3, had me switch, did the fills for 3 and 4, had me switch, did the stroke for 5, had me switch, did the fill for 6, had me switch and did the stroke for 6 and 7, then i switched thread for the last time to cover the fill for 7 and 8. meaning i load the thread 8 individual times

Would be a lot less hassle if it does something more like strokes for 1,5,3,4, then having me switch to the color for the fill and doing the fill for 2, 3, 4, 6, 7, 8, then switching back to do the remaining stroke_over_fill strokes for 2 and 6

this would conflict with #35 stitch-wise TSP (since its currently acting object based) but is definitely a lot more user friendly to be able to optimize the embroidery so that you change out the thread the least amount of possible times

Remaining bits of Processing compatibility: arc(), square(), PShape/SVG

Hi Lingdong,
For thoroughness and compatibility with Processing, could you please add the following to PEmbroider:

This is more complex, but could you also add support for loading SVG files. Ideally this would use Processing's PShape code: https://processing.org/reference/PShape.html

Here is the code for a sample SVG to get you started, the rubber duck:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 width="107.59px" height="107.59px" viewBox="0 0 107.59 107.59" style="enable-background:new 0 0 107.59 107.59;"
	 xml:space="preserve">
<g>
	<g>
		<path id="path5050" d="M96.264,34.699c-3.347-2.532-2.761,11.526-21.229,13.686c-6.061,0.707-11.467,0.123-16.271-1.017
			c-3.056-0.717-3.266-2.931-1.117-5.208c4.146-4.382,6.692-10.292,6.692-16.804c0-13.518-10.953-24.47-24.467-24.47
			c-9.802,0-18.25,5.758-22.158,14.075c-1.331,2.842-4.267,4.793-7.355,4.272C4.308,18.213,0,18.525,0,24.396
			c0,5.9,7.381,11.777,16.339,16.008c2.835,1.335,2.868,3.211,0.267,4.966C7.755,51.313,1.925,61.412,1.925,72.876
			c0,18.295,14.928,31.224,33.129,33.126c25.834,2.701,56.48-1.725,68.054-24.964C111.389,64.409,107.671,43.343,96.264,34.699"/>
	</g>
</g>
</svg>

Screen Shot 2020-06-14 at 4 34 59 PM

Although it's outside the official Processing spec, it would also be cool to add Alexandre B A Villares' "arcVertex":

new PEmbroiderGraphics width height

2020-06-19_19h51_06 2020-06-19_19h51_16

There is weird machine behavior if you make the width height in E = new PEmbroiderGraphics(this, width, height); smaller than the canvas dimensions; same file above viewed on 80x80 and 240x150; it has all the stitch information regardless of it going off canvas (didn't try running on the 80x80 in case it acts weirdly)

is there any reason to have the user manually set the dimensions for the output instead of having it match the canvas automatically?

stitchwise-TSP vs. objectwise-TSP?

@LingDong- , I see some opportunities in which the TSP solver could have a behavior which, though less "optimal" in one sense, might be more user-friendly in another.

Let's call an "object", a cluster of related stitches. For example: all of the stitches inside some polygon. Sometimes, when rendering several different objects, the TSP will render half of an object; jump to another object; and then (eventually) return to complete the remainder of the first object.

From a user's perspective, it might make more sense to complete each object individually. More precisely, to:

  • to complete each object, in isolation unto itself, in an optimal way, with TSP, and,
  • then to complete the collection of all objects, in an optimal order.

Is this an option that would be easy to add to the TSP solver?

Results from Shapes

Shapes_Merging
image

Shapes
image

Shapes Culling
image

Shapes Hatching 1
image
image

Shapes Hatching 2
Pre Cleanup
image

Post Cleanup (vaguely impossible for vec and perlin) there are way to many overlapping stitches that the pattern gets lost
image

Shapes Hatching 3
(had already posted this but here it is again so its all in one place)
2020-06-19_21h29_45
2020-06-19_21h29_58

Please support .PES format

Hi @LingDong- , could you please add support for the .PES embroidery format. Some folks who want to help test have a Brother PE800 machine, for which this is the best format.
Thank you!
Golan

Bitmap Results

Here's the first run; Ill finesse some of the values and re-embroider
2020-06-14_21h57_04

Got an error with this one:
2020-06-14_21h57_44

I cant embroider this; whenever I try to open the file on the machine it tells me "Embroidery too large', which is a peculiar error that I don't believe has anything to do with physical size so I'd assume the file contains to much information?

2020-06-14_21h56_45
For the parallel strokes, would it be possible to implement a staggering similar to the offset on fill so that the thread ends are not right next to each other?

2020-06-14_21h56_32
Dense concentric hatch warps the fabric at three points, will see if this goes away with adjusting value

2020-06-14_21h56_37
2020-06-14_21h56_55
2020-06-14_21h56_15
2020-06-14_21h56_24

Don't put long connective TSP stitches underneath hatching

So, this might be a tough one: A problem is the long TSP connective stitches being sewn UNDERNEATH a hatch. You can see that in this picture:

Screen Shot 2020-06-07 at 11 29 34 PM

It is essentially impossible to remove those long connectors later, if they are sewn under a hatch. But they can be quite visible, which is the (aesthetic) problem. Can you imagine any way to avoid this?

One way Lingdong can think of is to add it as an optimization goal to the TSP: minimize number of crossing between connective stitches and real stitches. But: how to optimize for that parallel to the TSP goals yet, other than simply doing a lot more trials and pick the best one?

Errors rendering lines

Hi @LingDong- ,
See the example, PEmbroider_lines_1. Issues include:

  • lines with a strokeWeight of exactly 2.0 are not rendered.
  • strokeCap(SQUARE) is not currently working for strokeMode(PERPENDICULAR); it renders with round endcaps. However, strokeCap(SQUARE) is working correctly for strokeMode(TANGENT).
  • something funny is going on with the round endcaps of thick lines. The two ends of the line should not look different. It looks like you're maybe drawing a full circle instead of a semicircle?

PEmbroider_lines_1

Spiraling

When I call
E.setStitch(10,30,0); E.hatchMode(SPIRAL); E.hatchSpacing(8); E.rect(350, 350, 100, 100);

image

With the inner corners becoming slanted instead of keeping the shape at right angles

a lot less noticable with a stitch length of 40, but you can see it a bit towards the center
image

Also spiraling for circles gets a bit funky depending on stitch length ; this is circle with E.setStitch(10,40,0)
2020-06-19_18h53_57

verses E.setStitch(10,30,0), both with hatch spacing of 4.
2020-06-19_18h55_26

smaller stitch length looks better but im not sure why there would only be one inconsistently lengthen stitch with length 40

I think the circle spiral issue is not as much of a concern (or possibly not a concern at all, easy for the user to fix on their own) but for rectangle spiraling I think special attention should be payed to the inner corners guaranteeing a stitch point at least for more noticeable (non-central) corners

Matrix transform issue, in

Got a good one for you, @LingDong-
I made an example based on this recursive tree by Dan Shiffman:
https://processing.org/examples/tree.html
This example is located in examples/gallery/PEmbroider_tree/PEmbroider_tree.pde.

When rendered with Processing, it looks like this:
Screen Shot 2020-06-20 at 12 09 50 AM

When rendered with PEmbroider (adding E. before all graphics calls), it looks like:
Screen Shot 2020-06-20 at 12 09 15 AM

Please debug?

Confusion regarding strokeSpacing, hatchSpacing, stitchLength scaling w/transforms?

I may be overthinking this, but: Below are two circles, both drawn with hatchSpacing(10) and PARALLEL hatch, but in the second case, I have scaled the world by 0.5. (code is below). The stitch length is being scaled, as is the hatch spacing:

Screen Shot 2020-06-17 at 11 33 31 PM

Here's another case, where I'm using CONCENTRIC hatch, and scaling non-uniformly. In this case, the stitch length is NOT being scaled, but the hatch spacing is:

Screen Shot 2020-06-17 at 11 38 00 PM

A few thoughts:

  • At the very least, some consistency here would probably be good.
  • It might be nice for the user to be able to decide if (independently) stitchLength, hatchSpacing, and strokeSpacing scale with other graphics transforms. They would (or would-not) scale independently from the "art" itself (e.g. just the circles). This suggestion loosely inspired by the "Scale Strokes & Effects" checkbox in Adobe Illustrator, which allows these things to be coupled or de-coupled:

Screen Shot 2020-06-17 at 11 43 40 PM

@LingDong- , @tatyanade , what is your opinion of this question?

import processing.embroider.*;
void setup() {
  noLoop(); 
  size (800, 600);
  PEmbroiderGraphics E = new PEmbroiderGraphics(this, width, height);

  E.beginDraw(); 
  E.clear();
  E.noStroke();
  E.fill(0, 0, 0);
  E.ellipseMode(CENTER); 
  E.hatchMode(PEmbroiderGraphics.PARALLEL); 
  E.hatchSpacing(10); 

  E.circle(200, 200, 200); 

  E.pushMatrix();
  E.translate(400, 200); 
  E.scale(0.5, 0.5); 
  E.circle(0, 0, 200); 
  E.popMatrix(); 

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

hatchMode(AUTO)

The orientation of parallel or satin strokes should be perpendicular to major axis of an arbitrary polygon, using hatchMode(AUTO).

Things to rename :(

@LingDong-

Please rename:
HATCH_SPARSITY → HATCH_SPACING
STROKE_SPARSITY → STROKE_SPACING
NORMAL → PERPENDICULAR

Thanks!
Golan

Problems with raster hatching

Hi @LingDong- ,

This issue is demonstrated in the new example,
https://github.com/CreativeInquiry/PEmbroider/tree/master/examples/PEmbroider_bitmap_image_1

There are several problems:

  1. There's a weird aliasing on raster hatches in PARALLEL and CROSS modes, as can be seen in the upper two embroideries in the screenshot below. The aliasing is proportional to the stitch length.
  2. When using CONCENTRIC or SPIRAL hatch modes, larger values of hatchSpacing reveal the problem, that the outer edge of the shape is not currently being stitched. This is visible in the middle embroidery on the lower row. The outside edge should not be omitted from the CONCENTRIC hatch.
  3. Currently, strokes are not working at all in raster rendering. The lower right embroidery is totally wrong; it should have a stroke and no fill.

Screen Shot 2020-06-13 at 1 37 12 AM

Code for the lower right embroidery is:

  E.stroke(0, 0, 0); 
  E.noFill(); 
  E.strokeWeight(5); 
  E.STROKE_MODE = PEmbroiderGraphics.TANGENT;
  E.STROKE_SPACING = 4;
  E.hatchRaster(PG, 500, 250);

strokeMode (ANGLED)

A feature request, inspired by some embroidery graphics I've seen:

E.strokeMode(PEmbroiderGraphics.ANGLED); E.strokeAngle(radians(45));

IMG_8700

This will not work for large angles, but could be attractive for angles ±45°. It might require raster rendering to cope with appropriate cropping.

Problem rendering near sharp concavities with hatchSpine()

When using the (admittedly experimental) PEmbroiderHatchSpine.hatchSpine(), sometimes hatching voids are produced in the vicinity of sharp concave contours. This can be seen in the PEmbroider_bitmap_image_1 example, below:

Untitled

I can think of some ugly hacks for dealing with this, just wanted to document the problem for the moment.

NaN's in the optimizer...

The following code is in PEmbroider_bitmap_image_1.pde, rendering the broken heart image:

  // Draw fat parallel stroke only; no fill.   
  E.noFill(); 
  E.stroke(0, 0, 0); 
  E.setStitch(2, 30, 1.0);
  E.strokeWeight(16); 
  E.strokeSpacing(4);
  E.strokeMode(PEmbroiderGraphics.PERPENDICULAR);
  E.image(myImage, 500, 250);

This code is producing the following worrisome output in the optimizer:

[PEmbroider Optimize] Input:NaN
[PEmbroider Optimize] Trial:0	NN:Infinity	2-Opt:2224.5767
[PEmbroider Optimize] Trial:1	NN:Infinity	2-Opt:2224.5767
[PEmbroider Optimize] Trial:2	NN:Infinity	2-Opt:2247.809
[PEmbroider Optimize] Trial:3	NN:Infinity	2-Opt:2275.2676
[PEmbroider Optimize] Trial:4	NN:Infinity	2-Opt:2301.788
[PEmbroider Optimize] Final:2224.5767
[PEmbroider Writer] BASENAME :/Users/golan/Desktop/PEmbroider-Uber/PEmbroider/examples/PEmbroider_bitmap_image_1/PEmbroider_bitmap_image_1
[PEmbroider Writer] EXTENSION:vp3
[PEmbroider Writer] Color count: 1
[PEmbroider Writer] Written!

Registration point for type is not working as expected

This type was set with the registration point (0,0). It is located at the incorrect position and should behave just like regular Processing.

Screen Shot 2020-06-06 at 6 53 38 PM

Here's the code:


import processing.embroider.*;
PEmbroiderGraphics E;

void setup() {
  noLoop(); 
  size (600, 400);
  PFont myFont = createFont("Helvetica-Bold", 100);

  E = new PEmbroiderGraphics(this, width, height);
  String outputFilePath = sketchPath("PEmbroider_text.vp3");
  E.setPath(outputFilePath); 

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

  E.hatchMode(PEmbroiderGraphics.PARALLEL);
  E.strokeMode(PEmbroiderGraphics.PERPENDICULAR);
  E.hatchSpacing(4);
  E.strokeSpacing(4);
  
  E.textFont(myFont);
  E.fill(0);
  E.strokeWeight(12);
  E.textSize(250);
  E.text("ABC", 0, 0);

  //-----------------------
  E.visualize();
  //E.optimize(); // slow, but very good and important
  //E.endDraw(); // write out the file
}

Feature request: add stitch points directly

Hi @LingDong- ,
There has been a request to have the ability to add stitch points directly, within the user's Processing sketch itself. Basically, some users want extremely precise control over where the stitches go. One example is for artistic effects; another example is a CS professor who wants to assign their students to have the problem of designing a stitch-placing algorithm (without having to recompile PEmbroider). Or, perhaps they just don't like where our algorithm has placed the stitches.

The command would have syntax like E.stitch(x,y);

Can it be done? (Does it already exist?)

Errors with shape culling

Shape culling needs some attention, please, as demonstrated by the example, PEmbroider_shape_culling.

Currently, small turds from culled shapes are sporadically left in the scene. As small as these isolated stitches are, they can cause major headaches later when the TSP is run. Below you can see screenshots of PEmbroider_shape_culling, with and without the TSP visualization.

Screen Shot 2020-06-14 at 3 47 34 AM

Screen Shot 2020-06-14 at 3 48 44 AM

A close look also shows that some stitches are culled prematurely, instead of being culled precisely; see magnification below. Perhaps its a related issue. Is culling currently using raster internals?

Untitled

Add optional numTrials argument to E.optimize()?

I'm seeing some VERY long optimization times (on the order of minutes) for large/complex designs. Let's pass in an optional argument for the number of optimization trials, (default 3) so that I can decide to do a quick test, OR to let it run overnight, etc.

Errors rendering image contours with thin strokes

This bug report concerns the Example, PEmbroider_bitmap_image_2, which is tracing the Processing.org logo.

Things look fine with E.strokeWeight(2); E.strokeMode(PEmbroiderGraphics.TANGENT);:
Screen Shot 2020-06-17 at 11 48 14 PM

However, there is a strange error with E.strokeWeight(2); E.strokeMode(PEmbroiderGraphics.PERPENDICULAR);:
Screen Shot 2020-06-17 at 11 48 32 PM

And with E.strokeWeight(1); E.strokeMode(PEmbroiderGraphics.TANGENT);, one of the shapes is omitted altogether:
Screen Shot 2020-06-17 at 11 49 14 PM

results for example Text_1 through 3

Test 1
image
(this above image was before the stroke staggering, redid below with some changes)
image

And a sample to see the difference in Fill first vs Stroke first, stroke first looks a lot better:
image

Text 2
image
fill is a bit sparse with these, will redo with 2 colors and stroke first

Text 3
image
still has stray threads to clean up but some of them are barely legible so I will reprint this example with larger font size

Single line Embroidery

I think it would be beneficial to implement a small repeat stitch at the beginning and end of each line

When using a sewing machine for sewing, when you reach the end of a stitch, you go over the same spot a few times (reverse then go forward again) so that the thread is effectively tied and it does not unravel when you snip the extra thread.
you can see this in a few spots on the ruler in #17 and the image below where I did a test on some lines - even just going over the last stitch one time helped a lot,
image
You can see the bottom version has unraveled in a few places but the top hasn't - I manually went over the last stitch one time, but it should work and look something like this (but with all the stitches having the same Y values) - I'll manually test this out
image

another issue is that lines intersecting at one point don't appear to intersect unless both lines stop at the intersection:

image

you can see the top vertical line seems to be floating about the horizontal line, but if the horizontal line had a stitch start and stop at the intersection there would be no way for it to move out of the way.

Experiments with Hatch and stitch Lengths & suggestions for better fills

Experiments with altering stitch length! and hatch

2020-06-08_16h51_07
2020-06-08_17h21_21

For fills I think it would be beneficial to make the thread stops on alternating layers as far from each other as possible (Like these yellow dots I've drawn in) or at least not very close to the thread stops on neighbor lines - the magenta dots in here are where the stitches start and stop and the yellow is a suggestion for how to make the fill a little better
2020-06-08_17h21_51

so the threads look more like this - this seems to be how other machine embroideries get their fills effectively.

2020-06-08_17h22_22
2020-06-08_17h22_30

other wise it creates valleys in the fill (highlighted in red below) that alter the shape - i think this skewed the circle since it causes the fabric to stretch and is harder on the fabric and more likely to deform or break it since its poking a lot of holes right next to each other instead of spacing them out more
2020-06-08_17h13_22

Also did some tests with outlines, the one on the left has a lower hatch value and the stitch length on both is the same and is the same as the width of the border, decreasing hatch and increasing stitch_length definitely help things look better

2020-06-08_17h20_24

Error with Greek Hershey font

The code:

E.textFont(PEmbroiderFont.GREEK_SIMPLEX);
E.text("Ξεσκεπαζω την ψυχοφθορα βδελυγμια.", 50, 50);

Produces an error:
ArrayIndexOutOfBoundsException: 894

How big is a unit?

@tatyanade , could you kindly do some Internet research and/or some actual tests, to reckon the number of embroidery-units-per-inch (at least, for our Viking Jade 35 machine)? I don't know whether a stitch length of 50 is really long or not, and I don't know how big a circle with diameter 100 will actually appear. Maybe embroider a units ruler?

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

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).

Refactor hatchSpineVF() to remove hatch spacing argument

Currently, calling hatchSpineVF has a second argument, which is the hatch spacing:
PEmbroiderHatchSpine.hatchSpineVF(myImage, 3.0);
This argument should be removed, and hatchSpineVF should instead use the current hatchSpacing() setting.

Option for no overlap of fill and stroke

Is there a way to eliminate overlap of stroke and fill on a singular shape from a bitmap? This is achievable with shapes through culling:

E.beginCull();
  
  E.noStroke();
  E.fill(0,0,0);
  E.circle(100, 100, 100); 
  
  E.noFill();
  E.stroke(255, 255, 0); // yellow stroke
  E.circle(100, 100, 100); 
  
  E.endCull();

(culling v not culling)

2020-06-19_20h47_472020-06-19_20h48_14

but does not work with images

E.beginCull();
  
  E.noStroke();
  E.fill(0,0,0);
  E.image(myImage, 0, 0); 
  
  E.noFill();
  E.stroke(255, 255, 0); // yellow stroke
  E.image(myImage, 0, 0); 
  E.endCull();

2020-06-19_20h49_05

Might be usefull and more legible to have something like 'E.Fill_Stroke_Overlap(false); ' to call function instead of making multiple instances of the same element

Please add .EXP, .JEF, and .XXX file export

Hi @LingDong- ,
I have started to announce PEmbroider on Twitter and there is a strong positive response. We made good choices by selecting .PES and .DST. But there are a few people who would like to help us do testing, whose machines only support other formats. Could you please add support for .EXP, .JEF, and .XXX? Once we do this, we should have all of the necessary formats covered. Here's code for the three formats:

https://github.com/EmbroidePy/EmbroideryIO/blob/master/core/src/main/java/org/embroideryio/embroideryio/ExpWriter.java
https://github.com/EmbroidePy/EmbroideryIO/blob/master/core/src/main/java/org/embroideryio/embroideryio/JefWriter.java
https://github.com/EmbroidePy/EmbroideryIO/blob/master/core/src/main/java/org/embroideryio/embroideryio/XxxWriter.java

The .XXX format is for Singer sewing machines. It seems inappropriate, but it is true.

The online viewer at https://htmtopdf.herokuapp.com/embroidery/ is able to handle all of these formats, for output verification.

Thank you!
Golan

HATCH_SPARSITY does not affect thick strokes

Hi @LingDong- ,

HATCH_SPARSITY currently does not affect the rendering of thick strokes. Either it should, or there should be a separate STROKE_HATCH_SPARSITY property (and maybe also a FILL_HATCH_SPARSITY which maps to the usual HATCH_SPARSITY or both.)

Screen Shot 2020-06-05 at 9 32 02 PM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.