Sha256: e5aef00e78ef7de0558071722f2a51f9b92d50157f7b694a442206248b15e5c3
Contents?: true
Size: 785 Bytes
Versions: 1
Compression:
Stored size: 785 Bytes
Contents
require 'ws_light/set/color_set' module WSLight module Set # Creates a gradient from one color to another class GradientSet < ColorSet attr_accessor :color_from, :color_to def init @color_from = Color.new(0, 0, 0) @color_to = Color.new(255, 255, 255) end def frame @set ||= create_frame end def create_frame set = [] @length.times do |i| set << pixel(i) end set += set.reverse if type == :double # this should be faster than generating the pixel one after another set end def pixel(number) number = @full_length - 1 - number if number >= @length @color_from.mix(@color_to, number.to_f / (@length - 1)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ws_light-0.4.2 | lib/ws_light/set/gradient_set.rb |