class Scruffy::Themes::Base

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.

Attributes

background[RW]
colors[RW]
font_family[RW]
grid[RW]
legend_font_size[RW]
marker[RW]
marker_font_size[RW]
outlines[RW]
title_font_size[RW]

Public Class Methods

new(descriptor) click to toggle source

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.

# File lib/scruffy/themes.rb, line 39
def initialize(descriptor)
  self.background = descriptor[:background]
  self.colors     = descriptor[:colors]
  self.outlines     = descriptor[:outlines]
  self.grid     = descriptor[:grid]
  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

Public Instance Methods

darken(color, shift=20) click to toggle source

todo: Implement darken function.

# File lib/scruffy/themes.rb, line 71
def darken(color, shift=20); end
lighten(color, shift=20) click to toggle source

todo: Implement lighten function.

# File lib/scruffy/themes.rb, line 74
def lighten(color, shift=20); end
next_color() click to toggle source

Returns the next available color in the color array.

# File lib/scruffy/themes.rb, line 52
def next_color
  @previous_color = 0 if @previous_color.nil?
  @previous_color += 1
          
  self.colors[(@previous_color-1) % self.colors.size]
end
next_outline() click to toggle source

Returns the next available outline in the outline array.

# File lib/scruffy/themes.rb, line 61
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