SVG intersections are working

Debug drawing is working too
pull/4/head
Reenforcements 2018-11-22 12:56:35 -05:00
rodzic 584610e943
commit bf947df998
9 zmienionych plików z 269 dodań i 89 usunięć

Wyświetl plik

@ -4,8 +4,8 @@
<list default="true" id="0b5af789-e47c-4138-bdb9-8fa765481e1e" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/PECRender/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/PECRender/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/PES.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/PES.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/PES_Emb_mathutils.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/PES_Emb_mathutils.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/svgFunctions.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/svgFunctions.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -16,7 +16,7 @@
</component>
<component name="CoverageDataManager">
<SUITE FILE_PATH="coverage/PES_Embroidery$svgImport.coverage" NAME="svgImport Coverage Results" MODIFIED="1541478220694" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/src/learning" />
<SUITE FILE_PATH="coverage/PES_Embroidery$main.coverage" NAME="main Coverage Results" MODIFIED="1542903623411" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/src" />
<SUITE FILE_PATH="coverage/PES_Embroidery$main.coverage" NAME="main Coverage Results" MODIFIED="1542909151130" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/src" />
<SUITE FILE_PATH="coverage/PES_Embroidery$PECRender_main.coverage" NAME="PECRender-main Coverage Results" MODIFIED="1542678577371" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/PECRender" />
<SUITE FILE_PATH="coverage/PES_Embroidery$main__1_.coverage" NAME="PECRender-main Coverage Results" MODIFIED="1542509072203" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/PECRender" />
</component>
@ -36,25 +36,25 @@
<usages-collector id="statistics.vcs.git.usages" />
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="Python" value="17980" />
<entry key="Python" value="20405" />
</counts>
</usages-collector>
<usages-collector id="statistics.js.language.service.starts" />
<usages-collector id="statistics.file.types.open">
<counts>
<entry key="Python" value="16" />
<entry key="Python" value="21" />
<entry key="UML" value="1" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.open">
<counts>
<entry key="JavaScript-modules-diagram//Users/imaustyn/Documents/MiamiUniversity/ECE 487/Project/PES-Embroidery" value="1" />
<entry key="py" value="16" />
<entry key="py" value="21" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.edit">
<counts>
<entry key="py" value="17980" />
<entry key="py" value="20405" />
</counts>
</usages-collector>
</session>
@ -64,8 +64,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="375">
<caret line="25" column="16" lean-forward="true" selection-start-line="25" selection-start-column="16" selection-end-line="25" selection-end-column="16" />
<state relative-caret-position="307">
<caret line="33" column="12" lean-forward="true" selection-start-line="33" selection-start-column="12" selection-end-line="33" selection-end-column="12" />
<folding>
<element signature="e#0#15#0" expanded="true" />
</folding>
@ -73,11 +73,41 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/PES_render_utils.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="390">
<caret line="26" column="13" lean-forward="true" selection-start-line="26" selection-start-column="13" selection-end-line="26" selection-end-column="13" />
<folding>
<element signature="e#0#13#0" expanded="true" />
<marker date="1542906615593" expanded="true" signature="129:130" ph="..." />
<marker date="1542906615593" expanded="true" signature="129:135" ph="..." />
<marker date="1542906615593" expanded="true" signature="1186:1387" ph="..." />
<marker date="1542906615593" expanded="true" signature="1414:1509" ph="..." />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/PECRender/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="43" column="22" selection-start-line="43" selection-start-column="22" selection-end-line="43" selection-end-column="22" />
<folding>
<element signature="e#0#10#0" expanded="true" />
<marker date="1542908086234" expanded="true" signature="272:446" ph="..." />
<marker date="1542908086234" expanded="true" signature="6331:6335" ph="..." />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/PES.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="317">
<caret line="165" column="12" lean-forward="true" selection-start-line="165" selection-start-column="12" selection-end-line="165" selection-end-column="12" />
<state relative-caret-position="353">
<caret line="163" lean-forward="true" selection-start-line="163" selection-end-line="163" />
<folding>
<element signature="e#0#23#0" expanded="true" />
<marker date="1542903616715" expanded="true" signature="121:198" ph="..." />
@ -91,33 +121,42 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/svgFunctions.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" column="14" lean-forward="true" selection-start-line="6" selection-start-column="14" selection-end-line="6" selection-end-column="14" />
<state relative-caret-position="420">
<caret line="84" column="61" selection-start-line="84" selection-start-column="61" selection-end-line="84" selection-end-column="61" />
<folding>
<element signature="e#0#19#0" expanded="true" />
<marker date="1542903295377" expanded="true" signature="343:344" ph="..." />
<marker date="1542903295377" expanded="true" signature="343:348" ph="..." />
<marker date="1542909370179" expanded="true" signature="374:375" ph="..." />
<marker date="1542909370179" expanded="true" signature="374:438" ph="..." />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file:///usr/local/lib/python2.7/site-packages/svgpathtools/path.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="199">
<caret line="1120" column="8" selection-start-line="1120" selection-start-column="8" selection-end-line="1120" selection-end-column="8" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/PES_Emb_mathutils.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="231">
<caret line="34" column="8" selection-start-line="34" selection-start-column="8" selection-end-line="34" selection-end-column="8" />
<state relative-caret-position="297">
<caret line="31" column="69" selection-start-line="31" selection-start-column="69" selection-end-line="31" selection-end-column="69" />
<folding>
<element signature="e#0#29#0" expanded="true" />
<marker date="1542903637276" expanded="true" signature="112:1608" ph="..." />
<marker date="1542903637276" expanded="true" signature="372:434" ph="..." />
<marker date="1542903637276" expanded="true" signature="618:1401" ph="..." />
<marker date="1542903637276" expanded="true" signature="1659:1735" ph="..." />
<marker date="1542903637276" expanded="true" signature="1806:1811" ph="..." />
<marker date="1542903637276" expanded="true" signature="1806:2287" ph="..." />
<marker date="1542908071934" expanded="true" signature="112:1695" ph="..." />
<marker date="1542908071934" expanded="true" signature="401:624" ph="..." />
<marker date="1542908071934" expanded="true" signature="694:1488" ph="..." />
<marker date="1542908071934" expanded="true" signature="1746:1822" ph="..." />
<marker date="1542908071934" expanded="true" signature="1893:1898" ph="..." />
<marker date="1542908071934" expanded="true" signature="1893:2374" ph="..." />
</folding>
</state>
</provider>
@ -132,20 +171,6 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/PECRender/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="30" lean-forward="true" selection-start-line="30" selection-end-line="30" />
<folding>
<element signature="e#0#10#0" expanded="true" />
<marker date="1542678576291" expanded="true" signature="272:446" ph="..." />
<marker date="1542678576291" expanded="true" signature="6331:6335" ph="..." />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
@ -174,10 +199,15 @@
<find>getStartAndEndPointsOfLineInBox</find>
<find>makeStitchLines</find>
<find>getBoxDiagonalLength</find>
<find>readBytes</find>
<find>to_svg</find>
<find>InfLine</find>
<find>to_svg</find>
<find>to_svg_Line</find>
<find>svgpathtools</find>
<find>invert</find>
<find>invertSlope</find>
<find>intersectionPath</find>
<find>readBytes</find>
<find>imag</find>
</findStrings>
</component>
<component name="Git.Settings">
@ -192,11 +222,12 @@
<option value="$PROJECT_DIR$/src/svg.py" />
<option value="$PROJECT_DIR$/src/PES-Emb-mathutils.py" />
<option value="$PROJECT_DIR$/src/utilities.py" />
<option value="$PROJECT_DIR$/src/PES.py" />
<option value="$PROJECT_DIR$/src/main.py" />
<option value="$PROJECT_DIR$/src/PES_render_utils.py" />
<option value="$PROJECT_DIR$/src/PES_Emb_mathutils.py" />
<option value="$PROJECT_DIR$/PECRender/main.py" />
<option value="$PROJECT_DIR$/src/svgFunctions.py" />
<option value="$PROJECT_DIR$/src/PES.py" />
<option value="$PROJECT_DIR$/src/PES_Emb_mathutils.py" />
</list>
</option>
</component>
@ -367,7 +398,7 @@
<frame x="0" y="23" width="1680" height="1027" extended-state="0" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.27106228" />
<window_info content_ui="combo" id="Project" order="0" weight="0.27106228" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
@ -389,6 +420,29 @@
<window_info anchor="right" id="SciView" order="3" />
<window_info anchor="right" id="Database" order="4" />
</layout>
<layout-to-restore>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.27106228" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.32941177" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Version Control" order="8" show_stripe_button="false" />
<window_info anchor="bottom" id="Database Changes" order="9" show_stripe_button="false" />
<window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
<window_info anchor="bottom" id="Terminal" order="11" />
<window_info anchor="bottom" id="Python Console" order="12" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="SciView" order="3" />
<window_info anchor="right" id="Database" order="4" />
</layout-to-restore>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
@ -439,18 +493,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/PECRender/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="30" lean-forward="true" selection-start-line="30" selection-end-line="30" />
<folding>
<element signature="e#0#10#0" expanded="true" />
<marker date="1542678576291" expanded="true" signature="272:446" ph="..." />
<marker date="1542678576291" expanded="true" signature="6331:6335" ph="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/utilities.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
@ -458,32 +500,83 @@
</state>
</provider>
</entry>
<entry file="file:///usr/local/lib/python2.7/site-packages/svgpathtools/bezier.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="387">
<caret line="352" selection-start-line="352" selection-end-line="352" />
</state>
</provider>
</entry>
<entry file="file:///usr/local/lib/python2.7/site-packages/pyglet/clock.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="199">
<caret line="345" selection-start-line="345" selection-end-line="345" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="375">
<caret line="25" column="16" lean-forward="true" selection-start-line="25" selection-start-column="16" selection-end-line="25" selection-end-column="16" />
<state relative-caret-position="307">
<caret line="33" column="12" lean-forward="true" selection-start-line="33" selection-start-column="12" selection-end-line="33" selection-end-column="12" />
<folding>
<element signature="e#0#15#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/svgFunctions.py">
<entry file="file://$PROJECT_DIR$/src/PES_Emb_mathutils.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" column="14" lean-forward="true" selection-start-line="6" selection-start-column="14" selection-end-line="6" selection-end-column="14" />
<state relative-caret-position="297">
<caret line="31" column="69" selection-start-line="31" selection-start-column="69" selection-end-line="31" selection-end-column="69" />
<folding>
<element signature="e#0#19#0" expanded="true" />
<marker date="1542903295377" expanded="true" signature="343:344" ph="..." />
<marker date="1542903295377" expanded="true" signature="343:348" ph="..." />
<element signature="e#0#29#0" expanded="true" />
<marker date="1542908071934" expanded="true" signature="112:1695" ph="..." />
<marker date="1542908071934" expanded="true" signature="401:624" ph="..." />
<marker date="1542908071934" expanded="true" signature="694:1488" ph="..." />
<marker date="1542908071934" expanded="true" signature="1746:1822" ph="..." />
<marker date="1542908071934" expanded="true" signature="1893:1898" ph="..." />
<marker date="1542908071934" expanded="true" signature="1893:2374" ph="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file:///usr/local/lib/python2.7/site-packages/svgpathtools/path.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="199">
<caret line="1120" column="8" selection-start-line="1120" selection-start-column="8" selection-end-line="1120" selection-end-column="8" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/PECRender/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="43" column="22" selection-start-line="43" selection-start-column="22" selection-end-line="43" selection-end-column="22" />
<folding>
<element signature="e#0#10#0" expanded="true" />
<marker date="1542908086234" expanded="true" signature="272:446" ph="..." />
<marker date="1542908086234" expanded="true" signature="6331:6335" ph="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/PES_render_utils.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="390">
<caret line="26" column="13" lean-forward="true" selection-start-line="26" selection-start-column="13" selection-end-line="26" selection-end-column="13" />
<folding>
<element signature="e#0#13#0" expanded="true" />
<marker date="1542906615593" expanded="true" signature="129:130" ph="..." />
<marker date="1542906615593" expanded="true" signature="129:135" ph="..." />
<marker date="1542906615593" expanded="true" signature="1186:1387" ph="..." />
<marker date="1542906615593" expanded="true" signature="1414:1509" ph="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/PES.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="317">
<caret line="165" column="12" lean-forward="true" selection-start-line="165" selection-start-column="12" selection-end-line="165" selection-end-column="12" />
<state relative-caret-position="353">
<caret line="163" lean-forward="true" selection-start-line="163" selection-end-line="163" />
<folding>
<element signature="e#0#23#0" expanded="true" />
<marker date="1542903616715" expanded="true" signature="121:198" ph="..." />
@ -496,18 +589,14 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/PES_Emb_mathutils.py">
<entry file="file://$PROJECT_DIR$/src/svgFunctions.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="231">
<caret line="34" column="8" selection-start-line="34" selection-start-column="8" selection-end-line="34" selection-end-column="8" />
<state relative-caret-position="420">
<caret line="84" column="61" selection-start-line="84" selection-start-column="61" selection-end-line="84" selection-end-column="61" />
<folding>
<element signature="e#0#29#0" expanded="true" />
<marker date="1542903637276" expanded="true" signature="112:1608" ph="..." />
<marker date="1542903637276" expanded="true" signature="372:434" ph="..." />
<marker date="1542903637276" expanded="true" signature="618:1401" ph="..." />
<marker date="1542903637276" expanded="true" signature="1659:1735" ph="..." />
<marker date="1542903637276" expanded="true" signature="1806:1811" ph="..." />
<marker date="1542903637276" expanded="true" signature="1806:2287" ph="..." />
<element signature="e#0#19#0" expanded="true" />
<marker date="1542909370179" expanded="true" signature="374:375" ph="..." />
<marker date="1542909370179" expanded="true" signature="374:438" ph="..." />
</folding>
</state>
</provider>

