Class: RGhost::Border

Inherits:
PsObject show all
Defined in:
lib/rghost/border.rb

Overview

Border object render a border around of vector shapes. Its sketch can be a combination of color, dashes, line joins and line caps. Usually its use inside of object facades, such as, Document, CallbackFacade and PsFacade as parameter :border, for example:

d=Document.new
d.horizontal_line :middle, :border => { :color => '#058412', :dash => [1,0,2] }

You can use it as a new instance of Border and set inside of Document by method set, example:

d=Document.new
b=Border.new :color => '#058412', :dash => [1,0,2]
d.set b
d.lineto :x => 2.5, :y => 5

Options

  • :color - Facade to Color using the same parameter.

  • :dash - Facade to Dash using the same parameter.

  • :width - Facade to LineWidth using the same parameter.

  • :linejoin - Sets the line join parameter in the graphics state to int, which must be one of the integers 0, 1, or 2.

:linejoin examples

  • Miter join :linejoin => 0

  • Round join :linejoin => 1

  • Bevel join :linejoin => 2

  • :linecap - Sets the line cap parameter in the graphics state to int, which must be one of the integers 0, 1, or 2

:linecap examples

  • Butt cap :linecap => 0

  • Round cap :linecap => 1

  • Projecting square cap :linecap => 2

Constant Summary collapse

DEFAULT_OPTIONS =
{:color => '#49AAFA', :dash => false, :width => 0.5, :linejoin => 0, :linecap => 0  }

Instance Method Summary collapse

Methods inherited from PsObject

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

Constructor Details

#initialize(options = {}) ⇒ Border

Returns a new instance of Border.



28
29
30
31
# File 'lib/rghost/border.rb', line 28

def initialize(options={})
  super(""){}
  @options = DEFAULT_OPTIONS.dup.merge(options)
end

Instance Method Details

#psObject

:nodoc:



33
34
35
36
37
38
39
40
41
# File 'lib/rghost/border.rb', line 33

def ps #:nodoc:
  p=RGhost::PsObject.new
  p.set RGhost::LineWidth.new(@options[:width]) if @options[:width]
  p.raw "#{@options[:linejoin]} setlinejoin"
  p.raw "#{@options[:linecap]} setlinecap"
  p.set RGhost::Dash.new(@options[:dash])       if @options[:dash]
  p.set RGhost::Color.create(@options[:color])  if @options[:color]
  p
end