Class: PaletteTown::Scheme
- Inherits:
-
Object
- Object
- PaletteTown::Scheme
- Defined in:
- lib/palettetown/scheme.rb
Class Method Summary collapse
- .author(author = nil) ⇒ Object
- .darker(color, amount) ⇒ Object
- .desaturate(color, amount) ⇒ Object
- .description(description = nil) ⇒ Object
- .hi(*options) ⇒ Object
- .lighter(color, amount) ⇒ Object
- .name(name = nil) ⇒ Object
- .saturate(color, amount) ⇒ Object
- .spin(color, amount) ⇒ Object
- .to_s ⇒ Object
Class Method Details
.author(author = nil) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/palettetown/scheme.rb', line 11 def =nil if .nil? else = end end |
.darker(color, amount) ⇒ Object
30 31 32 33 34 |
# File 'lib/palettetown/scheme.rb', line 30 def darker color, amount color = PaletteTown::Color.new color unless color.is_a? PaletteTown::Color color.lum -= amount / 100.0 color end |
.desaturate(color, amount) ⇒ Object
40 41 42 43 |
# File 'lib/palettetown/scheme.rb', line 40 def desaturate color, amount color = PaletteTown::Color.new color unless color.is_a? PaletteTown::Color color.sat -= amount / 100.0 end |
.description(description = nil) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/palettetown/scheme.rb', line 18 def description description=nil if description.nil? @description else @description = description end end |
.hi(*options) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/palettetown/scheme.rb', line 49 def hi * return @rules if .length == 0 @rules ||= {} rule = .shift if [0].is_a? Hash = [0] else = { :fg => [0], :bg => [1] } end @rules[rule] = PaletteTown::Rule.new() end |
.lighter(color, amount) ⇒ Object
25 26 27 28 29 |
# File 'lib/palettetown/scheme.rb', line 25 def lighter color, amount color = PaletteTown::Color.new color unless color.is_a? PaletteTown::Color color.lum += amount / 100.0 color end |
.name(name = nil) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/palettetown/scheme.rb', line 4 def name name=nil if name.nil? @name else @name = name end end |
.saturate(color, amount) ⇒ Object
35 36 37 38 39 |
# File 'lib/palettetown/scheme.rb', line 35 def saturate color, amount color = PaletteTown::Color.new color unless color.is_a? PaletteTown::Color color.sat += amount / 100.0 color end |
.spin(color, amount) ⇒ Object
44 45 46 47 48 |
# File 'lib/palettetown/scheme.rb', line 44 def spin color, amount color = PaletteTown::Color.new color unless color.is_a? PaletteTown::Color color.hue += amount / 360.0 color end |
.to_s ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/palettetown/scheme.rb', line 64 def to_s out = "\" Vim color file\n\" Generated by PaletteTown\n\" http://nuckchorris.github.io/palettetown/\n\"\n\" Name: \#{name}\n\" Author: \#{author}\n\" Notes: \#{description}\n\nhi clear\nif version > 580\n if exists(\"syntax_on\")\n syntax reset\n endif\nendif\n\nlet colors_name=\"\#{name}\"\n\n" if @rules[:Normal] out << "if has(\"gui_running\")\n set background=\#{if @rules[:Normal][:guibg].lum < 0.5 then \"dark\" else \"light\" end}\nendif\n\n" @rules[:Normal][:guibg].lum < 0.5 else warn "No Normal hilight found; can't guess background" end @rules.each do |rule, opts| out << "hi #{rule}" opts.each do |key, val| out << " #{key}=#{val}" unless val.nil? end out << "\n" end out end |