Sha256: 7ad8286e3cd2312afdd3b7d06fb70f1341a1489e6e82d8dc3d0e7061fe50c9da

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

# gradients.rb: objects dealing with (color) gradients
# copyright (c) 2009 by Vincent Fourmond
  
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
  
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details (in the COPYING file).

require 'ctioga2/utils'
require 'ctioga2/log'

require 'ctioga2/graphics/coordinates'

# This module contains all the classes used by ctioga
module CTioga2

  Version::register_svn_info('$Revision$', '$Date$')

  module Graphics

    module Styles

      
      # A color gradient with two points
      #
      # \todo There could be many more
      #
      # @todo This will have to be replaced by a real color map based
      # on what
      class TwoPointGradient < BasicStyle

        include Log
        
        # The starting color (for x = 0)
        attr_accessor :start

        # The ending color (for x = 1)
        attr_accessor :end

        def initialize(s,e)
          warn { "This class shouldn't be used anymore at #{caller.inspect}" }
          @start = s
          @end = e
        end

        # Returns the color for the given value of _x_ (between 0 and 1)
        def color(x)
          return Utils::mix_objects(@end,@start, x)
        end
        
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ctioga2-0.3 lib/ctioga2/graphics/styles/gradients.rb