Wyświetl plik

@ -210,7 +210,7 @@ def on_key_release(symbol, modifiers):
def updateDisplay(s):
window.clear()
pyglet.gl.glLineWidth(2)
pyglet.gl.glLineWidth(1)
# Stitch a line

Wyświetl plik

@ -6,6 +6,7 @@ import numpy
class InfLine:
def __init__(self, m, center):
self.m = m
self.center = center
self.b = center.imag - (center.real * m)
def x_for_y(self, y):
@ -16,14 +17,15 @@ class InfLine:
def invertSlope(self):
if self.m is not 0:
self.m = 1 / self.m
m2 = -1.0 / self.m
# Find a new b to maintain the center
b2 = (self.center.imag - (m2 * self.center.real))
self.m = m2
self.b = b2
def to_svg_Line(self, center, length):
# center = 2.0+0j
# length = 2.0*math.pow(8.0, 0.5)
# self.m = 1.0
# self.b = -2
dist = length / 2.0
# Find the two values of x that are "dist" down each
# side of the line.
@ -32,13 +34,13 @@ class InfLine:
xRoots = numpy.roots([ (1 + math.pow(self.m, 2.0) ),
((-2 * center.real * math.pow(self.m, 2.0)) - (2*center.real)),
(math.pow(center.real, 2.0)*math.pow(self.m, 2.0)) + (math.pow(center.real, 2.0)) - (math.pow(dist, 2.0)) ])
assert(len(xRoots) == 2)
assert(numpy.isreal(xRoots[0]))
assert (numpy.isreal(xRoots[1]))
return Line(start=(xRoots[0], self.y_for_x(xRoots[0])),
end=(xRoots[1], self.y_for_x(xRoots[1])))
return Line( start=complex(xRoots[0], self.y_for_x(xRoots[0]) ),
end= complex(xRoots[1], self.y_for_x(xRoots[1])) )
# h = length / 2.0

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -0,0 +1,49 @@
import pyglet
from svgpathtools import Line, CubicBezier, QuadraticBezier, Path
class GenericRenderer:
globalRenderer = None
def __init__(self):
# Make a new window to render into
self.window = pyglet.window.Window()
self.window.set_size(1000, 1000)
self.window.set_location(300, 0)
pyglet.gl.glClearColor(0.4, 0.4, 0.4, 1)
self.lineBatch = pyglet.graphics.Batch()
self.pointBatch = pyglet.graphics.Batch()
pyglet.gl.glLineWidth(2)
self.addLine(Line(start=(0+0j), end=(1000+1000j)), 255, 0, 0)
GenericRenderer.globalRenderer = self
def addLine(self, line, r, g, b):
self.lineBatch.add(2, pyglet.gl.GL_LINES, None,
('v2f', (line.start.real, line.start.imag, line.end.real, line.end.imag)),
('c3B', (r,g,b, r,g,b))
)
def addPath(self, path, r, g, b):
for shape in path:
for x in range(0, 99):
x1 = x / 100.0
x2 = x1 + 0.01
self.addLine(Line(start=shape.point(x1), end=shape.point(x2)), r, g, b)
def addPoint(self, point, r, g, b):
self.pointBatch.add(1, pyglet.gl.GL_POINTS, None,
('v2f', (point.real, point.imag)),
('c3B', (r, g, b))
)
def updateDisplay(self, s):
self.window.clear()
self.lineBatch.draw()
self.pointBatch.draw()
def runLoop(self):
pyglet.clock.schedule_interval(self.updateDisplay, 1 / 30.0)
pyglet.app.run()

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -4,8 +4,9 @@ from svgFunctions import *
import pyembroidery
from utilities import *
from PES import *
from PES_render_utils import *
# Argument parsing
parser = argparse.ArgumentParser(description="Converts an SVG file into a PES embroidery file.")
parser.add_argument("-i", dest="inputFile", type=str, action='store', required=True)
@ -14,6 +15,10 @@ parser.add_argument("-d", dest="debug", action='store_true')
args = parser.parse_args()
if args.debug:
# Create a generic renderer so we can see what's happening
renderer = GenericRenderer()
# Load the SVG file from disk
svg = loadVectorGraphic(args.inputFile)
paths, attributes = svg
@ -22,8 +27,8 @@ if paths is None or attributes is None:
# Enumerate the shapes in the SVG to find where stitches should go.
for shape in paths:
stitchLines = makeStitchLines(shape)
print(shape)
stitchLines = makeStitchLines(shape)
pes = PES()
pes.encode()
@ -35,3 +40,7 @@ if args.debug:
pyembroidery.write_png(loadedPES, replaceFilenameAndExtensionFromPath(args.inputFile, "debugPicture", "png"))
else:
print("Couldn't find output file.")
# Show what the program did in the debug window
# until the user quits.
GenericRenderer.globalRenderer.runLoop()

