-
Notifications
You must be signed in to change notification settings - Fork 93
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
RGBA and HSLA are compiled incorrectly #116
Comments
I think that was intentional and, I do admit, is probably surprising. It's been a while but I think my rational was that The RGBA model, in my opinion, places more of a cognitive load on the reader since they need to mix the colors in their head. The HSLA model on the other hand only requires an understanding of the color wheel it's based on, the angle (modulo 360), and then adjustment of saturation. IIRC most of the color operations are computed in terms of HSL because of it's simplicity. Again, this is my personal opinion and I understand if it's confusing or surprising. If it's important the design can be adjusted to persist a |
Saturation and lightness should be percentages, though. It seems the % is dropped when the value is zero, which creates an invalid property value. |
@ejlo I'm not certain that it is invalid. My memory could be off but I don't recall that being the case in the CSS spec. |
em { color: rgb(255,0,0) } /* integer range 0 - 255 */
em { color: rgba(255,0,0,1) /* the same, with explicit opacity of 1 */
em { color: rgb(100%,0%,0%) } /* float range 0.0% - 100.0% */
em { color: rgba(100%,0%,0%,1) } /* the same, with explicit opacity of 1 */ It isn't clear to me if |
@noprompt Chrome is complaining though. Perhaps it's an issue specifically with box-shadow? |
@levitanong No, I just confirmed this by editing a style on the page. It definitely looks like we need to emit |
The spec seems to indicate that hsl is different than rgb. For rgb you can have either integers or percentages (but all three values must be of the same type), whereas for hsl the first (hue) is an integer, but the other two should be percentages. |
@ejlo Yeah, I suspected as much. I'll convert this issue to a bug and fix it as fast as I can. @levitanong Thanks for reporting this. |
@noprompt My pleasure :) |
i've seen the "hsl is simpler to understand" argument floating around for a while, but at the end of the day, this is a personal preference. my preference is rgb and know plenty of others who work with rgb almost exclusively (because we like it :P). willing to accept that it might make sense to use hsl as a default when you don't know what the user prefers. OTOH, unconditionally converting to hsl even when someone has explicitly asked for an rgba value is less OK. What benefits are gained by changing formats between the clj source and rendered css? I can see a few drawbacks:
|
@thedavidmeister Thanks for your contribution to the discussion. I've already admitted to it being surprising and that my original decision to automatically convert to HSL/HSLA was based on personal opinion. I have no disagreements with the notion that what you type should be what you get (you can still write in RGB/RGBA, the compilation just needs to be correct). My intention is to resolve this issue in the near future. I've been hard at work at creating a new release of this library but my free time is somewhat limited. Regarding the drawbacks, I think the first and third are worthy points but the second is not. This is just a nitpick, but the principle of least surprise is highly amendable to interpretation and, honestly, I don't think it's a relevant talking point. A good example of this was given by Yukihiro Matsumoto, the creator of Ruby, who, in an interview stated
Since this principle largely depends on individual interpretation, emphasizing it doesn't add much value to the conversation. To give a personal example, when I originally made the decision to compile to HSL/HSLA, I did not anticipate end users being concerned by this because it worked and I felt that the color semantic was more important than the compiled notation. If the color expected to be rendered to the screen was rendered to the screen as expected, why emphasize the notation? To make my point, it wasn't surprising to me and I didn't think it would be surprising to others since my emphasis was on semantic and not notation. This aside, it's still no excuse for the bug persisting as it stands today. |
is the conversion from rgb to hsl lossless? |
@thedavidmeister Aside from the compiler bug and according to color math, yes. |
@thedavidmeister I could verify this in |
yeah cool, a few months back someone in my team had problems where they wanted to extrapolate a palette of colours from a starting colour with a modulo operation that was supposed to bring them back to the start after a few "shifts" of the colour based on some calculation. because they were accidentally triggering an implicit lossy conversion between rgb and hsl in the library they were using, the palette generation would "sometimes" hang - it never actually got back to the starting values due to rounding errors along the way. i'm not saying this library has the same issue, but i thought it could be helpful to share an example of how this type of thing could cause real world problems |
Okay. So the main problem here is that there is currently only one type for representing colors, The only way forward I can see is by breaking the API and releasing a new major version which uses the Since I'd like the next version to address more than that, I will start by releasing an alpha version which will include the updates to the color namespace using the extracted library code. I will leave a note here when that's available. |
This patch rethinks the architecture of Garden in terms of well defined boundaries between parsing and compiling. Instead of directly compiling objects into CSS, Garden will first parse the objects into a CSS AST which can then be consumed by the compiler. This architecture is closer to what one might expect to find in a programming language implementation setting. This new architecture yields greater flexibility to introduce new features and semantics while vastly simplifying the work of the compiler. As a result many requested features and solutions to bugs have now been either implemented, solved, or are now trivial to implement or solve. Changelog updates forthcoming. Closes #31 Closes #109 Closes #115 Closes #116 Closes #119 Closes #120 Closes #121
I've been rummaging a lot of code trying to find out why colors where being output incorrectly here. I ended up adding a slight rotation to all colors with an alpha-channel. Is |
@hkjels It's not. It's usable but I'm waiting for clojure 1.9 and the spec to settle down or at least the latter. |
@hkjels You can actually clone this repository, switch to the |
I tried that earlier, but it failed with some cryptic error-message. Maybe I'll have yet another look |
@hkjels You can post the error message here if you like. |
@noprompt So, it's just that I'm relying on a newer version of |
A few of the colors that I was generating with @noprompt If we're okay with using Clojure's alpha libraries, is the solution in the meantime to:
My hackish solution in the short-term was to turn pretty-printing off. |
The problem with the percent sign happens when compiling not pretty printed
|
And that's a bug in YUI Compressor |
Also got bitten w/ this with pretty print off |
e.g.
is converted to:
The text was updated successfully, but these errors were encountered: