Skip to content

Commit

Permalink
Parse solid color
Browse files Browse the repository at this point in the history
  • Loading branch information
meltingice committed May 4, 2015
1 parent c0ce722 commit 4ce0325
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/psd/layer/info.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ LAYER_INFO = {
nestedSectionDivider: require('../layer_info/nested_section_divider.coffee')
objectEffects: require('../layer_info/object_effects.coffee')
sectionDivider: require('../layer_info/section_divider.coffee')
solidColor: require('../layer_info/solid_color.coffee')
typeTool: require('../layer_info/typetool.coffee')
vectorMask: require('../layer_info/vector_mask.coffee')
}
Expand Down
21 changes: 21 additions & 0 deletions lib/psd/layer_info/solid_color.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
LayerInfo = require '../layer_info.coffee'
Descriptor = require '../descriptor.coffee'

module.exports = class SolidColor extends LayerInfo
@shouldParse: (key) -> key is 'SoCo'

constructor: (layer, length) ->
super(layer, length)

@r = @g = @b = 0

parse: ->
@file.seek 4, true
@data = new Descriptor(@file).parse()

@r = Math.round @colorData()['Rd ']
@g = Math.round @colorData()['Grn ']
@b = Math.round @colorData()['Bl ']

colorData: -> @data['Clr ']

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"browserify": "~ 3.46.0",
"mocha": "~ 1.18.2",
"should": "~ 3.3.1",
"rimraf": "~ 2.2.8"
"rimraf": "~ 2.2.8",
"codo": "~ 2.0.11"
}
}

0 comments on commit 4ce0325

Please sign in to comment.