Sha256: 954d837e3fcfe2127211cd58ccdbadbaf62a3a5afaca391c2f78c8e400011e58

Contents?: true

Size: 886 Bytes

Versions: 1

Compression:

Stored size: 886 Bytes

Contents

# frozen_string_literal: true

require "forwardable"

module TNS
  module Color
    # A variant of a color, which could be either a tint or a shade.
    class Variant < Base
      extend Forwardable

      attr_reader :color, :step

      def_delegators :@color, :to_css, :to_s

      def initialize(color, step)
        @color = color
        @step = step
        super()
      end

      # Change the internal color representation to Hex
      def to_hex
        @color = @color.to_hex
        self
      end

      # Change the internal color representation to HSL
      def to_hsl
        @color = @color.to_hsl
        self
      end

      # Return the step relative to base color. Step 0 has in index of 5,
      # tints and shades have indices relative to that.
      def index
        raise NotImplementedError("Implement this for shades or tints")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tints-n-shades-0.1.0 lib/tns/color/variant.rb