-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Beta Testing of new ColorHelper of 3.0 #159
Comments
Need to add a discussion label or a beta label 🤔 . |
You know you can tag a beta release with semver pre-release conventions, and only people with your package name in the The one "gotcha" is if you are planning to make >10 pre-releases in a row. See wbond/packagecontrol.io#99 There may also be something funky with dependencies. I just haven't work enough with them to know. |
Yeah, the new color library dependency is not yet ready (close, but not yet) and not added to package control. I just wanted initial feedback. It I get a lot of action, I may create a beta release. If I don't, I'll finish it up quietly, ship it and then see what kind of complaints I get. |
Some min-contrast fixes got pushed. Mainly for handling extreme cases (when contrast cannot be achieved etc.). It seems the way the algorithm works, if the ratio is impossible for the given color to reach, it turns into white. That's simply because whether we mix black or white is dependent on whether our luminance is less than or greater than the calculated required luminance. In extreme cases, this seems to always turn into white, even if the black yields the best contrast. Once the limits of that color's luminance range are met, the algorithm will yield white. Regardless, that is just the way it is and I'm fine with it as it seems to match Sublime. |
Updated opening post with planned things. Right now, unless I get feedback for any more new things, or I happen to come up with something, I'm going to work on polishing and getting the color dependency on finished up and on Package Control. So nothing in the list is of any real note. The dependency changes may require users of the beta branch to update the dependency when I get that work done, but other than that, there should be no real big changes. Once the dependency is live, we can consider a public beta. I may advertise it on the Sublime Forum as I really am interested if anything I axed affects anyone, or if there are ways to improve this I haven't thought about. I'm not really sure how everyone uses it or what they want to get out of the tool. I know there are things I'm simply not willing to support, such as color variables as those can be external to the current file, found all over the current file, and indexing all of that and adding knowledge for how to find that info (in all of its file specific formats) is something I'm just not interested in. That kind of thing is better suited for LSP servers. |
One limitation that still exists is the fact that you can only use one color class type per view. This means if the color class you have loaded for a given view recognizes colors one way, an embedded language that recognizes colors differently and needs a different color class won't work. Sublime tmThemes are an example of this. In the main part of these files, it recognizes sRGB colors with color names defined in X11, but in regions such as popup CSS, it uses web color names. If you just use one color class in the file, in some places you'll get bad color previews. Now there is no syntax I know of that'll provide a different scope we could trigger off of for tmThemes, but it is just an example. Now, I can't promise I'll allow multiple color classes in one view, but I think we could clean things up a little and have color rules reference a color class profile that could be reused in multiple rules. Theoretically, we could allow a rule to specify multiple combinations of scopes and color classes, and depending on the point where the color is found, it could qualify to be used with one color vs another. If we don't do some refactoring, this will never be possible, so it is probably worth doing the refactor now and evaluate. |
Updates have been made to both the plugin and the underlying color library. To upgrade to the latest beta, one must fetch the latest At this point, I think I'm going to run the plugin through some testing and probably start looking towards maybe a public beta. I think everything is in place now. I think I've refactored enough now as well. Maybe I'll do some more in the future, but I need a break 🙂. |
Got some round trip conversion tests into coloraide to shake out the rest of the conversion bugs. We had a few more that were overlooked in some of the less tested color spaces. I'm now pretty confident in the color space conversions. They seem to match our reference implementation and now we are ensuring round trip conversions are good. Coloraide 0.1.2 is recommended to get all the color conversion fixes. I went through and made sure proper dialogs pop up when doing cancels via escape or using the Just an FYI, precision will affect whether some colors read as in or out of gamut when it comes to color previews. It's impractical to print out full precision (I guess technically we adjust precision and scale). We can see here that when using full precision, our conversion still has our LCH value in the "srgb" gamut. But when we output the string (which uses a default precision/scale of 5) and read it back in (much like what you get when converting in your document with ColorHelper), we see that the color reads as out of the "srgb" gamut, which we use to preview the color. >>> c = Color("blue").convert("lch")
>>> c.coords()
[29.567582570569506, 131.20704008299427, 301.36852485669147]
>>> c.in_gamut("srgb")
True
>>> c = Color(Color("blue").convert("lch").to_string())
>>> c.coords()
[29.568, 131.21, 301.37]
>>> c.in_gamut("srgb")
False So if you are converting between color spaces such as LCH and SRGB, you will find that previews may warn that they are slightly out of gamut. If you convert back, the colors are "fit' to their own gamut by default, so it will usually convert back reasonably. This is just the nature of the colors and the color spaces. The only way to avoid such things is to always be working in full precision, but nobody wants to insert long ridiculous colors 🙂. |
I'm considering bumping default precision up to 6 to account for most gamut translation issues. Granted, the user can set the output to whatever they want, but maybe 6 is a good default. |
Reduced some troublesome cases when scanning. For instance, We shouldn't treat |
Been writing docs, but got held up as I've been considering some cases in the color library. I've kind of been playing with the idea of implementing an interpolator which we can use for mixing or for interpolating colors between two colors. This is also causing me to (re)consider how I am handling null hues (hues associated with achromatic colors). Currently, we handle this on the fly, and when doing certain operations, we do an achromatic color check and treat the hue as null during certain operations. We basically trigger on achromatic or very, very near achromatic to handle slight differences when converting between color spaces. May libraries handle this a little different, and some times a little different from each other as well. A common similarity is that they use With that said, often you are allowed to inject nulls in other channels as well which can allow you to hold a channel constant during a mix if one channel has a One reference we looked at seems to always be updating the hue if the color every looks achromatic. Another accepts whatever you manually give it, but on coverts, you may end up with Now ColorHelper doesn't read in NaNs currently as they aren't (at least not anywhere in the current spec) specified as a thing you can specify, but maybe it would be useful in the color mixing tool. Anyways, I've been a little hung up here as often when you are writing documentation, you consider things a little more as you try to describe it. Once I figure out how I want to move forward, I should be able to pick up steam again. |
Some more changes were made. Walked back the option to set the gamut mapping method. We will use the default (which is honestly superior to clipping, but there are still some times that clipping is useful). If it is desired to use some other gamut mapping method, one would need to override the class and provide a custom class. We are interpolating our colors based on the We also use gamut mapping when outputting the CSS string form by default. This can be disabled if desired in most cases except when outputting hex as hex has clear constraints. Conversion can optionally fit a color during conversion. So, by default, all these methods now use whatever is the default for the color class, except for the None of this matters too much to ColorHelper as the user doesn't have access to most of this. They can adjust string output though, but now they can simply turn off or on mapping on string output. If they want to control gamut mapping, they'll have to provide a custom color class instead. This helps clean up some handling. Now we don't constantly have to check the user's preference, we just use the, frankly, better mapping method. The class exposes the gamut mapping methods for a number of functions but doesn't currently expose a way to control it specifically. It just gets more convoluted as anything we have that calls such functions then also has to expose the methods and becomes kind of a mess. So, I've decided to make it a class variable. If one were to override the class and set it to some other supported gamut mapping method. Currently, I'm not going to introduce We could use Both the latest coloraide lib and ColorHelper are available. |
Finally got the ColorAide documentation: https://facelessuser.github.io/coloraide/. It's not fully complete, but enough that it can be used as a reference for output string options and such. With that in place. I can finish up ColorHelper documentation in preparation for the public beta. |
The latest docs are done. Time to look into pre-releases on Package Control. Unfortunately, coloraide is not yet on Package Control. Maybe we'll have to vendor it to get the beta out... |
Code changes are now on the main branch. As soon as Package Control gets our dependency merged, we can pull the trigger on an official beta release through Package Control, unfortunately, my hands our tied until that happens. I don't want to change them all the references to a vendored version just to change them all again when the dependency is available. Now we wait 🤷 |
https://facelessuser.github.io/ColorHelper/installation/#install-3.0-beta You have to use the channel repo file mentioned in the docs to get the dependency, but it works. Once the dependency is available in PC officially, the repo file can be removed from Package Control settings. |
Hello Isaac (@facelessuser), I'm currently trying out the 3.0-beta in Sublime Text Version 3.2.2., Build 3211. I did the installation via Packagecontrol.io as requested on the #install-3.0-beta section. I do mainly color schemes & themes for different stuff. I love to see the colors in Sublime Text while I work on the configurations. I keep track of all my used colors in a I did get the plugin to work with How can I help figure out why it is not working? Thanks and take care |
@mickimnet is this because you had a custom rule that no longer highlights colors in Markdown? Or that an old rule incidentally used to highlight colors and Markdown and no longer does due to the reworking of rules? I imagine it is the latter. |
@mickimnet I'm not seeing an issue with Markdown. I would need more information.
As you can see, colors are working Markdown for me: |
Hello @facelessuser, sorry, I could have provided more information and explanations. My bad 😞 Let me reiterate: I'm not talking about inline code blocks in Markdown--I replicated the code snippet from your screenshot and it works with my settings--, I'm referring to plain Markdown content, like: | | | Color value |||
| Name | Color | HSL | HEX | Shell |
| -----------------------: | :-----------: | :--------------------- | :-------: | :---: |
| myth_foreground | Whiteish | hsl(0, 0%, 93%) | #EEEEEE | 253 |
| myth_background | Blackish | hsl(0, 0%, 7%) | #111111 | 233 |
| myth_find_hl_bg | Sand | hsl(47, 100%, 79%) | #FFE792 | 222 |
| myth_comments | Grey | hsl(290, 3%, 43%) | #6F6A70 | 59 |
| myth_main | Orange | hsl(38, 100%, 50%) | #FFA200 | 214 | My current settings for the ColorHelper beta v3.0 -- I'm using MarkdownEditing for the syntax definitions (with the GFM part): {
"name": "Markdown",
"syntax_files": [],
"extensions": [".markdown"],
"base_scopes": [ "text.html.markdown", "text.html.markdown.gfm" ],
"color_class": "css-level-4",
"scanning": [
"meta.paragraph.markdown",
],
} My point is, that above Markdown section was highlighted with the current v2 version of ColorHelper, with the same syntax package and the following settings: {
"syntax_files": [],
"syntax_filter": "whitelist",
"base_scopes": ["text.html.markdown"],
"scan_scopes": [
"meta.paragraph.markdown",
],
"allowed_colors": ["hex", "hex_compressed", "hexa", "hexa_compressed", "rgb", "rgba", "hsl", "hsla", "gray", "graya", "hwb", "hwba"],
"extensions": [".markdown"],
"use_hex_argb": false,
"compress_hex_output": true
} Hope that makes it more clear and helps. Thank you and take care! |
So, things changed in regards to rules. I believe before, ColorHelper allowed multiple config rules to stack, that is no longer the case with ColorHelper 3.0. So, what is happening in your case is that the HTML rule is getting selected instead of your Markdown one, that is because the HTML rule only checks if the first character in the view has the desired base scope. You can change that to look for syntax file's instead or other various things. In the example below, I just override the HTML rule to exclude your Markdown scope: "user_color_rules": [
{
"name": "Markdown",
"syntax_files": [],
"extensions": [],
"base_scopes": ["text.html.markdown", "text.html.markdown.gfm"],
"color_class": "css-level-4",
"scanning": [
"meta.paragraph.markdown",
],
},
{
"name": "HTML/CSS",
"base_scopes": [
"source.css",
"text.html -text.html.markdown"
]
}
] |
Oh! I didn' t knew that. Thank you very, very much. It works now! |
Hello @facelessuser, I found another issue, I cannot quite put my finger on it: Sometimes (it happens regularly, but I didn't found a pattern so far), the display of the colors doesn't work for the head of the file. See: Can I provide further information? Take care, |
|
Are you using hardware acceleration? Does it work better (after a restart) when you modify that setting in the Sublime preference file? Is this ST3 or ST4? |
Updated opening post with more tasks to look into. |
Hello @facelessuser, I've to admit, that I'm a bit lost at the new configuration options. Today, I updated my Sublime Color Scheme with geometrical based colors (small adjustment, big improvement) and was trying to get the colors displayed in the I'm back on Sublime Text Version 3.2.2., Build 3211 and am using the following configuration option: "user_color_rules": [
{
// Sublime Color Schemes (based on Sublime Default)
"name": "Sublime Color Schemes",
"syntax_files": [ ".sublime-color-scheme" ],
"base_scopes": [ "source.json" ],
"color_class": "sublime-colormod",
// "color_class": "css-level-4",
"scanning": [
"string.quoted.double",
],
}, I tried also with-out the following (switched one of at a time):
Thanks and take care |
"syntax_files": [ ".sublime-color-scheme" ],
ColorHelper supports Sublime Color Schemes out of the box already if you are using the PackageDev plugin. I personally recommend that as it has better scoping which makes it easier for us not to highlight false positives. We provide a rule for PackageDev in the default setttings, This will handle color-mod functions too: {
"name": "PackageDev Sublime Schemes/Theme",
"syntax_files": [
"PackageDev/Package/Sublime Text Color Scheme/Sublime Text Color Scheme",
"PackageDev/Package/Sublime Text Theme/Sublime Text Theme"
],
"color_class": "sublime-colormod",
"color_trigger": "(?i)(?:\\b(?<![-#&])(?:color|hsla?|hwb|rgba?)\\(|\\b(?<![-#&])[\\w]{3,}(?!\\()\\b|(?!<&)\\#)",
"scanning": [
"source.css-color -meta.function-call.var.sublime-color-scheme",
"meta.css.sublime-color-scheme meta.property-value.css -comment -string.quoted.single.css -string.quoted.double.css"
]
}, |
🤦🏻 Sorry, I'm dumb. Thank you very much! I thought I had |
Be aware that I may remove the extension setting as it really isn't a practical way to specify the view for ColorHelper. Really, syntax should be used instead which is often set by the extension. So indirectly you end up triggering off of the extension. |
Good to know. Will change the settings. Thank you very much! If you need further testing on Sublime Text 3, please let me know. Happy to help. |
Sure. I haven't tested ST3 too well except as a sanity check. It's good to know though that I need a bit more testing there. |
Coloraide has been available on Package Control for a while. Looking to update it very soon to handle the color form when multiple color options are provided One thing to note is previously the spec allowed sRGB colors to omit the color space when using the |
New beta.02 is out.
Still more things to do before a stable release 🙂. |
Sounds like the CSS people are thinking about dropping fallbacks for colors. This means it is looking like I shouldn't waste time on that 🙂. This greatly simplifies what I had in the pipes. So, I think this means I can focus on looking into any polish needed on ST3 (I'd like to have it work as well as it does on ST4). The only other thing on my list is probably simplifying the conversion logic in Coloraide. I know that the package, from which Coloraide takes inspiration, mainly uses XYZ as the common path for most of the conversions. We do the same, but they also seem to have a way where each color class has color-specific conversions to get them to XYZ, and the library just finds the best path. I'd like to do something similar if possible to help reduce some of the logic in the conversion part. |
Beta 3 is out with a number of bug fixes. Fixes down in the coloraide dependency and in the actual plugin. |
A couple of things I plan on addressing in beta 04 is fixing some of the mixing logic. Apparently, we are not quite following the mix logic in CSS level 5 in regards to handling the multiple percentages. When adding the two percentages together, if they do not meet 100%, we need to set Additionally, we should not clamp percentages between What this means is that you could technically mix a color with Some are arguing that percentages greater than 100 should also be clamped. If that decision is made, we will do the same here. Regardless, there is an open issue discussing this at the CSS working group, and I am waiting to see how that discussion goes. We are also working on premultiplied transparent colors as well. I'm not sure if this will be the default in mixing or not, but it appears to be the way color level 5 is going. While support may soon be in the underlying library, we may wait to expose such behavior. |
Our mix logic better matches latest draft of color-mix. The logic that is, not syntax. The syntax actually seems much more simple in later drafts: color-mix(in lch, red 40%, blue) Adjuster logic is moved to So, after reading the color-mix(in lch, red 0%, blue 30%)
color-mix(in lch, red 0%, blue 0%) With a case like: color-mix(in lch, red 0%, blue) You would assume to use blue and just convert it. But with When given something like below, you assume both are mixed at 50% because nothing is specified. color-mix(in lch, red, blue) But with color-mix(in lch, red 0%, blue 0%) Do you do the same? Because both colors have zero, so you shouldn't use either, but since they are excluded, and you have to return something, do you just assume the percent's as undefined and return them mixed at 50%? Or do you return something like an opaque black? We are going to assume 50%, but I'm not sure if that is correct. |
Just to reiterate, while we are modeling logic after
Could we change in the future to the following?
Sure, but we haven't. I'm not even sure whether the CSS spec knows what they are settling on, but currently that is kind of what they are doing, except they also allow percent and color in any order, so this is also valid:
I'm not quite sure why they have to be so loose with their syntax 🤷 . |
I'm convinced the CSS working group doesn't know what they want yet. I was digging into conversations and such in their issues. We ended up sticking with roughly what we had before except it won't clamp 100. If totals exceed 100%, the values are scaled. There is no decision on what to do when the total is less than 100%, so we scale until we know better. There is no decision on what to do when the percentage is negative, so we clamp anything less than zero. That is what we'll stick to until at some future time the CSSWG decides what to do. |
This might very well be the last beta, but Beta 04 is out. Also, run
I ended up basically setting mix logic back to the way it was. I don't know if the CSS WG will have a decision on mixing by time I get an official release out, but I've noted in the docs that there are still some incomplete things in the algorithm due to the CSS WG still working it out. They mention they may figure it out by next week, but 🤷. I've tested it in ST3 and ST4. I think the underlying color lib is good enough at this time. I'm pretty excited about getting 3.0 out the door. Hopefully, people like the new version as much as I do. I think it is now in a state I can maintain without dreading to work on it. Color support is much, much better, supporting colors of the future. I appreciate the feedback I've gotten in the time I've been running the beta. Unless I run into bugs, I only expect maybe some minor changes, if any, between now and the final release. Maybe the mixing algorithm 🤞, and maybe subtle changes to some of the popup panels, but maybe not. |
I may just make the color mixer take one percentage. Instead of trying to mimic the In reality, By only requiring one percentage, you take out all of this nonsense, and can just pass the percentage directly to the interpolation algorithm. Problem solved. |
I actually understand the current algorithm for mixing now. It does work for negatives and everything...except if you two percentages that sum to zero. Then you get a divide by zero. So I understand what they meant to do, they just didn't think about the corner case of While I originally misunderstood the normalizing of the percentages, my original statement of using one percentage instead still holds true. |
So I did end up releasing a Beta 05 with the correct algorithm for mixing percentage resolution. It all works as stated in the spec now, but it does have an issue I do see why they did what they did. This way, you can attach a percentage to the color you want, and that part is intuitive. Attaching a percentage to both colors is a little less intuitive if the values do not sum to 100%, but they handle it by normalizing the values, treating them as weights on each color, which is fine. It works out and the mixing becomes extrapolation instead of interpolation. Again, not an issue, but maybe surprising if you are thinking about color mixing as mixing paint. You can see the algorithm here at work. It's really not complicated: https://codepen.io/facelessuser/pen/eYBLWjd. Really, if they keep things the way it is, they just need to mention what to do when |
Wasn't planning on it but while going over the coloraide lib, and thinking about trying to finalize the API and such, I decided to go back on a decision I made early on and have reintroduced The only way this noticeably affects ColorHelper is that when using the color picker with HSL or HWB colors, when saturation is 0 in HSL or W + B >= 100 in HWB, you can't change the hue, and it always shows as zero. This makes sense as Hue is now null, and we just use zero on string output. Before, we were calculating null hue on the fly, so we were able to keep the input value. Now, just due to how things serialize and come back to the popup, this is just how it is going to be. I don't feel like working around this. If people really complain, I can probably output the colors with a visible So Beta 06 basically has the following:
I'm not touching the ColorAide lib anymore before the final release, and I'm not touching ColorHelper. Unless a bug surfaces in Beta 06, this is probably the release candidate. I don't expect the CSSWG to address my current confusion next week, but if they do, whatever the resolution is, I'll ensure it is in the final release. |
I think I plan on making the final release on Friday next week, with any reported bugs fixed. There would have to be something major to keep me from pulling the trigger. |
ColorAide dependency is now at 0.1.0a6. A number of fixes. Just run On a side note, the CSSWG, while not committing to yet to the current percent algorithm, at least acknowledge they need to define |
Looks like we had an issue parsing compressed hex values with alpha in, but not on output. Basically, we were taking things like The dependency was updated to 0.1.0a7 to fix this issue. No changes to ColorHelper itself. |
We are poised for release! I've spent the last number of days (when I had a chance) getting things as stable as possible. There will be a few bug fixes in the next release, which will be the final 3.0 release.
All of these will be fixed tomorrow. We'll see how the greater audience responds. I'm expecting some flack on why certain things were removed, but that is the price of me moving forward with this project. Some buggy things had to go. |
Went ahead and tagged the release. It should be available in the next couple of hours. Now we get to see what people think outside of the beta test group. |
Feel free to try out the current beta and discuss, give feedback,etc.
Instructions
https://facelessuser.github.io/ColorHelper/installation/#install-3.0-beta
Let me know if you run into hiccups or something doesn't work.
Planned Changes
Handle color functions that specify fallback colors:. Looks like this is getting dropped from CSS spec 🎊.color(display-p3 0 1 0, rgb(0 100 0))
ColorHelper is meant to find instances of single colors. But some fallbacks are only valid when they are inside a color function. How do we handle those? In this case (Looks like this is getting dropped from CSS spec 🎊.color(display-p3 0 1 0, 0 1 0)
) the fallback is assumed to be srgb, but we can't just add a pattern to find random numbers and treat them as colors. The underlying library that handles color is meant to define and manipulate single colors, not to return an array of colors for a single color instance. Basically, we need to decide if we are just going to ignore such instances or provide more complexity to find such colors.Changes (so far)
3.0.0
lch
,lab
,display-p3
,rec-2020
,xyz
,prophoto-rgb
,a98-rgb
, andhsv
.rgb
,hsl
, andhwb
all support the new CSS formatrgb(r g b / a)
.blacklist
andwhitelist
are now known asblocklist
and
allowlist
respectively.is a color) can be configured in settings file. This can allow a user to not trigger
on certain formats.
files that can augment one or more supported color space's accepted input and output
formats.
Text that is not visible, both vertically or horizontally, will not be scanned until
it scrolls into view.
preview_on_select
to show color previews only when the cursor ison the color or selecting the color (currently only applied to one selection).
they alter the coordinates, and allows the user to mix it with one other color. The
result can be inserted back into the file, or will be handed back to the color picker
if called from there.
see a visual representation of how the two colors contrast. The resulting foreground
color can be inserted back into the file, or will be handed back to the color picker
if called from there.
color_scan
option tocolor_rule
.(on ST4) it will indicate that it has been gamut mapped. This can be disabled via
show_out_of_gamut_preview
, and instead a fully transparent color swatch with a"red-ish" border will be shown (color may vary based on color scheme). On mouse over
it will indicate that it is out of gamut (on ST4).
a certain color space (contrast tool and color picker only apply spaces easily
translated to sRGB), ColorHelper will have to gamut map a color. Two forms of gamut
mapping are provided
lch-chroma
andclip
.preferred_gamut_mapping
controllswhich method is preferred with
lch-chroma
being the default.necessity, or by user setting.
generic
option is defined which provides a default input and output forfiles with no rules. Users can use the color picker, and other color tools, from any
file now. Scanning is disabled by default and can be enabled if desired.
generic
canbe tweaked to provide whatever fallback experience the user desired.
Also can force a file with scanning enabled to be disabled.
transparent
.selected color.
channel.
user_color_rules
where user can append rules without overwriting theentire rule set. If a rule uses the same
name
as one of the existing default rules,a shallow merge will be done so the values of the top level keys will be overridden
with the user keys and/or any additional keys will be added.
time the user needs it already.
current file and generate a palette. This only worked in a limited number of files and
added much more complexity.
class object that is being used. For instance, input and output format of colors in the
form
#AARRGGBB
instead of the default#RRGGBBAA
would need need to use the newexample
ColorHelper.custom.ahex.ColorAhex
custom color object to read in and outputhex colors with leading alpha channels.
The text was updated successfully, but these errors were encountered: