Class: OoxmlParser::ThemeColors

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb

Overview

Class for hold ThemeColors list

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #initialize, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#listHash

Returns list of colors.

Returns:

  • (Hash)

    list of colors



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb', line 7

def list
  @list
end

Instance Method Details

#parse_color_theme(theme, tint) ⇒ Color

Parse color theme

Parameters:

  • theme (String)

    name of theme

  • tint (Integer)

    tint of theme

Returns:

  • (Color)

    color of theme



13
14
15
16
17
18
19
20
21
# File 'lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb', line 13

def parse_color_theme(theme, tint)
  themes_array = root_object.theme.color_scheme.values
  # TODO: if no swap performed - incorrect color parsing. But don't know why it needed
  themes_array[0], themes_array[1] = themes_array[1], themes_array[0]
  themes_array[2], themes_array[3] = themes_array[3], themes_array[2]
  hls = themes_array[theme].color.to_hsl
  tint = 0 if tint.nil?
  hls.calculate_rgb_with_tint(tint)
end