Border
shairontoledo edited this page Sep 13, 2010
·
3 revisions
Border object renders a border around vector shapes. Its sketch can be a combination of color, dashes, line joints and line caps. Usually it’s used inside object facades, such as Document, CallbackFacade and PsFacade as parameter :border, for example:
d=RGhost::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 it inside Document by method set, example:
d=RGhost::Document.new
b=RGhost::Border.new :color => '#058412', :dash => [1,0,2]
d.set b
d.lineto :x => 2.5, :y => 5
Options
- :color – Facade to Color class using the same parameters.
- :dash – Facade to Dash class using the same parameters.
- :width – Facade to LineWidth class 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.
Miter join
:linejoin => 0
Round join
:linejoin => 1
Bevel join
:linejoin => 2
h3. :linecap examples
:linecap - Sets the line cap parameter in the graphics state to int, which must be one of the integers 0, 1, or 2
Butt cap
:linecap => 0
Round cap
:linecap => 1
Projecting square cap
:linecap => 2
Sets the dash pattern on border lines. It reads one array all of which must be non-negative numbers and not all zero. It behaves this way
[2,1] #=> 2 turn on and 1 off, 2 turn on and 1 off …
[3,1,2,5] #=> 3 on, 1 off, 2 on, 5 off … repeating until end
Examples using dash as border parameter
d=RGhost::Document.new
d.horizontal_line(:bottom, :border=>{:dash => 1, :width => 2 })
d=RGhost::Document.new
d.horizontal_line(:bottom, :border=>{:dash => [1,1], :width => 2 })
d=RGhost::Document.new
d.horizontal_line(:bottom, :border=>{:dash => [1,2,1], :width => 2 })
d=RGhost::Document.new
d.horizontal_line(:bottom, :border=>{:dash => [2,10,5], :width => 2 })
d=RGhost::Document.new
d.horizontal_line(:bottom, :border=>{:dash => [1,1,3,1,5,1,7,1,9,1,10], :width => 4 })