Sha256: 52b2942302a4462e16ea221ea74ac867c306b541cd861e33b151cb3efde4b88e

Contents?: true

Size: 584 Bytes

Versions: 1

Compression:

Stored size: 584 Bytes

Contents

require_relative '../color'

class ASE
  class Color
    class Gray
      attr_accessor :value

      def initialize(value=0)
        @value = value
      end

      def read!(file)
        @value = file.read(4).unpack('g')[0].round(4)
      end

      def write!(file)
        file.write('Gray')
        to_a.each { |c| file.write [c].pack('g') }
      end

      def to_rgb
        RGB.new(*([rgb_value] * 3))
      end

      def to_a
        [@value]
      end

      private

      def rgb_value
        (@value * 255).to_i
      end
    end

    class Grey < Gray; end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ase-2.0.0 lib/ase/color_modes/gray.rb