Method: TCPDF#Rect
- Defined in:
- lib/tcpdf.rb
#Rect(x, y, w, h, style = '', border_style = {}, fill_color = {}) ⇒ Object Also known as: rect
Draws a rectangle.
- @param float :x
-
Abscissa of upper-left corner (or upper-right corner for RTL language).
- @param float :y
-
Ordinate of upper-left corner (or upper-right corner for RTL language).
- @param float :w
-
Width.
- @param float :h
-
Height.
- @param string :style
-
Style of rendering. See the getPathPaintOperator() function for more information.
-
all: Line style of all borders. Array like for SetLineStyle SetLineStyle.
-
L, T, R, B or combinations: Line style of left, top, right or bottom border. Array like for SetLineStyle SetLineStyle.
If a key is not present or is null, not draws the border. Default value: default line style (empty array).
-
- @param array :border_style
-
Border style of rectangle. Array like for SetLineStyle SetLineStyle. Default value: default line style (empty array).
- @param array :fill_color
-
Fill color. Format: array(GREY) or array(R,G,B) or array(C,M,Y,K). Default value: default color (empty array).
- @access public
- @since 1.0
- @see
-
SetLineStyle()
8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 |
# File 'lib/tcpdf.rb', line 8106 def Rect(x, y, w, h, style='', border_style={}, fill_color={}) if style.index('F') != nil and !fill_color.empty? SetFillColorArray(fill_color) end op = getPathPaintOperator(style) if !border_style or !border_style['all'].nil? if !border_style['all'].nil? and border_style['all'] SetLineStyle(border_style['all']) border_style = {} end end outRect(x, y, w, h, op) if border_style border_style2 = {} border_style.each { |line, value| length = line.length 0.upto(length - 1) do |i| border_style2[line[i]] = value end } border_style = border_style2 if !border_style['L'].nil? and border_style['L'] Line(x, y, x, y + h, border_style['L']) end if !border_style['T'].nil? and border_style['T'] Line(x, y, x + w, y, border_style['T']) end if !border_style['R'].nil? and border_style['R'] Line(x + w, y, x + w, y + h, border_style['R']) end if !border_style['B'].nil? and border_style['B'] Line(x, y + h, x + w, y + h, border_style['B']) end end end |