rghost-ruby1.9-beta 0.8.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rghost.rb +18 -0
- data/lib/rghost/border.rb +44 -0
- data/lib/rghost/callback.rb +58 -0
- data/lib/rghost/circle.rb +102 -0
- data/lib/rghost/color.rb +175 -0
- data/lib/rghost/constants.rb +626 -0
- data/lib/rghost/convert.rb +43 -0
- data/lib/rghost/cursor.rb +124 -0
- data/lib/rghost/dash.rb +59 -0
- data/lib/rghost/document.rb +546 -0
- data/lib/rghost/document_callback_facade.rb +64 -0
- data/lib/rghost/dsc_entry.rb +20 -0
- data/lib/rghost/dynamic_document_callback.rb +15 -0
- data/lib/rghost/eps.rb +31 -0
- data/lib/rghost/font.rb +48 -0
- data/lib/rghost/font_map.rb +54 -0
- data/lib/rghost/frame.rb +105 -0
- data/lib/rghost/function.rb +38 -0
- data/lib/rghost/gif.rb +41 -0
- data/lib/rghost/graphic.rb +26 -0
- data/lib/rghost/grid/base_grid.rb +228 -0
- data/lib/rghost/grid/callback_facade.rb +136 -0
- data/lib/rghost/grid/csv_grid.rb +51 -0
- data/lib/rghost/grid/dynamic_callback.rb +12 -0
- data/lib/rghost/grid/field_format.rb +43 -0
- data/lib/rghost/grid/grid.rb +15 -0
- data/lib/rghost/grid/header.rb +120 -0
- data/lib/rghost/grid/matrix.rb +10 -0
- data/lib/rghost/grid/rails_grid.rb +74 -0
- data/lib/rghost/grid/static_callback.rb +13 -0
- data/lib/rghost/grid/style/border_lines.rb +44 -0
- data/lib/rghost/grid/style/bottom_lines.rb +28 -0
- data/lib/rghost/grid/style/old_forms.rb +28 -0
- data/lib/rghost/grid/style/style.rb +8 -0
- data/lib/rghost/gs_alone.rb +25 -0
- data/lib/rghost/helpers.rb +13 -0
- data/lib/rghost/horizontal_line.rb +45 -0
- data/lib/rghost/how_to.rb +75 -0
- data/lib/rghost/image.rb +26 -0
- data/lib/rghost/jpeg.rb +39 -0
- data/lib/rghost/line.rb +89 -0
- data/lib/rghost/line_width.rb +28 -0
- data/lib/rghost/load.rb +43 -0
- data/lib/rghost/newpath.rb +19 -0
- data/lib/rghost/paper.rb +147 -0
- data/lib/rghost/parse_text.rb +53 -0
- data/lib/rghost/pdf_security.rb +36 -0
- data/lib/rghost/point.rb +23 -0
- data/lib/rghost/point_with_command.rb +17 -0
- data/lib/rghost/polygon.rb +75 -0
- data/lib/rghost/ps/AdobeExpert.enc +258 -0
- data/lib/rghost/ps/AdobeLatinEncoding.enc +258 -0
- data/lib/rghost/ps/Bengali.enc +386 -0
- data/lib/rghost/ps/CodePage1250.enc +258 -0
- data/lib/rghost/ps/CodePage1251.enc +258 -0
- data/lib/rghost/ps/CodePage1252.enc +258 -0
- data/lib/rghost/ps/CodePage1253.enc +258 -0
- data/lib/rghost/ps/CodePage1254.enc +258 -0
- data/lib/rghost/ps/CodePage1256.enc +258 -0
- data/lib/rghost/ps/CodePage1257.enc +258 -0
- data/lib/rghost/ps/CodePage1258.enc +258 -0
- data/lib/rghost/ps/CodePage874.enc +258 -0
- data/lib/rghost/ps/Fontmap +5 -0
- data/lib/rghost/ps/IsoLatin.enc +352 -0
- data/lib/rghost/ps/MacCentralEuropean.enc +258 -0
- data/lib/rghost/ps/MacCyrillice.desnc +258 -0
- data/lib/rghost/ps/MacGreek.enc +258 -0
- data/lib/rghost/ps/MacHebrew.enc +258 -0
- data/lib/rghost/ps/TeX-CorkEncoding.enc +258 -0
- data/lib/rghost/ps/TeX-LGR-Greek.enc +258 -0
- data/lib/rghost/ps/TeX-T2AModified2Encoding.enc +258 -0
- data/lib/rghost/ps/TeX-T2BAdobeEncoding.enc +258 -0
- data/lib/rghost/ps/TeX-T2CAdobeEncoding.enc +258 -0
- data/lib/rghost/ps/TeX-X2AdobeEncoding.enc +258 -0
- data/lib/rghost/ps/TeX-XL2encoding.enc +258 -0
- data/lib/rghost/ps/TeXMathExtensionEncoding.enc +258 -0
- data/lib/rghost/ps/TeXMathItalicEncoding.enc +258 -0
- data/lib/rghost/ps/TeXMathSymbolEncoding.enc +258 -0
- data/lib/rghost/ps/US-ASCII.enc +258 -0
- data/lib/rghost/ps/UTF-8.enc +3 -0
- data/lib/rghost/ps/_cusor.ps +46 -0
- data/lib/rghost/ps/basic.ps +25 -0
- data/lib/rghost/ps/begin_document.ps +8 -0
- data/lib/rghost/ps/callbacks.ps +175 -0
- data/lib/rghost/ps/code128.font +344 -0
- data/lib/rghost/ps/code39.font +195 -0
- data/lib/rghost/ps/cursor.ps +106 -0
- data/lib/rghost/ps/datagrid.ps +55 -0
- data/lib/rghost/ps/developer.ps +237 -0
- data/lib/rghost/ps/ean.font +150 -0
- data/lib/rghost/ps/eps.ps +42 -0
- data/lib/rghost/ps/font.ps +38 -0
- data/lib/rghost/ps/frame.ps +16 -0
- data/lib/rghost/ps/gif.ps +150 -0
- data/lib/rghost/ps/horizontal_line.ps +4 -0
- data/lib/rghost/ps/i25.font +103 -0
- data/lib/rghost/ps/jpeg.ps +122 -0
- data/lib/rghost/ps/link.ps +22 -0
- data/lib/rghost/ps/paper.ps +8 -0
- data/lib/rghost/ps/rect_link.ps +17 -0
- data/lib/rghost/ps/rectangle.ps +5 -0
- data/lib/rghost/ps/rghost_default_template.eps +1532 -0
- data/lib/rghost/ps/row.ps +4 -0
- data/lib/rghost/ps/show.ps +21 -0
- data/lib/rghost/ps/table_callbacks.ps +96 -0
- data/lib/rghost/ps/text.ps +63 -0
- data/lib/rghost/ps/textarea.ps +11 -0
- data/lib/rghost/ps/type.ps +1 -0
- data/lib/rghost/ps/unit.ps +3 -0
- data/lib/rghost/ps/vertical_line.ps +12 -0
- data/lib/rghost/ps/virtual_pages.ps +55 -0
- data/lib/rghost/ps_facade.rb +253 -0
- data/lib/rghost/ps_object.rb +55 -0
- data/lib/rghost/rectangle_link.rb +65 -0
- data/lib/rghost/rgengine.so +0 -0
- data/lib/rghost/ruby_ghost_config.rb +243 -0
- data/lib/rghost/ruby_ghost_engine.rb +156 -0
- data/lib/rghost/ruby_ghost_version.rb +8 -0
- data/lib/rghost/ruby_to_ps.rb +78 -0
- data/lib/rghost/scale.rb +29 -0
- data/lib/rghost/shape_content.rb +23 -0
- data/lib/rghost/show.rb +88 -0
- data/lib/rghost/static_document_callback.rb +18 -0
- data/lib/rghost/text.rb +44 -0
- data/lib/rghost/text_in.rb +51 -0
- data/lib/rghost/text_link_in.rb +42 -0
- data/lib/rghost/textarea.rb +88 -0
- data/lib/rghost/units.rb +82 -0
- data/lib/rghost/variable.rb +12 -0
- data/lib/rghost/vertical_line.rb +37 -0
- data/lib/rghost/virtual_pages.rb +42 -0
- metadata +185 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
#This module is included inside of Document class. It will creates methods to easy the use.
|
2
|
+
#===Callback execution order
|
3
|
+
#Example for a document with 4 pages, looking at the picture you can see the order in which the callbacks are executed
|
4
|
+
#
|
5
|
+
#link:images/pages_rghost.png
|
6
|
+
|
7
|
+
module RGhost::DocumentCallbackFacade
|
8
|
+
|
9
|
+
#Executes before page create. Respond to :only and :except options
|
10
|
+
def before_page_create(options={},&block)
|
11
|
+
new_dynamic_callback(:before_page_create,options,&block)
|
12
|
+
end
|
13
|
+
|
14
|
+
#Executes after page create. Respond to :only and :except options
|
15
|
+
def after_page_create(options={},&block)
|
16
|
+
new_dynamic_callback(:after_page_create,options,&block)
|
17
|
+
end
|
18
|
+
|
19
|
+
#Executes on odd pages create. Respond to :only and :except options
|
20
|
+
def odd_pages(options={},&block)
|
21
|
+
new_dynamic_callback(:odd_pages,options,&block)
|
22
|
+
end
|
23
|
+
|
24
|
+
#Executes on even pages create. Respond to :only and :except options
|
25
|
+
def even_pages(options={},&block)
|
26
|
+
new_dynamic_callback(:even_pages,options,&block)
|
27
|
+
end
|
28
|
+
|
29
|
+
#Executes one time before document create.
|
30
|
+
def before_document_create(&block)
|
31
|
+
new_static_callback(:before_document_create,&block)
|
32
|
+
end
|
33
|
+
|
34
|
+
#Executes one time on first page.
|
35
|
+
def first_page(&block)
|
36
|
+
new_static_callback(:first_page,&block)
|
37
|
+
end
|
38
|
+
#Executes one time on last page(end of document).
|
39
|
+
def last_page(&block)
|
40
|
+
new_static_callback(:last_page,&block)
|
41
|
+
end
|
42
|
+
|
43
|
+
#Executes before virtual page create. Respond to :only and :except options
|
44
|
+
def before_virtual_page_create(options={},&block)
|
45
|
+
new_dynamic_callback(:before_virtual_page_create,options,&block)
|
46
|
+
end
|
47
|
+
#Executes after virtual page create. Respond to :only and :except options
|
48
|
+
def after_virtual_page_create(options={},&block)
|
49
|
+
new_dynamic_callback(:after_virtual_page_create,options,&block)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def new_dynamic_callback(name,options={},&block)
|
55
|
+
@callbacks.set RGhost::Callback.new(name,options,&block)
|
56
|
+
end
|
57
|
+
def new_static_callback(name,&block)
|
58
|
+
|
59
|
+
callback_body= RGhost::PsFacade.new(&block)
|
60
|
+
@callbacks.set RGhost::Function.new(name,callback_body)
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "rghost/ps_object"
|
2
|
+
#Specifiesnew DSC (Document Structuring Conventions)
|
3
|
+
class RGhost::DSCEntry < RGhost::PsObject
|
4
|
+
#===Example
|
5
|
+
# DSCEntry.new do |entry|
|
6
|
+
# entry << "BoundingBox: 0 0 612 792"
|
7
|
+
# entry << "Pages: 45"
|
8
|
+
# entry << "BeginSetup"
|
9
|
+
# end
|
10
|
+
def initialize
|
11
|
+
|
12
|
+
yield @entries=[]
|
13
|
+
end
|
14
|
+
|
15
|
+
def ps
|
16
|
+
@entries.map{|e| "%%#{e}\n"}.to_s
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "rghost/callback"
|
2
|
+
|
3
|
+
class RGhost::DynamicDocumentCallback < RGhost::Callback #:nodoc:
|
4
|
+
ACCEPT=[:before_page_create,
|
5
|
+
:after_page_create,
|
6
|
+
:odd_pages,
|
7
|
+
:even_pages
|
8
|
+
]
|
9
|
+
|
10
|
+
def initialize(name,options={},&block)
|
11
|
+
raise NameError.new("#{name} no accept in #{self.class}") unless ACCEPT.include? name
|
12
|
+
super(name,options,&block)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/lib/rghost/eps.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "rghost/ps_object"
|
2
|
+
#Load new EPS file.
|
3
|
+
class RGhost::Eps < RGhost::PsObject
|
4
|
+
#===Examples
|
5
|
+
# doc=Document.new
|
6
|
+
# doc.set Eps.new "/local/templates/myform.eps", :x => 10, :y => 3
|
7
|
+
#Using Image.for facade
|
8
|
+
# doc.set Image.for "/local/templates/myform.eps", :x => 10, :y => 3
|
9
|
+
#Using PsFacade or Document
|
10
|
+
# doc.image "/local/templates/myform.eps", :x => 10, :y => 3
|
11
|
+
#===Options
|
12
|
+
#
|
13
|
+
#* <tt>:x and :y</tt> - Coordinates to position.
|
14
|
+
#* <tt>:rotate</tt> - Angle to image rotation if there is one.
|
15
|
+
def initialize(eps_path,options={:x=>0, :y=> 0, :rotate => 0})
|
16
|
+
super("")
|
17
|
+
@options=options
|
18
|
+
@path=eps_path
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def ps
|
23
|
+
|
24
|
+
"BeginEPSF \n #{RGhost::Cursor.translate(@options)} \n\t(#{@path}) run \nEndEPSF\n ";
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
end
|
data/lib/rghost/font.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require "rghost/ps_object"
|
2
|
+
require "rghost/constants"
|
3
|
+
require "rghost/helpers"
|
4
|
+
|
5
|
+
|
6
|
+
class RGhost::Font < RGhost::PsObject #:nodoc:
|
7
|
+
DEFAULT_OPTONS={ :size=> 8, :name => "Helvetica", :encoding => true }
|
8
|
+
include RGhost::Constants::Fonts
|
9
|
+
|
10
|
+
attr_reader :name
|
11
|
+
|
12
|
+
def initialize(options)
|
13
|
+
|
14
|
+
@options=DEFAULT_OPTONS.dup.merge(options)
|
15
|
+
@options.default ""
|
16
|
+
@options[:name]=@options[:font] if @options[:font]
|
17
|
+
@name=@options[:name].to_s
|
18
|
+
@name+="-encoding" if @options[:encoding]
|
19
|
+
end
|
20
|
+
|
21
|
+
def ps
|
22
|
+
o=@options
|
23
|
+
str_ret=""
|
24
|
+
# if o[:barcode]
|
25
|
+
# bc=RGhost::Barcode.new(o[:barcode])
|
26
|
+
# @name=bc.font_name
|
27
|
+
# o[:encoding]=false
|
28
|
+
# end
|
29
|
+
if o[:encoding] #define enconding
|
30
|
+
str_ret="/#{o[:name]} encoding_font\n"+
|
31
|
+
"/#{o[:name]}-encoding exch definefont pop\n"
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
size= o[:size]
|
36
|
+
str_ret+=case size
|
37
|
+
when Hash then "/#{@name} findfont [ #{size[:width]} 0 0 #{size[:height]} 0 0] makefont setfont "
|
38
|
+
when Array then "/#{@name} findfont [ #{size[0]} 0 0 #{size[1]} 0 0] makefont setfont "
|
39
|
+
when Fixnum then "/#{@name} findfont #{size} scalefont setfont "
|
40
|
+
end
|
41
|
+
str_ret
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#NetDeseigners <www.ndesigners.com.br>
|
2
|
+
#Shairon Toledo <shairon.toledo@gmail.com>
|
3
|
+
require 'rghost/ps_object'
|
4
|
+
require 'rghost/font'
|
5
|
+
require 'rghost/function'
|
6
|
+
|
7
|
+
|
8
|
+
class RGhost::FontMap < RGhost::PsObject #:nodoc:
|
9
|
+
include RGhost::RubyToPs
|
10
|
+
def initialize(options={:font => "Helvetica", :size => 8},&block)
|
11
|
+
|
12
|
+
#options[:name]=options[:font]
|
13
|
+
@options=options
|
14
|
+
@fonts={}
|
15
|
+
instance_eval(&block) if block
|
16
|
+
end
|
17
|
+
|
18
|
+
def new(name,options={})
|
19
|
+
#options[:name]=options[:font]
|
20
|
+
@fonts[name]=options
|
21
|
+
|
22
|
+
end
|
23
|
+
def tag(name,options={})
|
24
|
+
new(name,options)
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def ps
|
29
|
+
functions=[]
|
30
|
+
fonts=""
|
31
|
+
@fonts.each do |name,params|
|
32
|
+
options=@options
|
33
|
+
if params[:from]
|
34
|
+
[params[:from]].flatten.each do |font|
|
35
|
+
functions << format_custom_font(font)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
functions << RGhost::Function.new("_#{name}") do
|
40
|
+
raw RGhost::Font.new(options.dup.merge(params)).ps
|
41
|
+
raw( RGhost::Color.create(params[:color] || 0) )
|
42
|
+
end
|
43
|
+
end
|
44
|
+
functions.join
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
def format_custom_font(font_path)
|
49
|
+
ps=RGhost::PsObject.new
|
50
|
+
ps.raw "#{to_string(font_path)} findfont pop"
|
51
|
+
ps
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
data/lib/rghost/frame.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#Creates one rectangle or one shape with rounded corners.
|
2
|
+
#===Options
|
3
|
+
#
|
4
|
+
#* <tt>:x and :y</tt> - Coordinates to position.
|
5
|
+
#* <tt>:corners</tt> - Value for rounded corners. Use 0 to straight angle.
|
6
|
+
#* <tt>:width and :height</tt> - Size of frame
|
7
|
+
#* <tt>:content</tt> - facade to ShapeContent with same parameters.
|
8
|
+
#* <tt>:border</tt> - facade to Border with same parameters.
|
9
|
+
#===Examples using facade frame method inside of Document
|
10
|
+
# d=Document.new
|
11
|
+
# d.frame :x => 3, :width => 7, :height => 5, :content => {:fill => false}
|
12
|
+
#
|
13
|
+
#link:images/frame01.png
|
14
|
+
# d=Document.new
|
15
|
+
# d.frame :x => 3, :width => 7, :height => 5, :content => {:color => '#35F6A3' }
|
16
|
+
#
|
17
|
+
#link:images/frame02.png
|
18
|
+
#
|
19
|
+
# d=Document.new
|
20
|
+
# d.frame :x => 3, :width => 7, :height => 5, :content => {:color => '#35F6A3' }, :border =>{:width => 5, :dash => [1,3,10]}
|
21
|
+
#
|
22
|
+
#link:images/frame03.png
|
23
|
+
#
|
24
|
+
# d=Document.new
|
25
|
+
# d.frame :x => 3, :width => 7, :height => 5, :content => {:color => '#35F6A3' }, :corners => 20
|
26
|
+
#
|
27
|
+
#link:images/frame04.png
|
28
|
+
#
|
29
|
+
# d=Document.new
|
30
|
+
# d.frame :x => 3, :width => 7, :height => 5, :content => {:color => :yellow }, :border => {:color => :red, :width => 4}, :corners => 20
|
31
|
+
#
|
32
|
+
#link:images/frame05.png
|
33
|
+
class RGhost::Frame < RGhost::PsObject
|
34
|
+
DEFAULT_OPTIONS={
|
35
|
+
:x => :limit_left,
|
36
|
+
:y => :current_row,
|
37
|
+
:width => 5,
|
38
|
+
:height => 3.5,
|
39
|
+
:corners => 1,
|
40
|
+
:content => RGhost::ShapeContent::DEFAULT_OPTIONS,
|
41
|
+
:border => RGhost::Border::DEFAULT_OPTIONS
|
42
|
+
|
43
|
+
|
44
|
+
}
|
45
|
+
BACKGROUND_ROW_DEFAULT_OPTIONS={:start_in => :limit_left, :size => :area_x, :color => RGhost::ShapeContent::DEFAULT_OPTIONS[:color]}
|
46
|
+
def initialize(options={})
|
47
|
+
|
48
|
+
@options = DEFAULT_OPTIONS.dup.merge(options)
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def ps
|
54
|
+
x=RGhost::Units::parse(@options[:x])
|
55
|
+
y=RGhost::Units::parse(@options[:y])
|
56
|
+
|
57
|
+
h=RGhost::Units::parse(@options[:height])
|
58
|
+
w=RGhost::Units::parse(@options[:width])
|
59
|
+
|
60
|
+
inside=RGhost::ShapeContent.new(@options[:content]) if @options[:content]
|
61
|
+
border=RGhost::Border.new(@options[:border]) if @options[:border]
|
62
|
+
|
63
|
+
params=%Q{
|
64
|
+
/rcorners_params{
|
65
|
+
/:x #{x} def /:y #{y} def
|
66
|
+
/:w #{w} def /:h #{h} def
|
67
|
+
/:r #{@options[:corners]} def
|
68
|
+
/:s 1 def
|
69
|
+
/:inside{
|
70
|
+
#{inside.ps if inside }
|
71
|
+
} def
|
72
|
+
/:outside{
|
73
|
+
#{border.ps if border}
|
74
|
+
}def
|
75
|
+
} def
|
76
|
+
}
|
77
|
+
|
78
|
+
"#{params} rcorners_params rcorners"
|
79
|
+
|
80
|
+
end
|
81
|
+
#Creates background of the row for current row. Example
|
82
|
+
#Here's fill the current row using width :area_x, height :row_height, and starting in :limit_left.
|
83
|
+
# doc.background_row :color => '#35F6A3'
|
84
|
+
#
|
85
|
+
#link:images/background_row01.png
|
86
|
+
#
|
87
|
+
#Specifies size and where will start of background
|
88
|
+
# doc.background_row :start_in => 2, :size => 5.5, :color => 0.8
|
89
|
+
#
|
90
|
+
#link:images/background_row02.png
|
91
|
+
def self.background_row(options=BACKGROUND_ROW_DEFAULT_OPTIONS)
|
92
|
+
#opts=BACKGROUND_ROW_DEFAULT_OPTIONS.merge(options)
|
93
|
+
#start_in,size=Units::parse(opts[:start_in]),Units::parse(opts[:size])
|
94
|
+
#return RGhost::PsObject.new("#{start_in} #{size} {#{opts[:color]}} background_row ")
|
95
|
+
options =RGhost::Frame::BACKGROUND_ROW_DEFAULT_OPTIONS.merge(options)
|
96
|
+
g=RGhost::Graphic.new
|
97
|
+
g.set RGhost::Units::parse(options[:start_in])
|
98
|
+
g.set RGhost::Units::parse(options[:size])
|
99
|
+
g.set RGhost::Color.create(options[:color]) if options[:color]
|
100
|
+
g.raw :background_row
|
101
|
+
g
|
102
|
+
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "rghost/ps_object"
|
2
|
+
|
3
|
+
|
4
|
+
#Creates postscript internal function. Example
|
5
|
+
# f=RGhost::Function.new :foo do
|
6
|
+
# set Show.new("A Test")
|
7
|
+
# end
|
8
|
+
#In ps stack will be
|
9
|
+
# /foo (A Test) show def
|
10
|
+
class RGhost::Function < RGhost::PsObject
|
11
|
+
|
12
|
+
attr_reader :name
|
13
|
+
|
14
|
+
def initialize(name,body_function=nil,&block)
|
15
|
+
if block
|
16
|
+
#super(&block)
|
17
|
+
super(&block)
|
18
|
+
|
19
|
+
else
|
20
|
+
|
21
|
+
super("")
|
22
|
+
end
|
23
|
+
@name=name
|
24
|
+
@body_function=body_function
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def use_template(function_name)
|
29
|
+
call "_#{function_name}"
|
30
|
+
|
31
|
+
end
|
32
|
+
def ps
|
33
|
+
@body_function||=super
|
34
|
+
|
35
|
+
"\n/#{@name}{\n#{@body_function}\n} bind def \n"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/lib/rghost/gif.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require "rghost/ps_object"
|
2
|
+
require "rghost/graphic"
|
3
|
+
require "rghost/cursor"
|
4
|
+
require "rghost/variable"
|
5
|
+
require "rghost/image"
|
6
|
+
require "rghost/function"
|
7
|
+
require "rghost/scale"
|
8
|
+
#Loads GIF image from file
|
9
|
+
#===Examples
|
10
|
+
# doc=Document.new
|
11
|
+
# doc.set Gif.new "../public/images/button.gif", :x => 10, :y => 3
|
12
|
+
#Using Image.for facade
|
13
|
+
# doc.set Image.for "../public/images/button.gif", :x => 10, :y => 3
|
14
|
+
#Using PsFacade or Document
|
15
|
+
# doc.image "images/button.gif", :x => 10, :y => 3
|
16
|
+
#Using zoom of the 200 percent
|
17
|
+
# doc.image "images/button.gif", :zoom => 200
|
18
|
+
#===Options
|
19
|
+
#
|
20
|
+
#* <tt>:x and :y</tt> - Coordinates to position.
|
21
|
+
#* <tt>:rotate</tt> - Angle to image rotation if there is one.
|
22
|
+
#* <tt>:zoom</tt> - Resize proportionally the image
|
23
|
+
class RGhost::Gif < RGhost::Image
|
24
|
+
|
25
|
+
def ps
|
26
|
+
s=@options[:zoom]/100.0
|
27
|
+
|
28
|
+
g=RGhost::Graphic.new
|
29
|
+
|
30
|
+
params=RGhost::Function.new(:gif_params)
|
31
|
+
params.set RGhost::Cursor.translate(@options)
|
32
|
+
params.set RGhost::Cursor.rotate(@options[:rotate])
|
33
|
+
params.set RGhost::Scale.new(s,s)
|
34
|
+
|
35
|
+
g.set params
|
36
|
+
g.set RGhost::PsObject.new("(#{@file}) viewGIF")
|
37
|
+
g.ps
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "rghost/ps_object"
|
2
|
+
require "rghost/cursor"
|
3
|
+
require "rghost/point"
|
4
|
+
require "rghost/line_width"
|
5
|
+
#Creates a new graphic state between gsave and grestore postscript primitives. Example
|
6
|
+
# doc=Document.new
|
7
|
+
# doc.graphic do
|
8
|
+
# set LineWidth.new(0)
|
9
|
+
# set Line.lineto(5,7)
|
10
|
+
# end
|
11
|
+
class RGhost::Graphic < RGhost::PsObject
|
12
|
+
|
13
|
+
def ps
|
14
|
+
"gsave #{super} grestore"
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|