Module: HexaPDF::Content::LineCapStyle
- Defined in:
- lib/hexapdf/content/graphics_state.rb
Overview
Defines all available line cap styles as constants. Each line cap style is an instance of NamedValue, see ::normalize. For use with e.g. Canvas#line_cap_style.
See: PDF2.0 s8.4.3.3
Constant Summary collapse
- BUTT_CAP =
Stroke is squared off at the endpoint of a path.
Specify as 0 or
:butt
.#>pdf-small-hide canvas.line_cap_style(:butt) canvas.line_width(10).line(50, 20, 50, 80).stroke canvas.stroke_color("white").line_width(1).line(50, 20, 50, 80).stroke
NamedValue.new(:butt, 0)
- ROUND_CAP =
A semicircular arc is drawn at the endpoint of a path.
Specify as 1 or
:round
.#>pdf-small-hide canvas.line_cap_style(:round) canvas.line_width(10).line(50, 20, 50, 80).stroke canvas.stroke_color("white").line_width(1).line(50, 20, 50, 80).stroke
NamedValue.new(:round, 1)
- PROJECTING_SQUARE_CAP =
The stroke continues half the line width beyond the endpoint of a path.
Specify as 2 or
:projecting_square
.#>pdf-small-hide canvas.line_cap_style(:projecting_square) canvas.line_width(10).line(50, 20, 50, 80).stroke canvas.stroke_color("white").line_width(1).line(50, 20, 50, 80).stroke
NamedValue.new(:projecting_square, 2)
Class Method Summary collapse
-
.normalize(style) ⇒ Object
Returns the argument normalized to a valid line cap style, i.e.
Class Method Details
.normalize(style) ⇒ Object
Returns the argument normalized to a valid line cap style, i.e. a NamedValue instance.
-
0 or
:butt
can be used for the BUTT_CAP style. -
1 or
:round
can be used for the ROUND_CAP style. -
2 or
:projecting_square
can be used for the PROJECTING_SQUARE_CAP style. -
Otherwise an error is raised.
89 90 91 92 93 94 95 96 97 |
# File 'lib/hexapdf/content/graphics_state.rb', line 89 def self.normalize(style) case style when :butt, 0 then BUTT_CAP when :round, 1 then ROUND_CAP when :projecting_square, 2 then PROJECTING_SQUARE_CAP else raise ArgumentError, "Unknown line cap style: #{style}" end end |