paulgb / penkit

Tools for pen plotting in Python
MIT License
142 stars 8 forks source link

Text in SVG - the result is mirror-inverted #3

Open schittli opened 4 years ago

schittli commented 4 years ago

Good Morning

This is more a note than an issue, therefore I selected an issue title which describes the visible result so it hopefully gets found by other users who have similar results.

Thank you very much!

for sharing your knowledge in your Blog and your source code!, it is always amazing to see how mathematicians miraculously simplify complex problems and develop solutions with surprisingly few lines of code. Even your SVG drawing visualizer is great and the result can be interpreted very fast.

The issue: penkit-optimize removes the source file <svg …> and <g transform=…> elements

I tried to use penkit-optimize with AxiDraw, the handwriting machine to optimize one page filled with Text (which was converted from the TTF outline Text to Single Stroke with created 2650 SVG Path elements) and the result is great:

InitialCost / GreedyCost = 19.47
InitialCost / VRPOptimizationCost = 22.05
Plotting time of the example below: 06:55 reduced to 01:51. Amazing.

Unfortunately, the result is mirror-inverted.

Ex - penkit-optimize - Text, John C  Lennox, Original vs Optimized

I've analyzed the issue and found that penkit-optimize removes the original <svg …> and <g transform=…> elements. My source file (from Inkscape) has this SVG definition:

<svg xmlns="http://www.w3.org/2000/svg" 
  width="210.000000mm" height="297.000000mm" 
  viewBox="0.000000 -0.000000 9921.000000 14031.000000">
  <g transform="matrix(1,0,0,-1,0,14031.000000)">

Because the source uses <g transform=…> and penkit-optimize removes those elements, the result is mirrored.

Yesterday I tried to fix it and to make penkit-optimize compatible with the latest Google OR-Tools 7.3, but failed to start your Python Package from the command line :-(. Starting Python scripts is often a big annoyance for non Python developers. Because I don't know Python, I probably wouldn't have reached my goal within a useful time anyway.

paulgb commented 4 years ago

Sorry for the late reply. Thanks for reporting this Tom, I will add a note about it to the documentation. The limitation makes sense given the way I understand the underlying library, svgpathtools, to work: it is more of a path string parser than a full SVG implementation.

-- Paul

On Sat, Oct 12, 2019, 8:04 AM Tom-- notifications@github.com wrote:

Good Morning

This is more a note than an issue, therefore I selected an issue title which describes the visible result so it hopefully gets found by other users who have similar results. Thank you very much!

for sharing your knowledge in your Blog and your source code!, it is always amazing to see how mathematicians miraculously simplify complex problems and develop solutions with surprisingly few lines of code. Even your SVG drawing visualizer is great and the result can be interpreted very fast. The issue: penkit-optimize removes the source file <svg …> and <g transform=…> elements

I tried to use penkit-optimize with AxiDraw, the handwriting machine https://axidraw.com to optimize one page filled with Text (which was converted from the TTF outline Text to Single Stroke with created 2650 SVG Path elements) and the result is great:

InitialCost / GreedyCost = 19.47

InitialCost / VRPOptimizationCost = 22.05

Plotting time of the example below: 06:55 reduced to 01:51. Amazing.

Unfortunately, the result is mirror-inverted.

[image: Ex - penkit-optimize - Text, John C Lennox, Original vs Optimized] https://user-images.githubusercontent.com/8282673/66700782-141b8000-ecf5-11e9-82b3-d24c991518ea.png

I've analyzed the issue and found that penkit-optimize removes the original <svg …> and elements. My source file (from Inkscape) has this SVG definition:

<svg xmlns="http://www.w3.org/2000/svg"

width="210.000000mm" height="297.000000mm"

viewBox="0.000000 -0.000000 9921.000000 14031.000000">

Because the source uses and penkit-optimize removes those elements, the result is mirrored. Yesterday I tried to fix it and to make penkit-optimize compatible with the latest Google OR-Tools 7.3, but failed to start your Python Package from the command line :-(. Starting Python scripts is often a big annoyance for non Python developers. Because I don't know Python, I probably wouldn't have reached my goal within a useful time anyway. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub , or unsubscribe .