Skip to content

Commit

Permalink
Merge pull request #233 from WARP-LAB/master
Browse files Browse the repository at this point in the history
Add option to always display alpha and fix vec4 alpha to always be float
  • Loading branch information
thomaslindstrom authored Apr 12, 2018
2 parents 65195dc + aad6f98 commit 05d10d7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions lib/ColorPicker.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
description: 'Replace selected color automatically on change. Works well with as-you-type CSS reloaders.'
type: 'boolean'
default: false
# Always output alpha value
alphaChannelAlways:
title: 'Always include alpha channel value'
description: 'Output alpha channel value, even if it is 1.0'
type: 'boolean'
default: false
# Abbreviate values configuration: If possible, abbreviate color values. Eg. “0.3” to “.3”
# TODO: Can we abbreviate something else?
abbreviateValues:
Expand Down
4 changes: 2 additions & 2 deletions lib/extensions/Color.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
setColor: (smartColor) ->
_color = smartColor.toRGBA()
return if @previousColor and @previousColor is _color

@el.style.backgroundColor = _color
return @previousColor = _color
colorPicker.element.add @element.el
Expand Down Expand Up @@ -133,7 +133,7 @@
_format = _formatFormat or _inputColor?.format or _preferredFormat or 'RGB'

# TODO: This is very fragile
_function = if smartColor.getAlpha() < 1
_function = if smartColor.getAlpha() < 1 || atom.config.get 'color-picker.alphaChannelAlways'
(smartColor["to#{ _format }A"] or smartColor["to#{ _format }"])
else smartColor["to#{ _format }"]

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/SmartColor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
toVECA: ->
_vecaArray = @toVECAArray()
return s "vec4(#{ f _vecaArray[0] }, #{ f _vecaArray[1] }, #{ f _vecaArray[2] }, #{ f _vecaArray[3] })"
toVECAArray: -> @toVECArray().concat [@getAlpha()]
toVECAArray: -> @toVECArray().concat [(@getAlpha()).toFixed 2]

# HEX
# ---------------------------
Expand Down

0 comments on commit 05d10d7

Please sign in to comment.