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

SVG renders with poor precision #354

Open
gskluzacek opened this issue Jan 7, 2024 · 0 comments
Open

SVG renders with poor precision #354

gskluzacek opened this issue Jan 7, 2024 · 0 comments

Comments

@gskluzacek
Copy link

New, to pycairo, so maybe I'm missing something...

I'm trying to draw a simple polygon with move_to & line_to, however the values appearing in the SVG output are only accurate to the 100th place.

for example:

  I give an x coordinate in the move_to call of 6.426575
             but it shows up in the SVG file as 6.425781

for some reason its loosing precision after 6.42, the next digit should be a 6, but I'm getting a 5.

here's my code:

import cairo
with cairo.SVGSurface("test_2.svg", 100, 100) as surface:
    context = cairo.Context(surface)
    context.set_line_width(.1)
    context.set_source_rgb(1, 0, 0)
    context.move_to(6.426575, 89.055378)
    context.line_to(65.205100, 3.311026)
    context.line_to(123.983626, 89.055378)
    context.close_path()
    context.stroke()

here is the svg output

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="100"
     viewBox="0 0 100 100">
    <path fill="none" stroke-width="0.1" stroke-linecap="butt" stroke-linejoin="miter" stroke="rgb(100%, 0%, 0%)"
          stroke-opacity="1" stroke-miterlimit="10"
          d="M 6.425781 89.054688 L 65.207031 3.3125 L 123.984375 89.054688 Z M 6.425781 89.054688 "/>
</svg>
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

1 participant