svg2gcode 4.0.2__tar.gz → 4.0.4__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.
Files changed (40) hide show
  1. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/PKG-INFO +7 -4
  2. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/README.md +6 -3
  3. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/__init__.py +1 -1
  4. svg2gcode-4.0.4/svg2gcode/svg_examples/nonzero_evenodd.svg +47 -0
  5. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/compiler/_compiler.py +15 -9
  6. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/LICENSE +0 -0
  7. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/pyproject.toml +0 -0
  8. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/__main__.py +0 -0
  9. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_examples/README.md +0 -0
  10. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_examples/gcode_output.zip +0 -0
  11. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_examples/kye_circle_paws_orig copy.svg +0 -0
  12. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_examples/kye_circle_paws_orig.svg +0 -0
  13. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_examples/letterandsigns.svg +0 -0
  14. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/LICENSE +0 -0
  15. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/__init__.py +0 -0
  16. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/compiler/__init__.py +0 -0
  17. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/compiler/interfaces/__init__.py +0 -0
  18. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/compiler/interfaces/_abstract_interface.py +0 -0
  19. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/compiler/interfaces/_fan_controlled_gcode.py +0 -0
  20. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/compiler/interfaces/_gcode.py +0 -0
  21. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/css_color.py +0 -0
  22. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/formulas.py +0 -0
  23. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/geometry/__init__.py +0 -0
  24. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/geometry/_abstract_chain.py +0 -0
  25. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/geometry/_abstract_curve.py +0 -0
  26. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/geometry/_circular_arc.py +0 -0
  27. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/geometry/_cubic_bazier.py +0 -0
  28. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/geometry/_elliptical_arc.py +0 -0
  29. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/geometry/_line.py +0 -0
  30. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/geometry/_line_segment_chain.py +0 -0
  31. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/geometry/_matrix.py +0 -0
  32. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/geometry/_quadratic_bazier.py +0 -0
  33. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/geometry/_raster_image.py +0 -0
  34. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/geometry/_smooth_arc_chain.py +0 -0
  35. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/geometry/_vector.py +0 -0
  36. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/svg_parser/__init__.py +0 -0
  37. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/svg_parser/_parser_methods.py +0 -0
  38. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/svg_parser/_path.py +0 -0
  39. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/svg2gcode/svg_to_gcode/svg_parser/_transformation.py +0 -0
  40. {svg2gcode-4.0.2 → svg2gcode-4.0.4}/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.2
3
+ Version: 4.0.4
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>
@@ -16,9 +16,12 @@ Import-Name: svg2gcode
16
16
 
17
17
  # svg2gcode
18
18
 
19
- ### svg2gcode <small>is a *WYSIWYG* converter of Scalable Vector Graphic *(.svg)* drawings.</small>
19
+ ### svg2gcode <small>converts Scalable Vector Graphic drawings - *WYSIWYG* - to GCODE.</small>
20
+
21
+ Vector graphics files can be manipulated - scaled, rotated, transformed - and be converted to optimised gcode which can be directly used on your laser engraver/cutter. Properties like line thickness, fill and color are all taken into account. They are vector based. Unique is that bitmap images are also supported and drawn alongside and at the same scaling and position as defined in the *.svg* file. Specific lines within the vector drawings can be identified by color name or code and assigned actions like engrave, cut or ignore. All from one command.
22
+
23
+ *svg2gcode* makes use of library *image2gcode* for bitmap conversion to gcode and an updated and corrected version of library *SvgToGcode* for parsing (reading, interpreting) vector graphics files.<sup>(1)</sup>.
20
24
 
