def draw_polygon(coords = [], attr = {})
            load!

            stroke_color  = attr.fetch(:stroke_color, DEFAULT_STROKE_COLOR)
            fill_color    = attr.fetch(:fill_color, DEFAULT_FILL_COLOR)
            line_cap      = attr.fetch(:line_cap, DEFAULT_LINECAP)
            line_join     = attr.fetch(:line_join, DEFAULT_LINEJOIN)
            line_width    = attr.fetch(:line_width, DEFAULT_LINEWIDTH)
            dash_pattern  = attr.fetch(:dash, DEFAULT_DASHPATTERN)

            stroke        = attr[:stroke].nil? ? true : attr[:stroke]
            fill          = attr[:fill].nil? ? false : attr[:fill]

            stroke = true if fill == false and stroke == false

            set_fill_color(fill_color) if fill
            set_stroke_color(stroke_color) if stroke
            set_line_width(line_width)
            set_line_cap(line_cap)
            set_line_join(line_join)
            set_dash_pattern(dash_pattern)

            if @canvas.gs.text_state.is_in_text_object?
                @instructions << PDF::Instruction.new('ET').render(@canvas)
            end

            unless coords.size < 1
                x,y = coords.slice!(0)
                @instructions << PDF::Instruction.new('m',x,y).render(@canvas)

                coords.each do |px,py|
                    @instructions << PDF::Instruction.new('l',px,py).render(@canvas)
                end

                @instructions << (i =
                    if stroke and not fill
                        PDF::Instruction.new('s')
                    elsif fill and not stroke
                        PDF::Instruction.new('f')
                    elsif fill and stroke
                        PDF::Instruction.new('b')
                    end
                )

                i.render(@canvas)
            end

            self
        end
def draw_polygon(coords = [], attr = {})
            load!

            stroke_color  = attr.fetch(:stroke_color, DEFAULT_STROKE_COLOR)
            fill_color    = attr.fetch(:fill_color, DEFAULT_FILL_COLOR)
            line_cap      = attr.fetch(:line_cap, DEFAULT_LINECAP)
            line_join     = attr.fetch(:line_join, DEFAULT_LINEJOIN)
            line_width    = attr.fetch(:line_width, DEFAULT_LINEWIDTH)
            dash_pattern  = attr.fetch(:dash, DEFAULT_DASHPATTERN)

            stroke        = attr[:stroke].nil? ? true : attr[:stroke]
            fill          = attr[:fill].nil? ? false : attr[:fill]

            stroke = true if fill == false and stroke == false

            set_fill_color(fill_color) if fill
            set_stroke_color(stroke_color) if stroke
            set_line_width(line_width)
            set_line_cap(line_cap)
            set_line_join(line_join)
            set_dash_pattern(dash_pattern)

            if @canvas.gs.text_state.is_in_text_object?
                @instructions << PDF::Instruction.new('ET').render(@canvas)
            end

            unless coords.size < 1
                x,y = coords.slice!(0)
                @instructions << PDF::Instruction.new('m',x,y).render(@canvas)

                coords.each do |px,py|
                    @instructions << PDF::Instruction.new('l',px,py).render(@canvas)
                end

                @instructions << (i =
                    if stroke and not fill
                        PDF::Instruction.new('s')
                    elsif fill and not stroke
                        PDF::Instruction.new('f')
                    elsif fill and stroke
                        PDF::Instruction.new('b')
                    end
                )

                i.render(@canvas)
            end

            self
        end
Draw a polygon from a array of coordinates.