-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove StyleDeclarationSet and PaintProperties classes
- Loading branch information
Lucas Wojciechowski
committed
Jan 22, 2016
1 parent
e0e0a9c
commit ec62ab8
Showing
9 changed files
with
125 additions
and
135 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
var parseCSSColor = require('csscolorparser').parseCSSColor; | ||
var util = require('../util/util'); | ||
|
||
var colorCache = {}; | ||
|
||
function parseColor(input) { | ||
|
||
if (colorCache[input]) { | ||
return colorCache[input]; | ||
|
||
// RGBA array | ||
} else if (Array.isArray(input)) { | ||
return input; | ||
|
||
// GL function | ||
} else if (input && input.stops) { | ||
return util.extend({}, input, { | ||
stops: input.stops.map(parseFunctionStopColor) | ||
}); | ||
|
||
// Color string | ||
} else if (typeof input === 'string') { | ||
var output = colorDowngrade(parseCSSColor(input)); | ||
colorCache[input] = output; | ||
return output; | ||
|
||
} else { | ||
throw new Error('Invalid color ' + input); | ||
} | ||
|
||
} | ||
|
||
function parseFunctionStopColor(stop) { | ||
return [stop[0], parseColor(stop[1])]; | ||
} | ||
|
||
function colorDowngrade(color) { | ||
return [color[0] / 255, color[1] / 255, color[2] / 255, color[3] / 1]; | ||
} | ||
|
||
module.exports = parseColor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters