public
Description: Fast, Nimble PDF Writer for Ruby
Homepage: http://prawn.majesticseacreature.com
Clone URL: git://github.com/sandal/prawn.git
More cleanup of earlier hacks and making things more normal when working outside 
of the generate block
sandal (author)
Thu Jul 24 12:42:49 -0700 2008
commit  3867937e578440e363e0f67f927adf006228450a
tree    6ffccd64b01d35afa96728b1cedfb5f8c420b39f
parent  c9b31cbf847268af540ad76e603922eaca347d10
...
196
197
198
199
 
 
200
201
202
 
 
 
203
204
205
206
207
208
 
 
209
210
211
 
 
 
212
213
214
...
265
266
267
268
269
270
 
 
 
 
 
271
272
273
...
196
197
198
 
199
200
201
202
 
203
204
205
206
207
208
209
210
 
211
212
213
214
 
215
216
217
218
219
220
...
271
272
273
 
 
 
274
275
276
277
278
279
280
281
0
@@ -196,19 +196,25 @@ module Prawn
0
     # 
0
     #   pdf.fill_color "f0ffc1"
0
     #
0
-    def fill_color(color)
0
+    def fill_color(color=nil)
0
+      return @fill_color unless color
0
       @fill_color = color
0
       set_fill_color     
0
-    end                                                                      
0
+    end 
0
+    
0
+    alias_method :fill_color=, :fill_color                                                                     
0
     
0
     # Sets the line stroking color.  6 digit HTML color codes are used.
0
     #
0
     #   pdf.stroke_color "cc2fde"
0
     #
0
-    def stroke_color(color) 
0
+    def stroke_color(color=nil) 
0
+      return @stroke_color unless color
0
       @stroke_color = color
0
       set_stroke_color
0
-    end
0
+    end   
0
+    
0
+    alias_method :stroke_color=, :stroke_color
0
     
0
     # Strokes and closes the current path.
0
     #
0
@@ -265,9 +271,11 @@ module Prawn
0
       add_content "%.3f %.3f %.3f RG" %  [r / 255.0, g / 255.0, b / 255.0]       
0
     end                                       
0
     
0
-    def update_colors                                         
0
-      set_fill_color   if @fill_color
0
-      set_stroke_color if @stroke_color
0
+    def update_colors 
0
+      @fill_color   ||= "000000"
0
+      @stroke_color ||= "000000"                                       
0
+      set_fill_color
0
+      set_stroke_color
0
     end
0
 
0
   end
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
198
199
 
 
 
200
201
202
203
204
205
...
177
178
179
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
 
 
198
199
200
201
 
 
202
203
204
0
@@ -177,29 +177,28 @@ module Prawn
0
 
0
         # TODO: This is a bit of a hack and can be cleaned up
0
         if @background_color
0
-          old_fill_color, old_stroke_color = 
0
-           @document.instance_eval { [@fill_color, @stroke_color] }
0
-          @document.fill_color @background_color
0
-          @document.stroke_color @background_color
0
-
0
-          @document.canvas do
0
-            case border_style
0
-            when :all
0
-              point = [x,y-border]
0
-              h = height - border
0
-            when :no_top
0
-              point = [x,y-border/2.0]  
0
-              h     = height - border / 2.0
0
-            else
0
-              point = [x,y-border/2.0]
0
-              h     = height
0
-           end
0
+
0
+          @document.mask(:fill_color, :stroke_color) do
0
+            @document.fill_color = @background_color
0
+            @document.stroke_color = @background_color
0
+
0
+            @document.canvas do
0
+              case border_style
0
+              when :all
0
+                point = [x,y-border]
0
+                h = height - border
0
+              when :no_top
0
+                point = [x,y-border/2.0]  
0
+                h     = height - border / 2.0
0
+              else
0
+                point = [x,y-border/2.0]
0
+                h     = height
0
+             end
0
                     
0
-            @document.fill_and_stroke_rectangle point, width, h
0
-          end
0
+              @document.fill_and_stroke_rectangle point, width, h
0
+            end
0
+          end   
0
 
0
-          @document.fill_color old_fill_color || "000000"
0
-          @document.stroke_color old_stroke_color || "000000"
0
         end
0
 
0
         @cells.each do |e|

Comments