Round alpha channel in TextMate theme rgba colors to 2-decimal places

This commit is contained in:
Nathan Sobo
2012-09-28 16:43:02 -06:00
parent 4ba5ccb0fa
commit 5ad6c67e07
2 changed files with 5 additions and 3 deletions

View File

@@ -46,7 +46,7 @@ describe "TextMateTheme", ->
expect(rulesets[2]).toEqual
selector: '.editor.focused .selection'
properties:
'background-color': "rgba(221, 240, 255, .2)"
'background-color': "rgba(221, 240, 255, 0.2)"
it "returns an array of objects representing the theme's scope selectors", ->
expect(rulesets[11]).toEqual
@@ -62,4 +62,4 @@ describe "TextMateTheme", ->
selector: ".invalid-illegal"
properties:
'color': "#F8F8F8"
'background-color': 'rgba(86, 45, 86, parseInt(textmateColor[7..8], 16))'
'background-color': 'rgba(86, 45, 86, 0.75)'

View File

@@ -105,4 +105,6 @@ class TextMateTheme
g = parseInt(textmateColor[3..4], 16)
b = parseInt(textmateColor[5..6], 16)
a = parseInt(textmateColor[7..8], 16)
"rgba(#{r}, #{g}, #{b}, #{a / 255.0})"
a = Math.round((a / 255.0) * 100) / 100
"rgba(#{r}, #{g}, #{b}, #{a})"