Re: [css-shapes] circle radius as a percentage

On 9/5/13 3:49 PM, "François REMY" <francois.remy.dev@outlook.com> wrote:

>Some clarification of the css-shapes-1 spec (regarding how to interpret a
>percentage value used as a circle radius) would be welcome, I guess, for
>people trying to implement the spec.
>
>Indeed, it seems to me it is not specified whether the percentage is
>considered from the width direction or from the height direction, or form
>any other kind of reference. My own implementation used the width
>direction for consistency with ellipse but it would probably just be
>better to disallow percentage-defined radius for circles.
>
>Relevant text from the spec:
>
>  circle([<length>|<percentage>][, [<length>|<percentage>]]{2})
>  
>  The three values values represent cx, cy, and r.
>  They define the x-axis and y-axis coordinates of the center of the
>circle and the radius of the circle.
>  A negative value for r is invalid.
>
>For what it's worth, I'm not quite sure why there's a need for circle
>function when we could simply consider as a circle an ellipse with 3
>arguments, but I guess it's for the sake of consistency with SVG.
>
>Best regards,
>Francois 		 	   		

Look at the last sentence of section 3.2:

---
For the radius r of the circle shape,
a percentage value is resolved as
specified in the SVG recommendation.
---

The relevant part of the SVG rec is:

---
For any other length value expressed
as a percentage of the viewport,
the percentage is calculated as
the specified percentage of
sqrt((actual-width)**2 +
      (actual-height)**2))/sqrt(2).

---

Thanks,

Alan

Received on Thursday, 5 September 2013 22:57:42 UTC