Class: Sassafras::Theme

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base) ⇒ Theme

Returns a new instance of Theme.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/sassafras.rb', line 68

def initialize(base)
  is_hex = (base =~ /#.*/)
  @base_rgb   = is_hex ? Color::RGB.from_html(base) : Color::RGB.const_get(base.to_s.camelize)
  @colors     = { 'base' => 
    Tints.new(@base_rgb).colors.merge(
    Shades.new(@base_rgb).colors)
  }
			#@monochrome = { 'base' => 
  #  Tints.new(@base_rgb).colors.merge(
  #  Shades.new(@base_rgb).colors)
  #}
  return unless self.class.colors
  self.class.colors.each do |name, steps|
    color      = self.hue_adjusted_base_rgb(steps)
#monochrome = self.monochrome_adjusted_base_rgb(steps) 
    @colors[name] = 
      Tints.new(color).colors.merge(
      Shades.new(color).colors)
#@monochrome[name] =
#	Tints.new(monochrome).colors.merge(
#	Shades.new(monochrome).colors)
  end
end

Instance Attribute Details

#base_rgbObject (readonly)

Returns the value of attribute base_rgb.



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

def base_rgb
  @base_rgb
end

Class Method Details

.analogous(base) ⇒ Object



39
40
41
# File 'lib/sassafras.rb', line 39

def analogous(base)
  AnalogousTheme.new(base)
end

.basic(base) ⇒ Object



31
32
33
# File 'lib/sassafras.rb', line 31

def basic(base)
  BasicTheme.new(base)
end

.colorsObject



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

def colors
  @colors
end

.complementary(base) ⇒ Object



35
36
37
# File 'lib/sassafras.rb', line 35

def complementary(base)
  ComplementaryTheme.new(base)
end

.complete(base) ⇒ Object



59
60
61
# File 'lib/sassafras.rb', line 59

def complete(base)
	CompleteTheme.new(base)
end

.create(type, base) ⇒ Object



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

def create(type, base)
  Theme.send(type, base)
end

.rectangle(base) ⇒ Object



51
52
53
# File 'lib/sassafras.rb', line 51

def rectangle(base)
  RectangleTheme.new(base)
end

.split_complementary(base) ⇒ Object



47
48
49
# File 'lib/sassafras.rb', line 47

def split_complementary(base)
  SplitComplementaryTheme.new(base)
end

.square(base) ⇒ Object



55
56
57
# File 'lib/sassafras.rb', line 55

def square(base)
  SquareTheme.new(base)
end

.triadic(base) ⇒ Object



43
44
45
# File 'lib/sassafras.rb', line 43

def triadic(base)
  TriadicTheme.new(base)
end

Instance Method Details

#baseObject



92
93
94
# File 'lib/sassafras.rb', line 92

def base 
  @base_rgb.html
end

#colors(name = nil) ⇒ Object



96
97
98
99
# File 'lib/sassafras.rb', line 96

def colors(name=nil)
  return @colors[name.to_s] if name
  @colors
end

#get_bindingObject



113
# File 'lib/sassafras.rb', line 113

def get_binding; binding; end

#sassObject



101
102
103
104
105
106
107
108
109
110
111
# File 'lib/sassafras.rb', line 101

def sass
  returning "# Generated by Sassafras\n" do |str|
    colors.each do |set, colors|
      str << "# #{set}\n"
      colors.each do |name, hex|
        str << "!#{set}_#{name} = #{hex}\n"
      end
      str << "\n"
    end
  end
end