Kozea / Kozea/CairoSVG

Pattern fill not scaled correctly

Open
#315 2 comments 2 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
951
Forks
166
PR merge metrics
No merged PRs in 30d

Description

When attempting to convert the SVG below to a PNG image in python the background grid created by filling a rectangle with a defined pattern is not being scaled correctly.
```

```
It should be rendered as shown in the image below.

![svg-graph-1a](https://user-images.githubusercontent.com/1799044/108914047-ba360480-7622-11eb-872e-e64c8b28f361.png)

Note are that all the vertical bars, except the violet and dark orange ones, line up with the grid lines as expected and the major and minor graduations are aligned):

The function I'm using to convert the contents of the SVG file to a image is shown below:
```
def render_svg(_svg):
_bytes = cairosvg.svg2png(_svg)
byte_io = io.BytesIO(_bytes)
return pygame.image.load(byte_io)
```

This results in the following image:

![svg-graph-1b](https://user-images.githubusercontent.com/1799044/108914050-bace9b00-7622-11eb-80ff-afa92618f9eb.png)

This shows that that the grid pattern does not align with the vertical bars in the bar chart as expected, and the major and the major and minor graduations are also misaligned.

I'm using Debian Buster with python3.7 (3.7.3-2+deb10u2), python3-pygame (1.9.4.post1+dfsg-3), and (python3-cairosvg 1.0.20-1) installed using apt-get.

Drawing the grid lines one line at a time works as expected.

Hope this is helpful!

Thank you.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the render_svg function and reproduce the supplied SVG through cairosvg.svg2png, comparing its PNG output with the reference image. Trace the pattern-fill rendering path and verify the grid graduations align with the vertical bars; done means the generated image matches the expected alignment.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.