Class: Scruffy::Themes::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/scruffy/themes.rb

Overview

Scruffy::Themes::Base

Author

Brasten Sager & A.J. Ostman

Date

August 27th, 2006

The base theme class. Most themes can be constructed simply by instantiating a new Base object with a hash of color values.

See Scruffy::Themes::Base#instantiate for examples.

Direct Known Subclasses

Apples, CareBears, Keynote, Mephisto, RubyBlog, Standard, Tulips, Vitamins

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(descriptor) ⇒ Base

Returns a new Scruffy::Themes::Base object.

Hash options:

background

background color.

colors

an array of color values to use for graphs.

marker

color used for grid lines, values, data points, etc.

font_family

in general, allows you to change the font used in the graph. This is not yet supported in most graph elements, and may be deprecated soon anyway.



38
39
40
41
42
43
44
45
46
47
# File 'lib/scruffy/themes.rb', line 38

def initialize(descriptor)
  self.background = descriptor[:background]
  self.colors     = descriptor[:colors]
  self.outlines     = descriptor[:outlines]
  self.marker     = descriptor[:marker]
  self.font_family = descriptor[:font_family]
  self.marker_font_size = descriptor[:marker_font_size]
  self.title_font_size = descriptor[:title_font_size]
  self.legend_font_size = descriptor[:legend_font_size]
end

Instance Attribute Details

#backgroundObject

Background color or array of two colors



20
21
22
# File 'lib/scruffy/themes.rb', line 20

def background
  @background
end

#colorsObject

Array of colors for data graphs



21
22
23
# File 'lib/scruffy/themes.rb', line 21

def colors
  @colors
end

#font_familyObject

Font family: Not really supported. Maybe in the future.



24
25
26
# File 'lib/scruffy/themes.rb', line 24

def font_family
  @font_family
end

#legend_font_sizeObject

Legend Font Size:



27
28
29
# File 'lib/scruffy/themes.rb', line 27

def legend_font_size
  @legend_font_size
end

#markerObject

Marker color for grid lines, values, etc.



23
24
25
# File 'lib/scruffy/themes.rb', line 23

def marker
  @marker
end

#marker_font_sizeObject

Marker Font Size:



25
26
27
# File 'lib/scruffy/themes.rb', line 25

def marker_font_size
  @marker_font_size
end

#outlinesObject

Array of colors for outlines of elements for data graphs



22
23
24
# File 'lib/scruffy/themes.rb', line 22

def outlines
  @outlines
end

#title_font_sizeObject

Title Font Size:



26
27
28
# File 'lib/scruffy/themes.rb', line 26

def title_font_size
  @title_font_size
end

Instance Method Details

#darken(color, shift = 20) ⇒ Object

todo: Implement darken function.



69
# File 'lib/scruffy/themes.rb', line 69

def darken(color, shift=20); end

#lighten(color, shift = 20) ⇒ Object

todo: Implement lighten function.



72
# File 'lib/scruffy/themes.rb', line 72

def lighten(color, shift=20); end

#next_colorObject

Returns the next available color in the color array.



50
51
52
53
54
55
# File 'lib/scruffy/themes.rb', line 50

def next_color
  @previous_color = 0 if @previous_color.nil?
  @previous_color += 1
          
  self.colors[(@previous_color-1) % self.colors.size]
end

#next_outlineObject

Returns the next available outline in the outline array.



59
60
61
62
63
64
65
66
# File 'lib/scruffy/themes.rb', line 59

def next_outline
  @previous_outline = 0 if @previous_outline.nil?
  @previous_outline += 1
  if self.outlines.nil?
    return "#000000"
  end
  self.outlines[(@previous_outline-1) % self.outlines.size]
end