Sha256: 20d24828a4ec9e0906a4044a43387dbc1e3cd454f8df6a62d5fdcb366a481f4d

Contents?: true

Size: 783 Bytes

Versions: 5

Compression:

Stored size: 783 Bytes

Contents

# encoding: utf-8   

# cap_style.rb : Implements stroke cap styling
#
# Contributed by Daniel Nelson. October, 2009
#
# This is free software. Please see the LICENSE and COPYING files for details.
#
module Prawn
  module Graphics
    module CapStyle
      # Sets the cap_style for stroked lines and curves
      #

      CAP_STYLES = { :butt => 0, :round => 1, :projecting_square => 2 }
      
      # style is one of :butt, :round, or :projecting_square
      def cap_style(style=nil)
        return @cap_style || :butt if style.nil?

        @cap_style = style

        write_stroke_cap_style
      end
      
      alias_method :cap_style=, :cap_style

      private

      def write_stroke_cap_style
        add_content "#{CAP_STYLES[@cap_style]} J"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
prawn-layout-0.3.2 vendor/prawn-core/lib/prawn/graphics/cap_style.rb
prawn-core-0.6.3 lib/prawn/graphics/cap_style.rb
prawn-core-0.6.2 lib/prawn/graphics/cap_style.rb
prawn-layout-0.3.1 vendor/prawn-core/lib/prawn/graphics/cap_style.rb
prawn-core-0.6.1 lib/prawn/graphics/cap_style.rb