Method: TCPDF#StarPolygon
- Defined in:
- lib/tcpdf.rb
#StarPolygon(x0, y0, r, nv, ng, angle = 0, draw_circle = false, style = '', line_style = nil, fill_color = nil, circle_style = '', circle_outLine_style = nil, circle_fill_color = nil) ⇒ Object Also known as: star_polygon
Draws a star polygon
- @param float :x0
-
Abscissa of center point.
- @param float :y0
-
Ordinate of center point.
- @param float :r
-
Radius of inscribed circle.
- @param integer :nv
-
Number of vertices.
- @param integer :ng
-
Number of gap (if (:ng % :nv = 1) then is a regular polygon).
- @param float :angle
-
Angle oriented (anti-clockwise). Default value: 0.
- @param boolean :draw_circle
-
Draw inscribed circle or not. Default value is false.
- @param string :style
-
Style of rendering. See the getPathPaintOperator() function for more information.
- @param array :line_style
-
Line style of polygon sides. Array with keys among the following:
-
all: Line style of all sides. Array like for SetLineStyle SetLineStyle.
-
0 to (n - 1): Line style of each side. Array like for SetLineStyle SetLineStyle.
-
If a key is not present or is null, not draws the side. Default value is default line style (empty array). [@param array :fill_color ]Fill color. Format: array(red, green, blue). Default value: default color (empty array).
- @param string :circle_style
-
Style of rendering of inscribed circle (if draws). Possible values are:
-
D or empty string: Draw (default).
-
F: Fill.
-
DF or FD: Draw and fill.
-
CNZ: Clipping mode (using the even-odd rule to determine which regions lie inside the clipping path).
-
CEO: Clipping mode (using the nonzero winding number rule to determine which regions lie inside the clipping path).
-
- @param array :circle_outLine_style
-
Line style of inscribed circle (if draws). Array like for SetLineStyle SetLineStyle. Default value: default line style (empty array).
- @param array :circle_fill_color
-
Fill color of inscribed circle (if draws). Format: array(red, green, blue). Default value: default color (empty array).
- @access public
- @since 2.1.000 (2008-01-08)
8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 |
# File 'lib/tcpdf.rb', line 8516 def StarPolygon(x0, y0, r, nv, ng, angle=0, draw_circle=false, style='', line_style=nil, fill_color=nil, circle_style='', circle_outLine_style=nil, circle_fill_color=nil) draw_circle = false if draw_circle == 0 if nv < 2 nv = 2 end if draw_circle Circle(x0, y0, r, 0, 360, circle_style, circle_outLine_style, circle_fill_color) end p2 = [] visited = [] 0.upto(nv -1) do |i| a = angle + i * 360 / nv a_rad = a * ::Math::PI / 180 # deg2rad p2.push x0 + r * ::Math.sin(a_rad) p2.push y0 + r * ::Math.cos(a_rad) visited.push false end p = [] i = 0 while true p.push p2[i * 2] p.push p2[i * 2 + 1] visited[i] = true i += ng i %= nv break if visited[i] end Polygon(p, style, line_style, fill_color) end |