Class: RGhost::Frame
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, :corners => 1, :content => RGhost::ShapeContent::DEFAULT_OPTIONS, :border => RGhost::Border::DEFAULT_OPTIONS }
- BACKGROUND_ROW_DEFAULT_OPTIONS =
{:start_in => :limit_left, :size => :area_x, :color => RGhost::ShapeContent::DEFAULT_OPTIONS[:color]}
Class Method Summary collapse
-
.background_row(options = BACKGROUND_ROW_DEFAULT_OPTIONS) ⇒ Object
Creates background of the row for current row.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Frame
constructor
A new instance of Frame.
- #ps ⇒ Object
Methods inherited from PsObject
#<<, #call, #graphic_scope, #raw, #set, #to_s
Constructor Details
#initialize(options = {}) ⇒ Frame
Returns a new instance of Frame.
46 47 48 49 50 |
# File 'lib/rghost/frame.rb', line 46 def initialize(={}) @options = DEFAULT_OPTIONS.dup.merge() end |
Class Method Details
.background_row(options = BACKGROUND_ROW_DEFAULT_OPTIONS) ⇒ Object
Creates background of the row for current row. Example Here’s fill the current row using width :area_x, height :row_height, and starting in :limit_left. doc.background_row :color => ‘#35F6A3’
Specifies size and where will start of background doc.background_row :start_in => 2, :size => 5.5, :color => 0.8
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/rghost/frame.rb', line 91 def self.background_row(=BACKGROUND_ROW_DEFAULT_OPTIONS) #opts=BACKGROUND_ROW_DEFAULT_OPTIONS.merge(options) #start_in,size=Units::parse(opts[:start_in]),Units::parse(opts[:size]) #return RGhost::PsObject.new("#{start_in} #{size} {#{opts[:color]}} background_row ") =RGhost::Frame::BACKGROUND_ROW_DEFAULT_OPTIONS.merge() g=RGhost::Graphic.new g.set RGhost::Units::parse([:start_in]) g.set RGhost::Units::parse([:size]) g.set RGhost::Color.create([:color]) if [:color] g.raw :background_row g end |
Instance Method Details
#ps ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rghost/frame.rb', line 53 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]) inside=RGhost::ShapeContent.new(@options[:content]) if @options[:content] border=RGhost::Border.new(@options[:border]) if @options[:border] params=%Q{ /rcorners_params{ /:x #{x} def /:y #{y} def /:w #{w} def /:h #{h} def /:r #{@options[:corners]} def /:s 1 def /:inside{ #{inside.ps if inside } } def /:outside{ #{border.ps if border} }def } def } "#{params} rcorners_params rcorners" end |