21
- It is based on library *SvgToGcode* (*https://github.com/johannesnoordanus/SvgToGcode*)<sup>(1)</sup>.
22
25
  ### Version 4.0 is out now!
23
26
  **svg2gcode 4.0** has a vastly improved *stroke* and *fill* and is even easier to control.
24
27
  Lines with a certain width are now drawn almost perfectly in a vector like manner.
@@ -64,7 +67,7 @@ More info can be obtained by looking at the documentation and examples below and
64
67
 
65
68
  *svg2gcode* has three related programs: *image2gcode* mentioned above has similar capabilities but handles raster image files (like *png* and *jpg*) directly, *gcode2image* performs the inverse function and is capable of showing multiple writes (burns) to the same location and last *grblhud* which gives full control over gcode execution.
66
69
 
67
- <sup>(1)</sup> Note that an upgraded and corrected version of this library is included.
70
+ <sup>(1)</sup> *image2gcode* can be found here: *https://github.com/johannesnoordanus/image2gcode*, the updated library *SvgToGcode* can be found here: *https://github.com/johannesnoordanus/SvgToGcode*. Note that python library and program *image2gcode* will be installed alongside when installing via *pip* and that *SvgToGcode* is included in *svg2gcode*.
68
71
 
69
72
  -----
70
73
 
@@ -1,8 +1,11 @@
1
1
  # svg2gcode
2
2
 
3
- ### svg2gcode <small>is a *WYSIWYG* converter of Scalable Vector Graphic *(.svg)* drawings.</small>
3
+ ### svg2gcode <small>converts Scalable Vector Graphic drawings - *WYSIWYG* - to GCODE.</small>
4
+
5
+ Vector graphics files can be manipulated - scaled, rotated, transformed - and be converted to optimised gcode which can be directly used on your laser engraver/cutter. Properties like line thickness, fill and color are all taken into account. They are vector based. Unique is that bitmap images are also supported and drawn alongside and at the same scaling and position as defined in the *.svg* file. Specific lines within the vector drawings can be identified by color name or code and assigned actions like engrave, cut or ignore. All from one command.
6
+
7
+ *svg2gcode* makes use of library *image2gcode* for bitmap conversion to gcode and an updated and corrected version of library *SvgToGcode* for parsing (reading, interpreting) vector graphics files.<sup>(1)</sup>.
4
8
 
5
- It is based on library *SvgToGcode* (*https://github.com/johannesnoordanus/SvgToGcode*)<sup>(1)</sup>.
6
9
  ### Version 4.0 is out now!
7
10
  **svg2gcode 4.0** has a vastly improved *stroke* and *fill* and is even easier to control.
8
11
  Lines with a certain width are now drawn almost perfectly in a vector like manner.
@@ -48,7 +51,7 @@ More info can be obtained by looking at the documentation and examples below and
48
51
 
49
52
  *svg2gcode* has three related programs: *image2gcode* mentioned above has similar capabilities but handles raster image files (like *png* and *jpg*) directly, *gcode2image* performs the inverse function and is capable of showing multiple writes (burns) to the same location and last *grblhud* which gives full control over gcode execution.
50
53
 
51
- <sup>(1)</sup> Note that an upgraded and corrected version of this library is included.
54
+ <sup>(1)</sup> *image2gcode* can be found here: *https://github.com/johannesnoordanus/image2gcode*, the updated library *SvgToGcode* can be found here: *https://github.com/johannesnoordanus/SvgToGcode*. Note that python library and program *image2gcode* will be installed alongside when installing via *pip* and that *SvgToGcode* is included in *svg2gcode*.
52
55
 
53
56
  -----
54
57
 
@@ -1,4 +1,4 @@
1
1
  """
2
2
  svg2gcode: convert an SVG (Scalable Vector Graphic) image to gcode.
3
3
  """
4
- __version__ = "4.0.2"
4
+ __version__ = "4.0.4"
@@ -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>
@@ -122,7 +122,7 @@ class Compiler:
122
122
  gcode += ["; WARNING: Cut is not within machine bounds of "
123
123
  f"X[0,{self.settings['x_axis_maximum_travel']}], Y[0,{self.settings['y_axis_maximum_travel']}]\n",]
124
124
  elif not self.check_axis_maximum_travel():
125
- # logger.warning("Please define machine cutting area, set parameter: 'x_axis_maximum_travel' and 'y_axis_maximum_travel'")
125
+ logger.warning("Please define machine cutting area, set parameter: 'x_axis_maximum_travel' and 'y_axis_maximum_travel'")
126
126
  gcode += ["; WARNING: Please define machine cutting area, set parameter: 'x_axis_maximum_travel' and 'y_axis_maximum_travel'\n",]
127
127
  else:
128
128
  gcode += [f"; WARNING: distance mode is not absolute: {self.settings['distance_mode']}\n",]
@@ -473,14 +473,14 @@ class Compiler:
473
473
 
474
474
  # parse fill
475
475
  if style['fill'] is None and 'fill' in style_str:
476
- fill = re.search('fill:[^;]+;',style_str)
476
+ fill = re.search('fill:[^;]+(?:;|$)',style_str)
477
477
  if fill:
478
478
  fill_str = fill.group(0)[5:-1]
479
479
  if fill_str != 'none':
480
480
  style['fill'] = fill_str
481
481
  # parse fill-rule
482
482
  if style['fill-rule'] is None and 'fill-rule' in style_str:
483
- fill_rule = re.search('fill-rule:#(evenodd|nonzero)',style_str)
483
+ fill_rule = re.search('fill-rule: ?(evenodd|nonzero)',style_str)
484
484
  if fill_rule:
485
485
  style['fill-rule'] = re.search('(evenodd|nonzero)', fill_rule.group(0)).group(0)
486
486
  # parse fill-opacity
@@ -490,7 +490,7 @@ class Compiler:
490
490
  style['fill-opacity'] = re.search(r'(\d*\.)?\d+', fill_opacity.group(0)).group(0)
491
491
  # parse stroke
492
492
  if style['stroke'] is None and 'stroke' in style_str:
493
- stroke = re.search('stroke:[^;]+;',style_str)
493
+ stroke = re.search('stroke:[^;]+(?:;|$)',style_str)
494
494
  if stroke:
495
495
  stroke_str = stroke.group(0)[7:-1]
496
496
  if stroke_str != 'none':
@@ -730,21 +730,26 @@ class Compiler:
730
730
  # fill opacity attribute overrides rgba property
731
731
  stroke_alpha = float(style['stroke-opacity'])
732
732
  if not 0 <= stroke_alpha <= 1:
733
- logger.warning(f"Opacity value '{stroke_alpha}' should be in range [0.0..1.0]!")
733
+ logger.warning(f"Attribute 'opacity' with value '{stroke_alpha}' should be in range [0.0..1.0]!")
734
734
  stroke_alpha = 1
735
735
  if style['stroke-width'] is not None and style['stroke-width'] != 'none':
736
736
  width = float(style['stroke-width'])
737
737
  stroke_width = math.ceil(round(width/pixel_size, self.precision)/2)
738
+ if not style['stroke']:
739
+ logger.warning(f"Attribute 'stroke width' is set to '{style['stroke-width']}', but no stroke color given: skip this path.")
740
+
738
741
  if style['fill'] is not None and style['fill'] != 'none':
739
742
  fill_color = style['fill']
740
- if style['fill-rule'] is not None:
741
- fill_rule = style['fill-rule']
742
- if style['fill-opacity'] is not None:
743
+ if style['fill-opacity'] is not None :
743
744
  # fill opacity attribute overrides rgba property
744
745
  fill_alpha = float(style['fill-opacity'])
745
746
  if not 0 <= fill_alpha <= 1:
746
- logger.warning(f"Opacity value '{fill_alpha}' should be in range [0.0..1.0]!")
747
+ logger.warning(f"Attribute 'fill opacity' with value '{fill_alpha}' should be in range [0.0..1.0]!")
747
748
  fill_alpha = 1
749
+ if style['fill-rule'] is not None and style['fill-rule'] != 'none':
750
+ fill_rule = style['fill-rule']
751
+ if not style['fill']:
752
+ logger.warning(f"Attribute 'fillrule' is set to '{fill_rule}', but no fill color given: skip this fill.")
748
753
 
749
754
  return (stroke_width, stroke_color, stroke_alpha, fill_color, fill_alpha, fill_rule, style['pathcut'])
750
755
 
@@ -1031,4 +1036,5 @@ class Compiler:
1031
1036
  self.body.extend([f"\n; end engrave path '{name_id}'\n"])
1032
1037
  else:
1033
1038
  # cannot engrave path (ignore)
1039
+ logger.warning(f"cannot engrave path '{name_id}': no stroke color set")
1034
1040
  self.body.extend([f"\n; cannot engrave path '{name_id}': no stroke color set"])
File without changes
File without changes