Class: RGhost::RectangleLink

Inherits:
PsObject show all
Includes:
RubyToPs
Defined in:
lib/rghost/rectangle_link.rb

Overview

Creates one rectangle or one shape with rounded corners.

Options

  • :x and :y - Coordinates to position.

  • :corners - Value for rounded corners. Use 0 to straight angle.

  • :width and :height - Size of frame

  • :content - facade to ShapeContent with same parameters.

  • :border - facade to Border with same parameters.

Examples using facade frame method inside of Document

d=Document.new
d.frame :x => 3, :width => 7, :height => 5, :content => {:fill => false}

d=Document.new
d.frame :x => 3, :width => 7, :height => 5, :content => {:color => '#35F6A3' }

d=Document.new
d.frame :x => 3, :width => 7, :height => 5, :content => {:color => '#35F6A3' }, :border =>{:width => 5, :dash => [1,3,10]}

d=Document.new
d.frame :x => 3, :width => 7, :height => 5, :content => {:color => '#35F6A3' }, :corners => 20

d=Document.new
d.frame :x => 3, :width => 7, :height => 5, :content => {:color => :yellow }, :border => {:color => :red, :width => 4}, :corners => 20

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :x => :limit_left,
  :y => :current_row,
  :width => 5,
  :height => 3.5,
  :url => "http://rghost.rubyforge.org",
  :border_color => RGhost::Border::DEFAULT_OPTIONS[:color]
  
  
}

Instance Method Summary collapse

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(options = {}) ⇒ RectangleLink

Returns a new instance of RectangleLink.



45
46
47
48
49
# File 'lib/rghost/rectangle_link.rb', line 45

def initialize(options={})

  @options = DEFAULT_OPTIONS.dup.merge(options)

end

Instance Method Details

#psObject



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rghost/rectangle_link.rb', line 52

def ps
  x=RGhost::Units::parse(@options[:x])
  y=RGhost::Units::parse(@options[:y])
  
  h=RGhost::Units::parse(@options[:height])
  w=RGhost::Units::parse(@options[:width])
  url=@options[:url]
  scolor=RGhost::Color.create(@options[:border_color]).ps.gsub(/setrgbcolor/,'')
"/:rect_color [#{scolor}] def /:rect_x #{x} def /:rect_y #{y} def /:rect_w #{w} def /:rect_h #{h} def /:rect_uri #{to_string(url)} def :rect_link"
  
  
end