You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Praveen Nayak <Pr...@telelogic.com> on 2007/10/18 10:32:17 UTC

Path problem

Hi,

 

I have a path that draws a line, an arc and a Z to complete the shape.

 

                <path style="stroke:black;fill:#FF9966"
d="M0,0L0,140A140 140 1 1 0 -3.4288977907026563e-14,140z"
transform="translate(4.898425415289509e-15,-40)" />

 

But canvas does not draw the arc. 

 

I then saw that it does not handle the size -3.4288977907026563e-14.
(Got through math functions)

 

This works with adobe viewer though.

 

I then changed it to -0.0001 and it worked. Some more leading zeros to
the 1 and it will again not work.

 

                <path style="stroke:black;fill:#FF9966"
d="M0,0L0,140A140 140 1 1 0 -0.0001,140z"
transform="translate(4.898425415289509e-15,-40)" />

 

So, is this a bug with Batik, or a specification of SVG?

 

 

Thanks,

Praveen 
--------------------------------------------------------------------------------
Telelogic Lifecycle Solutions:
Helping You Define, Design & Deliver Advanced Systems & Software 
Learn More at www.telelogic.com 

Praveen Nayak 
Technical Leader 
Telelogic India Pvt Ltd 
#58, 1- 4 HM Towers,
Brigade Road, 
560 025 Bangalore 
India 

Phone: +91 (80) 419 95800 x327 
Fax: 
Mobile phone: 
Praveen.Nayak@telelogic.com 
http://www.telelogic.com 

Telelogic - Requirements-Driven Innovation!
------------------------------------------------------------- 


The information contained in this e-mail, including any attachment or enclosure, is intended only for the person or entity to which it is addressed and may contain confidential material. Any unauthorized use, review, retransmissions, dissemination, copying or other use of this information by persons or entities other than the intended recipient is prohibited.

Re: Path problem

Posted by th...@kodak.com.
Hi Praveen,

"Praveen Nayak" <Pr...@telelogic.com> wrote on 10/18/2007 04:32:17 
AM:

> I have a path that draws a line, an arc and a Z to complete the shape.
> 
>                 <path style="stroke:black;fill:#FF9966" d="M0,0L0,
> 140A140 140 1 1 0 -3.4288977907026563e-14,140z" 
> transform="translate(4.898425415289509e-15,-40)" />
> 
> But canvas does not draw the arc. 
> 
> I then saw that it does not handle the size -3.4288977907026563e-14.
> (Got through math functions)

   Right this is a precision issue.

> This works with adobe viewer though.

   They probably hold the coords as a double precision floats.

> I then changed it to -0.0001 and it worked. Some more leading zeros 
> to the 1 and it will again not work.

   Right a float has ~8 digits of precision.  '140' is 3 digits,
'0.0001' is 4 more digits so even there you are on the edge of
140.0001 -> 140.  If that happens then you have an arc that
goes from 0, 140 to 0, 140 with a radius of 140... unfortunately
there are an infinite number of such circles.  If you really want
such a circle I would suggest using two arc commands.  Have the
first do one half of the circle and have the second finish the
circle, then you can really close the circle, rather than leaving
a small 'flat' edge.

>                 <path style="stroke:black;fill:#FF9966" d="M0,0L0,
> 140A140 140 1 1 0 -0.0001,140z" transform="translate(4.
> 898425415289509e-15,-40)" />

  For example (not entirely sure the arc flags are right).
    d="M0,0 L0,140 A140,140 1 1 0 -140,140 A140,140 1 1 0 0,140z"

> So, is this a bug with Batik, or a specification of SVG?

   Implementations are allowed to hold coordinate data as float
so one can reasonably argue this is a bug in your specification
of the path.