-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for fill-opacity
#325
base: master
Are you sure you want to change the base?
Conversation
we do tend to try to use semantics names for the various possible inputs, but that's to be evaluated ton a case by case basis. Remind me what are the semantics in the offset and the opacity cases ? |
Right. Then it's better to define different types: I'll revert the renaming to offset and create a new type ☺ I think that offset relates to patterns: it moves the start of the pattern (for instance on dashed lines). If provided a percentage, then it's along the line for that percentage (and it can be negative or greater than 100%), if a number, it represents a distance (I don't know why one can't provide a unit there). For fill-opacity, the percentage must be between 0% and 100% (it's just the opacity), and the number must be between 0 and 1. So it's not only used to represent different things (distance vs alpha), but also has different bounds. I'm going to change this ☺ |
Given your description ... maybe we could just mandate a float between 0 and 1 for the opacity, actually. The two representations are redundant. |
The attribute |
There are three things: 1) The API, 2) The representation 3) The parsing Parsing should be complete (in this case, accepting both form), API should be convenient (In this case, avoid 15 layers of data format), and the internal representation should yield valid HTML5 (in this case, whatever works). |
Great! So let's write it such that we are able to write both percentages and numbers, but only storing numbers internally, and only printing out numbers ☺ I changed things in By the way, I noticed that there is a |
Yeah, it's ... not very structured. It works surprisingly well in practice :D
.... not sure. Probably not! |
Sorry for the amount of commits: it took me some time to understand how everything works. I'm starting to appreciate the point that I reached regarding the opacity attributes. What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks excellent 👍
I made some misc comments, and we can merge just after.
Note that the use of Re_str
is not mandatory, just tends to yield quick implementation.
I was in need of the
fill-opacity
attribute, so I did these changes. I haven't changed the parser yet, but I'm not sure where to start.The attribute
fill-opacity
takes the same kind of argument thanoffset
(a number or a percentage), but they mean different things: I think that it would not make sense to reuse the typeoffset
(being either a number or a percentage), so I introduced anumber_or_percentage
type. Maybe we should instead declare several types foroffset
andfill_opacity
?