svg2gcode 4.0.3__tar.gz → 4.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/PKG-INFO +1 -1
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/__init__.py +1 -1
- svg2gcode-4.0.5/svg2gcode/svg_examples/nonzero_evenodd.svg +47 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/compiler/_compiler.py +33 -11
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/LICENSE +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/README.md +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/pyproject.toml +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/__main__.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_examples/README.md +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_examples/gcode_output.zip +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_examples/kye_circle_paws_orig copy.svg +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_examples/kye_circle_paws_orig.svg +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_examples/letterandsigns.svg +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/LICENSE +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/__init__.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/compiler/__init__.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/compiler/interfaces/__init__.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/compiler/interfaces/_abstract_interface.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/compiler/interfaces/_fan_controlled_gcode.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/compiler/interfaces/_gcode.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/css_color.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/formulas.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/geometry/__init__.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/geometry/_abstract_chain.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/geometry/_abstract_curve.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/geometry/_circular_arc.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/geometry/_cubic_bazier.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/geometry/_elliptical_arc.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/geometry/_line.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/geometry/_line_segment_chain.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/geometry/_matrix.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/geometry/_quadratic_bazier.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/geometry/_raster_image.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/geometry/_smooth_arc_chain.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/geometry/_vector.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/svg_parser/__init__.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/svg_parser/_parser_methods.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/svg_parser/_path.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/svg_parser/_transformation.py +0 -0
- {svg2gcode-4.0.3 → svg2gcode-4.0.5}/svg2gcode/svg_to_gcode/svg_parser/debug_methods.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: svg2gcode
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.5
|
|
4
4
|
Summary: svg2gcode: convert an SVG (Scalable Vector Graphic) image to gcode.
|
|
5
5
|
Keywords: scalable vector graphics,svg,image,laser cutter,laser engraving
|
|
6
6
|
Author-email: Johannes Noordanus <mailjohannes.mailnoordanus@gmail.com>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<svg
|
|
3
|
+
viewBox="-10 -10 220 120"
|
|
4
|
+
version="1.1"
|
|
5
|
+
id="svg2"
|
|
6
|
+
sodipodi:docname="nonzero_evenodd.svg"
|
|
7
|
+
inkscape:version="1.4.4 (dcaf3e7d, 2026-05-05)"
|
|
8
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
9
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
xmlns:svg="http://www.w3.org/2000/svg">
|
|
12
|
+
<defs
|
|
13
|
+
id="defs2" />
|
|
14
|
+
<sodipodi:namedview
|
|
15
|
+
id="namedview2"
|
|
16
|
+
pagecolor="#ffffff"
|
|
17
|
+
bordercolor="#000000"
|
|
18
|
+
borderopacity="0.25"
|
|
19
|
+
inkscape:showpageshadow="2"
|
|
20
|
+
inkscape:pageopacity="0.0"
|
|
21
|
+
inkscape:pagecheckerboard="0"
|
|
22
|
+
inkscape:deskcolor="#d1d1d1"
|
|
23
|
+
inkscape:zoom="3.9727273"
|
|
24
|
+
inkscape:cx="104.71396"
|
|
25
|
+
inkscape:cy="56.887872"
|
|
26
|
+
inkscape:window-width="1214"
|
|
27
|
+
inkscape:window-height="1187"
|
|
28
|
+
inkscape:window-x="424"
|
|
29
|
+
inkscape:window-y="58"
|
|
30
|
+
inkscape:window-maximized="0"
|
|
31
|
+
inkscape:current-layer="svg2" />
|
|
32
|
+
<!-- Default value for fill-rule -->
|
|
33
|
+
<path
|
|
34
|
+
id="polygon1"
|
|
35
|
+
style="stroke:#ff0000;fill:#00A0A0;stroke-width:0.3"
|
|
36
|
+
d="M 50,0 21,90 98,35 H 2 l 77,55 z" />
|
|
37
|
+
<!--
|
|
38
|
+
The center of the shape has two
|
|
39
|
+
path segments (shown by the red stroke)
|
|
40
|
+
between it and infinity. It is therefore
|
|
41
|
+
considered outside the shape, and not filled.
|
|
42
|
+
-->
|
|
43
|
+
<path
|
|
44
|
+
id="polygon2"
|
|
45
|
+
style="fill-rule:evenodd;fill:#FFFFFF;stroke:#ff0000;stroke-width:0.1"
|
|
46
|
+
d="m 150,0 -29,90 77,-55 h -96 l 77,55 z" />
|
|
47
|
+
</svg>
|
|
@@ -35,9 +35,25 @@ from svg2gcode import __version__
|
|
|
35
35
|
from image2gcode.boundingbox import Boundingbox # type: ignore[import-untyped]
|
|
36
36
|
from image2gcode.image2gcode import Image2gcode # type: ignore[import-untyped]
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
class OnceFilter(logging.Filter):
|
|
39
|
+
"""log same messages only once"""
|
|
40
|
+
def __init__(self):
|
|
41
|
+
super().__init__()
|
|
42
|
+
self.logged_messages = set()
|
|
43
|
+
|
|
44
|
+
def filter(self, record):
|
|
45
|
+
# Use message string is key
|
|
46
|
+
log_entry = record.getMessage()
|
|
47
|
+
if log_entry in self.logged_messages:
|
|
48
|
+
# duplicate if message in set()
|
|
49
|
+
return False # Do not log
|
|
50
|
+
self.logged_messages.add(log_entry)
|
|
51
|
+
return True # Log it
|
|
52
|
+
|
|
53
|
+
# Setup logger, add filter to display messages only once.
|
|
40
54
|
logger = logging.getLogger(__name__)
|
|
55
|
+
logger.addFilter(OnceFilter())
|
|
56
|
+
logging.basicConfig(format="[%(levelname)s] %(message)s")
|
|
41
57
|
logger.setLevel(logging.INFO)
|
|
42
58
|
|
|
43
59
|
# fan codes
|
|
@@ -122,7 +138,7 @@ class Compiler:
|
|
|
122
138
|
gcode += ["; WARNING: Cut is not within machine bounds of "
|
|
123
139
|
f"X[0,{self.settings['x_axis_maximum_travel']}], Y[0,{self.settings['y_axis_maximum_travel']}]\n",]
|
|
124
140
|
elif not self.check_axis_maximum_travel():
|
|
125
|
-
|
|
141
|
+
logger.warning("Please define machine cutting area, set parameter: 'x_axis_maximum_travel' and 'y_axis_maximum_travel'")
|
|
126
142
|
gcode += ["; WARNING: Please define machine cutting area, set parameter: 'x_axis_maximum_travel' and 'y_axis_maximum_travel'\n",]
|
|
127
143
|
else:
|
|
128
144
|
gcode += [f"; WARNING: distance mode is not absolute: {self.settings['distance_mode']}\n",]
|
|
@@ -473,14 +489,14 @@ class Compiler:
|
|
|
473
489
|
|
|
474
490
|
# parse fill
|
|
475
491
|
if style['fill'] is None and 'fill' in style_str:
|
|
476
|
-
fill = re.search('fill:[^;]
|
|
492
|
+
fill = re.search('fill:[^;]+(?:;|$)',style_str)
|
|
477
493
|
if fill:
|
|
478
494
|
fill_str = fill.group(0)[5:-1]
|
|
479
495
|
if fill_str != 'none':
|
|
480
496
|
style['fill'] = fill_str
|
|
481
497
|
# parse fill-rule
|
|
482
498
|
if style['fill-rule'] is None and 'fill-rule' in style_str:
|
|
483
|
-
fill_rule = re.search('fill-rule
|
|
499
|
+
fill_rule = re.search('fill-rule: ?(evenodd|nonzero)',style_str)
|
|
484
500
|
if fill_rule:
|
|
485
501
|
style['fill-rule'] = re.search('(evenodd|nonzero)', fill_rule.group(0)).group(0)
|
|
486
502
|
# parse fill-opacity
|
|
@@ -490,7 +506,7 @@ class Compiler:
|
|
|
490
506
|
style['fill-opacity'] = re.search(r'(\d*\.)?\d+', fill_opacity.group(0)).group(0)
|
|
491
507
|
# parse stroke
|
|
492
508
|
if style['stroke'] is None and 'stroke' in style_str:
|
|
493
|
-
stroke = re.search('stroke:[^;]
|
|
509
|
+
stroke = re.search('stroke:[^;]+(?:;|$)',style_str)
|
|
494
510
|
if stroke:
|
|
495
511
|
stroke_str = stroke.group(0)[7:-1]
|
|
496
512
|
if stroke_str != 'none':
|
|
@@ -730,21 +746,26 @@ class Compiler:
|
|
|
730
746
|
# fill opacity attribute overrides rgba property
|
|
731
747
|
stroke_alpha = float(style['stroke-opacity'])
|
|
732
748
|
if not 0 <= stroke_alpha <= 1:
|
|
733
|
-
logger.warning(f"
|
|
749
|
+
logger.warning(f"Attribute 'opacity' with value '{stroke_alpha}' should be in range [0.0..1.0]!")
|
|
734
750
|
stroke_alpha = 1
|
|
735
751
|
if style['stroke-width'] is not None and style['stroke-width'] != 'none':
|
|
736
752
|
width = float(style['stroke-width'])
|
|
737
753
|
stroke_width = math.ceil(round(width/pixel_size, self.precision)/2)
|
|
754
|
+
if not style['stroke']:
|
|
755
|
+
logger.warning(f"Attribute 'stroke width' is set to '{style['stroke-width']}', but no stroke color given: skip this path.")
|
|
756
|
+
|
|
738
757
|
if style['fill'] is not None and style['fill'] != 'none':
|
|
739
758
|
fill_color = style['fill']
|
|
740
|
-
if style['fill-
|
|
741
|
-
fill_rule = style['fill-rule']
|
|
742
|
-
if style['fill-opacity'] is not None:
|
|
759
|
+
if style['fill-opacity'] is not None :
|
|
743
760
|
# fill opacity attribute overrides rgba property
|
|
744
761
|
fill_alpha = float(style['fill-opacity'])
|
|
745
762
|
if not 0 <= fill_alpha <= 1:
|
|
746
|
-
logger.warning(f"
|
|
763
|
+
logger.warning(f"Attribute 'fill opacity' with value '{fill_alpha}' should be in range [0.0..1.0]!")
|
|
747
764
|
fill_alpha = 1
|
|
765
|
+
if style['fill-rule'] is not None and style['fill-rule'] != 'none':
|
|
766
|
+
fill_rule = style['fill-rule']
|
|
767
|
+
if not style['fill']:
|
|
768
|
+
logger.warning(f"Attribute 'fillrule' is set to '{fill_rule}', but no fill color given: skip this fill.")
|
|
748
769
|
|
|
749
770
|
return (stroke_width, stroke_color, stroke_alpha, fill_color, fill_alpha, fill_rule, style['pathcut'])
|
|
750
771
|
|
|
@@ -1031,4 +1052,5 @@ class Compiler:
|
|
|
1031
1052
|
self.body.extend([f"\n; end engrave path '{name_id}'\n"])
|
|
1032
1053
|
else:
|
|
1033
1054
|
# cannot engrave path (ignore)
|
|
1055
|
+
logger.warning(f"cannot engrave path '{name_id}': no stroke color set")
|
|
1034
1056
|
self.body.extend([f"\n; cannot engrave path '{name_id}': no stroke color set"])
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|