- From: Jeremie Patonnier <jeremie.patonnier@gmail.com>
- Date: Sat, 11 Feb 2012 21:28:18 +0100
- To: "Tab Atkins Jr." <jackalmage@gmail.com>
- Cc: www-svg <www-svg@w3.org>
- Message-ID: <CAEi838keUPAn1ZEjn1vk4yhAncWpJ-ca_oQdY+2x+srOG127-g@mail.gmail.com>
Hi, Tab, thanks for this enlightenment :) 2012/2/11 Tab Atkins Jr. <jackalmage@gmail.com> > The *Units attributes don't change the meaning of percentages, they > just change the size of userspace units so that one unit is the size > of the object bounding box. Ok, I see... after reading the spec again and again, and again... It's some kind of treasure hunt to find why it behaves that way. And as an author, I have to say that when I read this I thought : "WTF!!!!! (o_O)". It's pretty hard to understand this because, conceptually, there is no difference between ".xx" in a [0,1] range and "xx%" I think the SVG 1.1 spec is somewhat misleading (and could be clarified). Let's go back to the treasure hunt and let me tell you the poor story of the author trying to "have fun" with SVG (remember, it's the way an AUTHOR will read the spec... yes, yes, yes, I know, spec are not made for author, anyway, I guess it's also painful for implementor to read it) : 1. Let's start by reading the maskUnits definition [1] : « If maskUnits="objectBoundingBox", ‘x’, ‘y’, ‘width’ and ‘height’ represent fractions or *percentages* of the bounding box of the element to which the mask is applied. (See Object bounding box units.) » Reading this, ok, percentage are cool, no need to read further -> Warning! Many authors will stop reading here and will assume that it's also true for maskContentUnits, clipPathUnits and so on... which is obviously wrong and their demos will fail. 2. Well, let's read maskContentUnits [2] : « If maskContentUnits="objectBoundingBox", the user coordinate system for the contents of the ‘mask’ is established using the bounding box of the element to which the mask is applied. (See Object bounding box units.) » Many lazy authors will stop reading here and will assume that if everything is bound to the Object Bounding Box, the percentage will be as well -> Wrong, the demo would fail miserably, again. 3. Ok, let's read that damned "Object bounding box" thing [3] : « The following elements offer the option of expressing coordinate values and lengths as fractions (and, *in some cases*, percentages) » Wait... WHAT? But why? Which are those cases? (remember, here is the author trying to understand that mess) « When percentages are used with attributes that define the gradient vector, the pattern tile, the filter region or the masking region, a percentage represents the same value as the corresponding decimal value (e.g., 50% means the same as 0.5). » Ok, that sounds quite logical and it is what I'm expecting... should I keep reading... ok, I'll give it a try, I was scammed before. « If percentages are used within the content of a ‘pattern’, ‘clipPath’, ‘mask’ or ‘filter’ element, these values are treated according to the processing rules for percentages as defined in Units. » ???... ok I suspect there is a trick here. 4. Let's read the Units part [4]: « For percentage values that are defined to be relative to the size of viewport: [...] » Oooookey... and what about percentage value that are related to object bounding box? Nothing. So what? Here end my story and, again, thanks to Tab to have clarified the expected behavior : percentage value in that case are considered relative to the size of the viewport. Anyway even with the spec it doesn't sound obvious and in an author point of view it seams really unnatural (but I'd be glad if someone could explain the rationale behind that). So to make things clearer for every one, I suggest two actions : 1. Update the current SVG spec to add a note to all the relevant attributes definition that do not support percentage value relative to the object bounding box (gradientUnits, patternUnits, patternContentUnits, clipPathUnits, maskUnits, maskContentUnits, filterUnits or primitiveUnits): « Note that percentage values are not affected by the 'objectBoundingBox' value and, according to the units processing rules, are defined to be relative to the size of the viewport applicable to the object the gradient|mask|pattern|clip|filter|primitive is applied to. » 2. I propose some changes to the upcoming SVG 2.0 to have things more consistent and more author friendly: 1. Mark all the gradientUnits, patternUnits, patternContentUnits, clipPathUnits, maskUnits, maskContentUnits, filterUnits or primitiveUnits attributes deprecated. It's to many different attributes that basically do the same : switching between 'userSpaceOnUse' and 'objectBoundingBox' values. 2. Add two new attributes « units » and « contentUnits ». « units » will be a unified attribute that will be used in replacement of gradientUnits, patternUnits, maskUnits, filterUnits and primitiveUnits. « contentUnits » will be a unified attribute that will be used in replacement of patternContentUnits, clipPathUnits and maskContentUnits 3. The old deprecated attributes will remain with their behavior unchanged but the new attributes will allow the use of percentage values always relative to the object bounding box if the value of the « units » or « contentUnits » is set to "objectBoundingBox" (which is, IMO, what authors expect : when something is bound to the bounding box, everything should be and percentage are much more readable than fraction). 4. if both the old deprecated attribute and the new friendly attribute are used at the same times, the new attribute will override the behavior of the old one. 5. if only one attribute is declared, the default value of the undeclared attribute is ignored 6. if there is no attribute, both old and new attributes should have the same default value which will insure backward compatibility with legacy content. Let me know if I'm missing something. Regards -- Jeremie ............................. Web : http://jeremie.patonnier.net Twitter : @JeremiePat <http://twitter.com/JeremiePat> [1] http://www.w3.org/TR/SVG11/masking.html#MaskElementMaskUnitsAttribute [2] http://www.w3.org/TR/SVG11/masking.html#MaskElementMaskContentUnitsAttribute [3] http://www.w3.org/TR/SVG11/coords.html#ObjectBoundingBox [4] http://www.w3.org/TR/SVG11/coords.html#Units
Received on Saturday, 11 February 2012 20:29:06 UTC