Class: RGhost::Line

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

Overview

Creates straight lines

Constant Summary collapse

DEFAULT_POINT =
{:x => :limit_left , :y => :current_row}

Class Method Summary collapse

Methods inherited from PsObject

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

Constructor Details

This class inherits a constructor from RGhost::PsObject

Class Method Details

.lineto(point = {}) ⇒ Object

Draw line the one pont until another, the first point is creates by moveto and de last point using the method lineto.

Examples

doc=Document.new doc.moveto :x => 2, :y => 3 doc.lineto :x => 5, :y => 2

doc=Document.new doc.moveto :x => 2, :y => 3 doc.lineto :x => 4, :y => 4

doc=Document.new doc.border :color => '#AAFA49', :width => 4 doc.moveto :x => 2, :y => 3 doc.lineto :x => 4, :y => 1

doc=Document.new doc.border :color => '#49AAFA', :width => 1 doc.moveto :x => 2, :y => 3 doc.lineto :x => 4, :y => 1 doc.moveto :x => 2, :y => 3 doc.lineto :x => 2, :y => 1

Using graphic state to close path shape

doc=Document.new doc.graphic do

doc.border :color => '#49AAFA', :width => 1
doc.moveto :x => 2, :y => 3
doc.lineto :x => 4, :y => 1 
doc.lineto :x => 2, :y => 1 
doc.shape_content :color => "#F0FFFF"
doc.closepath

end


51
52
53
54
55
# File 'lib/rghost/line.rb', line 51

def self.lineto(point={})

  RGhost::Line.make_command(:lineto,point)

end

.rlineto(point = {}) ⇒ Object

(Relative lineto) Draw straingh line in the same manner as lineto, but from current point to distance for next :x and :y. That is, rlineto constructs a line from (x, y) to (x + dx, y + dy) and makes (x + dx, y + dy) the new current point.

Examples

doc=Document.new doc.moveto :x => 2, :y => 1 doc.rlineto :x => 3, :y => 2

doc=Document.new doc.moveto :x => 2, :y => 1 doc.rlineto :x => 3, :y => 2 doc.rlineto :x => 0, :y => -2


70
71
72
73
# File 'lib/rghost/line.rb', line 70

def self.rlineto(point={})
  line=RGhost::Line.make_command(:rlineto,point)

end