thedutchcoder / colorconvert Goto Github PK
View Code? Open in Web Editor NEWA Sublime Text 2 plugin that converts CSS colors from hex to rgb and back
License: MIT License
A Sublime Text 2 plugin that converts CSS colors from hex to rgb and back
License: MIT License
The problem is: I have to select completely the color for then execute the key binding. I could see in other plugins like "Hex-to-RGBA" that staying the cursor over the color it is possible to execute the key binding but here it doesn't work.
If I first convert an RGBA or an HSLA to a HEX, and then go and mess with a different line entirely... the original A value from the first line gets applied to the second line. The value gets 'stuck'.
e.g. Convert both lines to HSLA in order:
box-shadow: inset 0 3px 9px rgba(0,0,0,0.25);
color: #000;
You get:
box-shadow: inset 0 3px 9px hsla(0.0, 0.0%, 0.0%, 0.25);
color: hsla(0.0, 0.0%, 0.0%, 0.25);
^D
for Quick Add Next
)โโงC
)V
rgba(242, 242, 242, 1.0)
V
hsla(0.0, 0.0%, 94.9%, 1.0)
V
Hi.Good work. Do u think it's possible to write same for Synwrite?
https://sourceforge.net/p/synwrite/wiki/python%20API/
if u refactor code, so convert is a separate Def, i can make it
In large projects that I work on we always have a color.scss file which defines numerous colors to variables. Often times, remembering those variables can be difficult and am constantly cross-referencing back to the variable definitions to determine which variable to use.
Request feature, to define variables in plugin preferences and autoreplace color values when entered as hex/rgb/hsl to the appropriate variable name.
I can't find the package using Package Control on Sublime Text 3.
Any ETA when it's going to be supported?
Hi, very handy plugin.. cudos & thx!
In your Readme you state the keycombo was Ctrl. - Shift - c
.. however here on OSX it actually is Cmd. - Shift - c
. Dunno if this is a OS thing or the Readme evtl. is outdated.. anyway, just wanted to let you know.
cheers,
Jan
You have put in a shortcut which is very handy. However, shortcuts can be hard to remember if not used often.
It'd be a plus if I could open the command palette and start typing the command, "Convert CSS... enter" or even "Convert CSS color to [rgba]".
An idea for an enhancement. If it's simple enough, it will help me and possibly others. Thanks for the useful plug-in!
I notice it supports an integer for opacity, but not for hue...
hsla(1, 63%, 28%, 1.0)
won't convert but...
hsla(1.0, 63%, 28%, 1)
will convert
Seems like an oversight.
Is there any plan to allow converting to rgb()? If I'm supporting IE<8 I'd like to be able to just use rgb without alpha.
This would be a really useful feature to add, and shouldn't be too hard.
For instance, when converted back to HEX it gets lower-cased.
So:
{
"color-case": "upper"
}
I'm sorry for bring you this topic, but I believe you took a bad decision when you chose to always use the alpha value.
First, if you allow us to convert to and from HEX, which doesn't support alpha, you're showing that a non-alpha value is acceptable.
Probably, one of the most used tasks for your plugin is to create fallback colors. But, if we can't create RGB colors, we can't use it for IE4-8, which doesn't support RGBA. Personally, I don't care about IE6 or 7 anymore, but, for the God sake, there are still developers who have to. So, without RGB, the fallback colors have to be HEX, what turns into a bug. Your idea of saving self.alpha
globally is causing conflicts. If you convert a color with ALPHA value and then convert another color which doesn't have an ALPHA, the value of the previous ALPHA appears again! This is a serious bug.
So, my suggestion for you is just use the ALPHA value if it is different of 1 and to add a comment to the HEX color when it is converted from a value with an ALPHA. For example:
/**
* Well, this format is just a suggestion.
*/
rgba(20,105,140,.3) -> #14698c/*A: .3*/
I believe that to keep the ALPHA value close to the HEX color makes better fallback colors on CSS and keep the conversion on your plugin easier to code. Even better, allowing RGB and HSL will save 3 characters for every non-ALPHA color and, in the front-end world, size matters.
I mainly use hex codes out of habit, but sometimes, I need to switch over to RGB for transparency, etc. Would it be possible to have a "convert all" options that switches all HEX colors to RGB?
I want change the keyboard shortcut because it's conflict with another package how can i do that?
Tanx
Not sure if this is an issue with this plugin or something else. Everything was working fine, then I think it coincided when I updated to Sublime v2.0.2, Build 2221 (but I'm not sure if that is the impetus). Anyway, when I invoke ColorConvert using Cmd+Shift+C on my Mac, I get the following in Sublime's console:
Traceback (most recent call last):
File "./sublime_plugin.py", line 362, in run_
File "./colorconvert.py", line 280, in run
ValueError: zero length field name in format
All other packages and their keyboard mappings seem to be working just fine.
Any help would be appreciated...
I would love to use this in a project I am working on. What is the license?
The regexp you're using to detect hex codes isn't correct: it will also match hex codes of 4 and 5 characters.
I don't know about python, but in js this would be what you're looking for:
/^#([a-f\d]{3}){1,2}$/i
Any chance of HSLA conversion? Also, please create a command palette listing instead of a default keybind, and let the user choose where and if they want the keybind - it's very awkward and time-consuming to replace default keybinds at the moment; quite a serious problem in Sublime.
If alpha value contains two-digit fractional part, eg 0.55, converting don't work.
Due to this if convert eg rgba(159, 205, 0, 0.75) to hsla(73.5, 100.0%, 40.2%, 0.75) and delete 5 in 0.75 it always convert to #000
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.