Method: RBPDF#RoundedRectXY
- Defined in:
- lib/rbpdf.rb
#RoundedRectXY(x, y, w, h, rx, ry, round_corner = '1111', style = '', border_style = nil, fill_color = nil) ⇒ Object Also known as: rounded_rect_xy
Draws a rounded rectangle.
- @param float :x
-
Abscissa of upper-left corner.
- @param float :y
-
Ordinate of upper-left corner.
- @param float :w
-
Width.
- @param float :h
-
Height.
- @param float :rx
-
the x-axis radius of the ellipse used to round off the corners of the rectangle.
- @param float :ry
-
the y-axis radius of the ellipse used to round off the corners of the rectangle.
- @param string :round_corner
-
Draws rounded corner or not. String with a 0 (not rounded i-corner) or 1 (rounded i-corner) in i-position. Positions are, in order and begin to 0: top left, top right, bottom right and bottom left. Default value: all rounded corner (“1111”).
- @param string :style
-
Style of rendering. See the getPathPaintOperator() function for more information.
- @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 4.9.019 (2010-04-22)
9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 |
# File 'lib/rbpdf.rb', line 9588 def RoundedRectXY(x, y, w, h, rx, ry, round_corner='1111', style='', border_style=nil, fill_color=nil) style = '' if style.nil? if (round_corner == '0000') or ((rx == ry) and (rx == 0)) # Not rounded Rect(x, y, w, h, style, border_style, fill_color) return end # Rounded if (nil != style.index('F')) and fill_color SetFillColorArray(fill_color) end op = getPathPaintOperator(style) if op == 'f' border_style = [] end if border_style SetLineStyle(border_style) end myArc = 4 / 3.0 * (::Math.sqrt(2) - 1) outPoint(x + rx, y) xc = x + w - rx yc = y + ry outLine(xc, y) if round_corner[0,1] == '1' outCurve(xc + (rx * myArc), yc - ry, xc + rx, yc - (ry * myArc), xc + rx, yc) else outLine(x + w, y) end xc = x + w - rx yc = y + h - ry outLine(x + w, yc) if round_corner[1,1] == '1' outCurve(xc + rx, yc + (ry * myArc), xc + (rx * myArc), yc + ry, xc, yc + ry) else outLine(x + w, y + h) end xc = x + rx yc = y + h - ry outLine(xc, y + h) if round_corner[2,1] == '1' outCurve(xc - (rx * myArc), yc + ry, xc - rx, yc + (ry * myArc), xc - rx, yc) else outLine(x, y + h) end xc = x + rx yc = y + ry outLine(x, yc) if round_corner[3,1] == '1' outCurve(xc - rx, yc - (ry * myArc), xc - (rx * myArc), yc - ry, xc, yc - ry) else outLine(x, y) outLine(x + rx, y) end out(op) end |