Skip to content

Commit

Permalink
fix #3 default to rgba hex; new setting for argb
Browse files Browse the repository at this point in the history
  • Loading branch information
braver committed Aug 18, 2021
1 parent 08743a8 commit 940276c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ColorHints.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def get_cursor_color(view, region):
color = None
alpha = None
alpha_dec = None
settings = sublime.load_settings('ColorHints.sublime-settings')
argb = settings.get('argb_hex', False)
point = region.begin()
visible = view.visible_region()
start = point - 50
Expand All @@ -38,7 +40,7 @@ def get_cursor_color(view, region):
ref = point - start
for m in util.COLOR_RE.finditer(bfr):
if ref >= m.start(0) and ref < m.end(0):
color, alpha, alpha_dec = util.translate_color(m, True)
color, alpha, alpha_dec = util.translate_color(m, argb)
break
return color, alpha, alpha_dec

Expand Down
5 changes: 4 additions & 1 deletion ColorHints.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
// - always
// - never
// - in scope selector, eg 'source.css, source.scss, source.sass, source.less, text.html'
"live_hints": "always"
"live_hints": "always",

// Interpret hex values with an alpha channel as argb (not rgba)
"argb_hex": false
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ Call up an inline color box displaying the color at the cursor(s). Live hints ca

ColorHints currently understands:

- hex(a)
- hex(a)<sup>*</sup>
- rgb(a)
- hsl(a)
- hwb(a)
- css color names (e.g. "aliceblue" or "rebeccapurple")
- Pantone color codes (e.g. "16-1546 TCX" or "Yellow 012 C")
- RAL classic color codes (e.g. "RAL 6034")

<sup>*</sup>) Set the "argb_hex" preference to `true` for (a)hex, ie. argb in hex values.

## Notes

The alpha (opacity) value is not represented in the hint. In these small samples it's impossible to properly judge the opacity anyway, and it's usually more interesting to know the base color.
Expand Down

0 comments on commit 940276c

Please sign in to comment.