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, 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.



34
35
36
37
38
39
# File 'lib/scruffy/themes.rb', line 34

def initialize(descriptor)
  self.background = descriptor[:background]
  self.colors     = descriptor[:colors]
  self.marker     = descriptor[:marker]
  self.font_family = descriptor[:font_family]
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.



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

def font_family
  @font_family
end

#markerObject

Marker color for grid lines, values, etc.



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

def marker
  @marker
end

Instance Method Details

#darken(color, shift = 20) ⇒ Object

todo: Implement darken function.



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

def darken(color, shift=20); end

#lighten(color, shift = 20) ⇒ Object

todo: Implement lighten function.



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

def lighten(color, shift=20); end

#next_colorObject

Returns the next available color in the color array.



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

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