Outputs basic PES files that work!

main
branchwelder 2022-02-18 16:19:36 -08:00
rodzic 7f99ee1187
commit 00bbda03e5
13 zmienionych plików z 257 dodań i 0 usunięć

3
.vscode/settings.json vendored 100644
Wyświetl plik

@ -0,0 +1,3 @@
{
"terminal.integrated.cwd": "${workspaceFolder}"
}

Wyświetl plik

@ -0,0 +1,3 @@
.background {
background-color: blueviolet;
}

Wyświetl plik

@ -0,0 +1,31 @@
import React from "react";
import "./TemplateAction.css";
export default class Embroidery extends React.Component {
constructor(props) {
super(props);
this.state = {
flag: true,
};
}
backendMethod() {
fetch("/runBackendMethod", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
method: "templateActionMethod", // The method to run
actionID: this.props.action.id,
}),
})
.then((res) => res.json())
.then((asdf) => {
console.log(asdf);
});
}
render() {
return <div className='background'>Content goes here!</div>;
}
}

Wyświetl plik

@ -0,0 +1,29 @@
from app.planager.workflow.Action import Action
CONFIG = {
"displayName": "Embroidery",
"inports": {
"templateInput": {
"displayName": "TemplateAction",
"description": "TemplateAction",
}
},
"outports": {
"templateOutput": {
"displayName": "TemplateAction",
"description": "TemplateAction",
}
},
}
class Embroidery(Action):
def __init__(self):
Action.__init__(self, CONFIG)
def main(self):
"""The main loop; this is what runs when the action is run."""
print("main loop")
def templateActionMethod(self, options):
print("template method")

56
embryoid.py 100644
Wyświetl plik

@ -0,0 +1,56 @@
from rich import print
from pyembroidery import *
from svgpathtools import svg2paths, wsvg
import numpy as np
OUTPUT_PES = "pes_tests/"
OUTPUT_SVG = "svg_tests/"
class Embryoid:
def __init__(self):
self.pattern = EmbPattern()
def save_svg(self, fname=OUTPUT_SVG + "design.svg"):
write_svg(self.pattern, fname)
def save_pes(self, fname=OUTPUT_PES + "design.pes"):
write_pes(self.pattern, fname)
def add_stitch_block(self, block):
self.pattern.add_block(block)
def parse_svg(self, fname):
paths, attributes = svg2paths(fname)
print(attributes)
for path in paths:
block = []
for segment in path._segments:
block.append((segment.start.real, segment.start.imag))
block.append((path._segments[0].start.real, path._segments[0].start.imag))
self.pattern.add_block(block, "teal")
def solid_block(x_len=100, y_len=100, num_stitches=20):
stitches = []
stitches_y_coords = np.linspace(0, y_len, num_stitches)
for stitch_y in stitches_y_coords:
stitches.append((0, stitch_y))
stitches.append((x_len, stitch_y))
return stitches
def parse():
e = Embryoid()
e.parse_svg("star.svg")
e.save_svg("star_test.svg")
e.save_pes("result.pes")
if __name__ == "__main__":
e = Embryoid()
e.add_stitch_block(solid_block())
e.save_svg("block_test.svg")
e.save_pes("block_test.pes")

15
requirements.txt 100644
Wyświetl plik

@ -0,0 +1,15 @@
black==22.1.0
click==8.0.3
colorama==0.4.4
commonmark==0.9.1
mypy-extensions==0.4.3
numpy==1.22.2
pathspec==0.9.0
platformdirs==2.5.0
pyembroidery==1.4.33
Pygments==2.11.2
rich==11.2.0
scipy==1.8.0
svgpathtools==1.4.4
svgwrite==1.4.1
tomli==2.0.1

