Class: RGhost::CMYK

Inherits:
Color show all
Defined in:
lib/rghost/color.rb

Overview

Creates CMYK color space

Constant Summary collapse

CONSTANTS =
RGhost::Constants::Colors::CMYK

Constants included from RubyToPs

RubyToPs::UTF8_ENCODINGS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Color

create

Methods included from RubyToPs

#array_to_stack, #hash_to_array, #pack_string, #ps_escape, #string_eval, #to_array, #to_bool, #to_string, #to_string_array

Methods inherited from PsObject

#<<, #call, #graphic_scope, #raw, #set, #to_s

Constructor Details

#initialize(color = {:cyan=> 1 ,:magenta => 0, :yellow => 0, :black => 0}) ⇒ CMYK

Hash with 4 pair of key/value. Valids keys :cyan, :magenta, :yellow and :black

Color.create :cyan=> 1 ,:magenta => 0.3, :yellow => 0, :black => 0

Hash with 4 pair of key/value. Valids keys :c, :m, :y and :b

Color.create :c=> 1 ,:m => 0.3, :y => 0, :b => 0


121
122
123
# File 'lib/rghost/color.rb', line 121

def initialize(color={:cyan=> 1 ,:magenta => 0, :yellow => 0, :black => 0})
  @color=color
end

Instance Attribute Details

#blackObject

Returns the value of attribute black.



114
115
116
# File 'lib/rghost/color.rb', line 114

def black
  @black
end

#cyanObject

Returns the value of attribute cyan.



114
115
116
# File 'lib/rghost/color.rb', line 114

def cyan
  @cyan
end

#magentaObject

Returns the value of attribute magenta.



114
115
116
# File 'lib/rghost/color.rb', line 114

def magenta
  @magenta
end

#yellowObject

Returns the value of attribute yellow.



114
115
116
# File 'lib/rghost/color.rb', line 114

def yellow
  @yellow
end

Instance Method Details

#psObject



125
126
127
128
129
130
131
# File 'lib/rghost/color.rb', line 125

def ps
  value=case @color
    when Hash then  [@color[:c] || @color[:cyan],@color[:m] || @color[:magenta] ,@color[:y] || @color[:yellow], @color[:k] || @color[:black]]
    when Array then  @color
  end
  array_to_stack(value.map{|n| n > 1 ? n/100.0: n})+"setcmykcolor"
end