Syntax for image-pattern support in CSS
David Grieve
david.grieve at oracle.com
Fri Aug 31 06:42:17 PDT 2012
My understanding is that they are relative to the "anchor rectangle". If proportional is true, then the "anchor rectangle" is defined by the shape you're painting. If proportional is false, then you are giving the absolute size of the anchor rectangle.
You can allow percentages, but they would have to be relative to the shape being filled; otherwise, you are changing the meaning of the arg since, I would argue, percentages imply proportional=true. If you had percentages and proportional=false, then that would be a syntax error or would generate a warning and be ignored.
I like using percentage values since it conveys information. 20% is more descriptive than .2. radial-gradient and linear-gradient accept percentage or number for the "from <point> to <point>", so there is precedent.
On Aug 30, 2012, at 10:27 PM, Richard Bair wrote:
> That's a good question, I really don't know how those properties work. Are they relative to the shape being filled, or are they relative to the source image? If the latter, then it is up to the developer. If it is the former, then I will need to change the parser to support percentages, in which case, I'm royally hosed (because although the parser can handle it fine, I have to pass the knowledge that these things are percentages down, and there is nothing to pass them down to).
>
> Richard
>
> On Aug 30, 2012, at 7:24 PM, Joe Andresen wrote:
>
>> Hey Rich,
>>
>> Looks good to me.
>>
>> If proportional is false, the range of the previous parameters will change. Will this be alright with the way we represent ranges in CSS? I'm assuming yes.
>>
>> -J
>>
>> ----- Original Message -----
>> From: richard.bair at oracle.com
>> To: openjfx-dev at openjdk.java.net
>> Sent: Thursday, August 30, 2012 6:36:19 PM GMT -08:00 US/Canada Pacific
>> Subject: Syntax for image-pattern support in CSS
>>
>> http://javafx-jira.kenai.com/browse/RT-19455
>>
>> Anywhere a Paint is allowed:
>>
>> url('region/test20x20.png');
>> image-pattern('region/test20x20.png', 0, 0, 1, 1, true);
>>
>> The syntax is exactly the same as our ImagePattern class. I rather chose the rgb() style function rather than linear, radial gradient style named parameters both because it was less work and less syntax to define, and because there aren't many params and I thought I'd just map directly to the class. I could have tried giving percentage based value support (percent of what? The image, the dest?) but I decided to just stick with plain numbers. Most of the time people will either just use the url version and get tiling for free, or they will use the image-pattern version and get it stretched (as I've done here). Or they can do whatever with the image-pattern version.
>>
>> What do you think?
>>
>> (I'm attacking this issue right now, incidentally, because I'm working on numerous Region performance and behavior issues, and in my travels I noticed some very useful rendering modes are not supported currently with respect to images, so I thought I would round it all out while I was in the code).
>>
>> Richard
>
David Grieve | Principal Member of Technical Staff
Mobile: +16033121013
Oracle Java Client UI and Tools
Durham, NH 03824
Oracle is committed to developing practices and products that help protect the environment
More information about the openjfx-dev
mailing list