[ROOT-6994] Rounding of coordinates in SVG Created: 31/Dec/14  Updated: 06/Jan/15  Resolved: 06/Jan/15

Status: Closed
Project: ROOT
Component/s: Graphics
Affects Version/s: 5.34/23
Fix Version/s: None

Type: Bug Priority: High
Reporter: Daniel Geerts Assignee: Olivier Couet
Resolution: Fixed Votes: 0
Labels: None
Environment:

Any


Attachments: File SVG_bug.C     File TSVG.cxx     File TSVG.h    
Development:

 Description   

Who's the smart guy that's rounding all the coordinates to integers in TSVG.cxx? Look at this:
Int_t TSVG::XtoSVG(Double_t x)

That's just wrong. Plain wrong. <venting> All my plots are now rubbish because the hatches don't draw properly! </venting>



 Comments   
Comment by Daniel Geerts [ 01/Jan/15 ]

Based on ROOT 5.34.19

Comment by Daniel Geerts [ 01/Jan/15 ]

I just attached a fix, based on ROOT 5.34/19 (sorry, that's the one I'm using, not 5.34/23). The hatches in my plots now look perfect. Some labels etc. shift around too, but that's because the previous behaviour was wrong.

Comment by Olivier Couet [ 05/Jan/15 ]

As this code is like that since 12 years (see https://root.cern.ch/viewvc/trunk/graf2d/postscript/src/TSVG.cxx?revision=3986&view=markup) ...

... the "smart guy" is me.

I agree to apply your patch .. but, as the problem you mention was never reported before, I would like to have a script reproducing it.

Comment by Daniel Geerts [ 05/Jan/15 ]

Script to generate an SVG file that needs floating point coordinates to be saved properly.

Comment by Daniel Geerts [ 05/Jan/15 ]

I've attached a script that generates an SVG file that needs floating point coordinates to be saved properly. Generate the SVG file, and use any image viewer to zoom in on the diagonal lines. You'll notice that their angles are all slightly different, and at the borders, the intervals between their endpoints appears very irregular. After applying the patch, everything looks fine.

And I have to apologise for my non-professional ticket opening. I was just finishing up one of the last chapters of my thesis when I suddenly noticed this, and I had to re-generate all my plots. Sorry!

Comment by Olivier Couet [ 05/Jan/15 ]

Thanks I will look.

And I have to apologise for my non-professional ticket opening. I was just finishing up one of the last chapters of my thesis when I suddenly noticed this, and I had to re-generate all my plots. Sorry!

No problem. I was just surprised that you seemed to say it was a new problem whereas the code is like that since the creation of this class (12 years ago)

Comment by Daniel Geerts [ 05/Jan/15 ]

Oh, I see. No, I did realise this problem has been there for quite some time, but I only started noticing it when I started prettifying my plots. Sorry if I was unclear about that.

Comment by Olivier Couet [ 05/Jan/15 ]

I am now back at the SVG doc. I'd like to find out if the coordinates can be defined as floating points. For instances in your SVG file the hatches are drawn with commands like:

<path d="M359,167l -151, 151" fill="none" stroke="#999999"/>

"M" means "Move" and the values just after are the coordinates. Your fix will make these two numbers floating points. I need to check if it is allowed or not. If it is, I will apply your patch.

Comment by Daniel Geerts [ 05/Jan/15 ]

Yeah, I tried looking it up too, and it's not that obvious.

http://www.w3.org/TR/SVG/paths.html#PathData
Notice the text about the "decimal point"

But more obvious:
http://www.w3.org/TR/SVG/coords.html#Introduction
http://www.w3.org/TR/SVG/types.html#DataTypeNumber

Comment by Olivier Couet [ 05/Jan/15 ]

Yes I was looking in to that also. The path seems to allow decimal points according to the doc.
I will look more closely at the fix. I ll let you know.

Comment by Olivier Couet [ 05/Jan/15 ]

I think that will be fine. But looking at this I found an other problem.

Comment by Olivier Couet [ 06/Jan/15 ]

Now fixed.

Generated at Sat Sep 21 06:40:53 CEST 2019 using Jira 7.13.1#713001-sha1:5e06076c2d215a6f699b7e5c90ab2fae7ba5a1ce.