Class: RGhost::CMYKSpot

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

Overview

Creates CMYK Spot color space

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 = {:name => 'spot', :cyan=> 1 ,:magenta => 0, :yellow => 0, :black => 0}) ⇒ CMYKSpot

Returns a new instance of CMYKSpot.



148
149
150
151
152
# File 'lib/rghost/color.rb', line 148

def initialize(color={:name => 'spot', :cyan=> 1 ,:magenta => 0, :yellow => 0, :black => 0})
  @name = color[:name]
  color.delete(:name)
  @color = color
end

Instance Attribute Details

#blackObject

Returns the value of attribute black.



146
147
148
# File 'lib/rghost/color.rb', line 146

def black
  @black
end

#cyanObject

Returns the value of attribute cyan.



146
147
148
# File 'lib/rghost/color.rb', line 146

def cyan
  @cyan
end

#magentaObject

Returns the value of attribute magenta.



146
147
148
# File 'lib/rghost/color.rb', line 146

def magenta
  @magenta
end

#nameObject

Returns the value of attribute name.



146
147
148
# File 'lib/rghost/color.rb', line 146

def name
  @name
end

#yellowObject

Returns the value of attribute yellow.



146
147
148
# File 'lib/rghost/color.rb', line 146

def yellow
  @yellow
end

Instance Method Details

#psObject



154
155
156
157
158
159
160
161
162
163
# File 'lib/rghost/color.rb', line 154

def ps
  value=case @color
    when Hash
      [@color[:cyan] || @color[:c],@color[:magenta] || @color[:m],@color[:yellow] || @color[:y],@color[:black] || @color[:k]]
    when Array
      @color
  end
  
  array_to_stack(value.map{|n| n > 1 ? n/100.0: n}) + "(#{@name.to_s}) findcmykcustomcolor \n/#{@name.to_s.gsub(' ', '_')} exch def\n\n#{@name.to_s.gsub(' ', '_')} 1 setcustomcolor"
end