Class: Resedit::ColorMap

Inherits:
Object
  • Object
show all
Defined in:
lib/resedit/convert/colors.rb

Instance Method Summary collapse

Constructor Details

#initialize(from, to) ⇒ ColorMap

Returns a new instance of ColorMap.



51
52
53
54
# File 'lib/resedit/convert/colors.rb', line 51

def initialize(from, to)
    @from = Color.new(from)
    @to = Color.new(to)
end

Instance Method Details

#gradient(steps) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/resedit/convert/colors.rb', line 56

def gradient(steps)
    map = [@from.to_i]
    c = steps
    for i in 1..steps-2
        v = 1.0 * i / c
        map << (@from*(1.0-v) + @to*v).to_i
    end
    map << @to.to_i
    #puts map
    return map
end

#mapBpp(bpp) ⇒ Object



68
69
70
# File 'lib/resedit/convert/colors.rb', line 68

def mapBpp(bpp)
    return gradient(1<<bpp)
end