Method: PDF::Writer::Graphics#polygon
- Defined in:
- lib/pdf/writer/graphics.rb
#polygon(points) ⇒ Object
Draw a polygon. points is an array of PolygonPoint objects, or an array that can be converted to an array of PolygonPoint objects with PDF::Writer::PolygonPoint.new(*value).
- New Point
-
(points[-1].x, points[-1].y) - Subpath
-
New
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
# File 'lib/pdf/writer/graphics.rb', line 325 def polygon(points) points = points.map { |pp| pp.kind_of?(Array) ? PDF::Writer::PolygonPoint.new(*pp) : pp } point = points.shift move_to(point.x, point.y) while not points.empty? point = points.shift case point.connector when :curve c1 = point c2 = points.shift point = points.shift curve_to(c1.x, c1.y, c2.x, c2.y, point.x, point.y) when :scurve c1 = point point = points.shift scurve_to(c1.x, c1.y, point.x, point.y) when :ecurve c1 = point point = points.shift ecurve_to(c1.x, c1.y, point.x, point.y) else line_to(point.x, point.y) end end self end |