Wyświetl plik

@ -1,5 +1,6 @@
import svgpathtools
from PES_Emb_mathutils import *
from PES_render_utils import *
from PES import Stitch
import numpy
@ -13,6 +14,10 @@ def loadVectorGraphic(filename):
return svg
def makeStitchLines(shape, threadWidth=0.04, slope=1):
"""
:type shape: svgpathtools.CubicBezier
"""
stitchLines = []
# Get the bounds of the shape
@ -35,6 +40,7 @@ def makeStitchLines(shape, threadWidth=0.04, slope=1):
intersectionPath.invertSlope()
p1, p2 = getStartAndEndPointsOfLineInBox(intersectionPath, left, right, top, bottom)
intersectionPath = Line(start=p1, end=p2)
#print("Start and end points: {}, {}".format(p1,p2))
#intersectionPath = intersectionPath.to_svg_Line(center=center, length=intersectionLineLength)
@ -48,16 +54,41 @@ def makeStitchLines(shape, threadWidth=0.04, slope=1):
# Get the max length of the intersection lines we'll need
intersectionLineLength = getBoxDiagonalLength(left, right, top, bottom)
print("Total intersections: {} along path: {}".format(totalIntersections, intersectionPath))
print("Performing up to {} intersections along path: {}".format(totalIntersections, intersectionPath))
print("(From {} to {})".format(intersectionPath.point(0), intersectionPath.point(1.0)))
GenericRenderer.globalRenderer.addPath(shape, 50, 120, 255)
for x in range(0, totalIntersections):
# Get a new (infinite) line using the point at the current t value
# as the center
center = intersectionPath.point((tIncrementAmount * x) / pathLength)
GenericRenderer.globalRenderer.addPoint(center, 255, 255, 0)
i = InfLine(m=slope, center=center)
# Convert it to a bezier line
l = i.to_svg_Line(center=center, length=intersectionLineLength)
print((tIncrementAmount * x) / pathLength, l)
GenericRenderer.globalRenderer.addLine(l, 255, 255, 255)
# Intersect with the shape
intersections = shape.intersect(l)
if len(intersections) % 2 is not 0:
s = "Number of intersections should always be even (its {} ). Make sure all shapes are closed shapes.".format(len(intersections))
raise Exception(s)
# Iterate through the intersections to find where to put stitches
for i in range(0, len( intersections )/2):
start = l.point(intersections[i][1][0])
end = l.point(intersections[i+1][1][0])
# Create a stitch for the given start and end points
l = Line(start=start, end=end)
# Choose a stitch format based on the last stitch
s = Stitch(line=l)
stitchLines.append(s)
# Draw lines
GenericRenderer.globalRenderer.addLine(l, 255, 0, 50)
return stitchLines

Plik binarny nie jest wyświetlany.