-
Notifications
You must be signed in to change notification settings - Fork 46
Object Orientation and Position
There are two ways that you can work; the relative position with automatic cursor and absolute position passing the coordinate x,y to object or specifying in the body of the document.
Jump to the next row. It‘s the same as jump_rows(1).
doc=RGhost::Document.new
doc.show "Row 1"
doc.next_row
doc.show "Row 2"
doc.next_row
doc.show "Row 3"
Executes show and the method next_row. The result of the code below is the same as above.
doc=RGhost::Document.new
doc.show "Row 1"
doc.show_next_row “Row 2”
doc.show_next_row “Row 3”
The class method goto positions the cursor based on page row number. Example:
d=Document.new
d.goto_row 15
d.show "You're on row 15"
d.goto_row 3
d.show "Now you're on row 3"
Or without facade
d=RGhost::Document.new
d.set Cursor.goto_row(15)
d.set Show.new(" You're on row 15")
d.set Cursor.goto_row(3)
d.set Show.new("Now you're on row 3")
Jumps n rows relative to the current row
d=RGhost::Document.new
d.jump_rows 4 # jump four rows below
d.jump_rows -5 # go back up five rows
Moves cursor to absolute point relative to default source point x=0 and y=0 of the page. It doesn’t interfere with the row positions.
doc=RGhost::Document.new
doc.moveto :x=> 10, :y=> 5
doc.show "Hello Girls!!!"
It works the same way as moveto; the only difference is that it’s relative to the current point.
doc=RGhost::Document.new
doc.moveto :x=> 10, :y=> 5
doc.show "Hello Girls!!!"
doc.rmoveto :x => 5 # move to x=> 15 (10 plus 5) maintaining y => 5
It changes the default point to a new point(dislocate)
doc=RGhost::Document.new
doc.translate :x=> 2, :y=> 1
#the translate method dislocates to :x=> 2, :y=> 1, so the moveto(0,0) will refer to the same point (2,1).
doc.moveto :x => 0,:y => 0
doc.translate :x=> -2, :y=> -1 # returns to default source point
Rotates all objects after executing them, passing the angle as argument.
d=RGhost::Document.new
d.rotate 90
#do something
d.rotate -90 # goes back to source angle
Using it inside newpath block
d=RGhost::Document.new
d.newpath do |n|
n.moveto :x => 5, :y => 5
n.rotate 90
n.show 'Foo'
end
Using it inside graphic block
d=RGhost::Document.new
d.graphic do |g|
g.moveto :x => 5, :y => 5
g.rotate 90
g.show 'Foo'
end