Wyświetl plik

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg12"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
sodipodi:docname="star.svg.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview14"
pagecolor="#505050"
bordercolor="#eeeeee"
borderopacity="1"
inkscape:pageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="0.32026164"
inkscape:cx="-65.571386"
inkscape:cy="896.14228"
inkscape:window-width="1920"
inkscape:window-height="1028"
inkscape:window-x="-6"
inkscape:window-y="-6"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs9" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
sodipodi:type="star"
style="fill:#0000ff"
id="path38"
inkscape:flatsided="false"
sodipodi:sides="7"
sodipodi:cx="212.32639"
sodipodi:cy="352.83652"
sodipodi:r1="266.94638"
sodipodi:r2="133.47319"
sodipodi:arg1="1.1490091"
sodipodi:arg2="1.597808"
inkscape:rounded="0"
inkscape:randomized="0"
d="M 321.61202,596.38738 208.72149,486.26102 90.049134,590.13094 105.76329,433.20691 -49.436486,405.18697 83.049281,319.63226 8.1906761,180.82203 157.68356,231.06109 219.53619,85.987517 273.46501,234.1893 l 151.98756,-42.09356 -82.24475,134.56555 127.67277,92.58376 -156.48635,19.5987 z"
transform="matrix(0.26458333,0,0,0.26458333,27.262865,-9.9137691)"
inkscape:transform-center-x="0.42447985"
inkscape:transform-center-y="-3.0821517" />
</g>
</svg>

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.0 KiB

Wyświetl plik

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100mm"
height="100mm"
viewBox="0 0 100 100"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
sodipodi:docname="test.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#505050"
bordercolor="#eeeeee"
borderopacity="1"
inkscape:pageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="0.90583672"
inkscape:cx="-64.581175"
inkscape:cy="360.99221"
inkscape:window-width="1920"
inkscape:window-height="1028"
inkscape:window-x="-6"
inkscape:window-y="-6"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:#0000ff;stroke-width:0.383311"
id="rect103"
width="40.095089"
height="67.024628"
x="26.795521"
y="10.968253" />
<rect
style="fill:#ffff00;stroke-width:0.528045"
id="rect53"
width="5.7712412"
height="78.311577"
x="76.78405"
y="-19.638121"
transform="matrix(0.86221591,0.50654094,-0.52622018,0.85034835,0,0)" />
</g>
</svg>

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.6 KiB

Plik binarny nie jest wyświetlany.

BIN
tests_pes/star.pes 100644

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -0,0 +1 @@
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" width="100.0" height="100.0" viewBox="0.0 0.0 100.0 100.0"><path d="M 0.0,0.0 100.0,0.0 0.0,5.2631578947368425 100.0,5.2631578947368425 0.0,10.526315789473685 100.0,10.526315789473685 0.0,15.789473684210527 100.0,15.789473684210527 0.0,21.05263157894737 100.0,21.05263157894737 0.0,26.315789473684212 100.0,26.315789473684212 0.0,31.578947368421055 100.0,31.578947368421055 0.0,36.8421052631579 100.0,36.8421052631579 0.0,42.10526315789474 100.0,42.10526315789474 0.0,47.36842105263158 100.0,47.36842105263158 0.0,52.631578947368425 100.0,52.631578947368425 0.0,57.89473684210527 100.0,57.89473684210527 0.0,63.15789473684211 100.0,63.15789473684211 0.0,68.42105263157896 100.0,68.42105263157896 0.0,73.6842105263158 100.0,73.6842105263158 0.0,78.94736842105263 100.0,78.94736842105263 0.0,84.21052631578948 100.0,84.21052631578948 0.0,89.47368421052633 100.0,89.47368421052633 0.0,94.73684210526316 100.0,94.73684210526316 0.0,100.0 100.0,100.0" fill="none" stroke="#b0852e" stroke-width="3" /></svg>

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.1 KiB

Wyświetl plik

@ -0,0 +1 @@
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" width="55.7597702" height="97.63100200000001" viewBox="26.795521 -19.638121 55.7597702 97.63100200000001"><path d="M 26.795521,10.968253 66.89061000000001,10.968253 66.89061000000001,77.99288100000001 26.795521,77.99288100000001 26.795521,10.968253" fill="none" stroke="#008080" stroke-width="3" /><path d="M 76.78405,-19.638121 82.5552912,-19.638121 82.5552912,58.673456 76.78405,58.673456 76.78405,-19.638121" fill="none" stroke="#008080" stroke-width="3" /></svg>

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 608 B

Wyświetl plik

@ -0,0 +1 @@
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" width="520.317076" height="510.399863" viewBox="-49.436486 85.987517 520.317076 510.399863"><path d="M 321.61202,596.38738 208.72149,486.26102 90.049134,590.13094 105.76329,433.20691 -49.436486,405.18697 83.049281,319.63226 8.1906761,180.82203 157.68356,231.06109 219.53619,85.987517 273.46501,234.1893 425.45257000000004,192.09574 343.20782,326.66129 470.88059000000004,419.24505 314.3942400000001,438.84375 321.61202,596.38738" fill="none" stroke="#008080" stroke-width="3" /></svg>

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 626 B