Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting from 'Percent' to millimeters is not supported, treating as millimeters #20

Closed
matopeto opened this issue Oct 2, 2021 · 2 comments

Comments

@matopeto
Copy link

matopeto commented Oct 2, 2021

Hi

I exported svg from Affinity Photo and svg looks like:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 354 1181" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
    <g transform="matrix(0.30102,0,0,1,4.19388,0)">
        <path d="M6,1175L1182,1179L1178,3L6,1L6,1175Z" style="fill:none;stroke:rgb(255,0,57);stroke-width:1.13px;"/>
    </g>
</svg>

It defines viewBox (in some units, seems like pixels mm x dpi) and width and height in percent

I run your program and get this warning

Converting from 'Percent' to millimeters is not supported, treating as millimeters

And result is 100x100 mm instead correct dimensions

It can be sized by --dimensions but i cannot specify only one dimension because of wrong aspect ratio 100x100 instead of 354x1181

cargo run --release -- examples/affinityexport.svg --off 'M4' --on 'M5' -o out.gcode
[2021-10-02T16:12:21Z WARN  svg2gcode::converter] Converting from 'Percent' to millimeters is not supported, treating as millimeters
[2021-10-02T16:12:21Z WARN  svg2gcode::converter] Converting from 'Percent' to millimeters is not supported, treating as millimeters

Generated output:

G21
G90;svg > g > path
M4
G0 X1.6949152542372883 Y0.5080440304826368
M5
G1 X101.69477966101695 Y0.1693480101608884 F300
G1 X101.35464406779661 Y99.74597798475868 F300
G1 X1.6949152542372883 Y99.91532599491956 F300
G1 X1.6949152542372883 Y0.5080440304826368 F300
M4
M2
@sameer
Copy link
Owner

sameer commented Oct 3, 2021

Hi matopeto,

I've added some more nuanced handling for the use case you described:

  • Percentage conversion is now supported. Preserves aspect ratio and treats the viewBox as being in millimeters (i.e. 100% x 100% = 354mm x 1181mm)
  • Specifying a viewBox and no width/height assumes the viewBox is in millimeters

Checked output with dimensions arguments 354mm,, ,1181mm and 354mm,1181mm and all look identical

@matopeto
Copy link
Author

It works, great :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants