Method: TCPDF#SetFillColor
- Defined in:
- lib/tcpdf.rb
#SetFillColor(col1 = 0, col2 = -1,, col3 = -1,, col4 = -1)) ⇒ Object Also known as: set_fill_color
Defines the color used for all filling operations (filled rectangles and cell backgrounds). It can be expressed in RGB components or gray scale. The method can be called before the first page is created and the value is retained from page to page.
- @param int :col1
-
Gray level for single color, or Red color for RGB, or Cyan color for CMYK. Value between 0 and 255
- @param int :col2
-
Green color for RGB, or Magenta color for CMYK. Value between 0 and 255
- @param int :col3
-
Blue color for RGB, or Yellow color for CMYK. Value between 0 and 255
- @param int :col4
-
Key (Black) color for CMYK. Value between 0 and 255
- @access public
- @since 1.3
- @see
-
SetDrawColor(), SetTextColor(), Rect(), Cell(), MultiCell()
2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 |
# File 'lib/tcpdf.rb', line 2261 def SetFillColor(col1=0, col2=-1, col3=-1, col4=-1) # set default values unless col1.is_a?(Numeric) col1 = 0 end unless col2.is_a?(Numeric) col2 = -1 end unless col3.is_a?(Numeric) col3 = -1 end unless col4.is_a?(Numeric) col4 = -1 end # Set color for all filling operations if (col2 == -1) and (col3 == -1) and (col4 == -1) # Grey scale @fill_color = sprintf('%.3f g', col1 / 255.0) @bgcolor['G'] = col1 elsif col4 == -1 # RGB @fill_color = sprintf('%.3f %.3f %.3f rg', col1 / 255.0, col2 / 255.0, col3 / 255.0) @bgcolor['R'] = col1 @bgcolor['G'] = col2 @bgcolor['B'] = col3 else # CMYK @fill_color = sprintf('%.3f %.3f %.3f %.3f k', col1 / 100.0, col2 / 100.0, col3 / 100.0, col4 / 100.0) @bgcolor['C'] = col1 @bgcolor['M'] = col2 @bgcolor['Y'] = col3 @bgcolor['K'] = col4 end @color_flag = (@fill_color != @text_color) if @page > 0 out(@fill_color) end end |