Method: HexaPDF::Content::Canvas#line_join_style
- Defined in:
- lib/hexapdf/content/canvas.rb
#line_join_style(style = nil, &block) ⇒ Object Also known as: line_join_style=
:call-seq:
canvas.line_join_style => current_line_join_style
canvas.line_join_style(style) => canvas
canvas.line_join_style(style) { block } => canvas
The line join style specifies the shape that is used at the corners of stroked paths.
The style parameter can be one of (also see LineJoinStyle):
- :miter or 0
-
The outer lines of the two segments continue until the meet at an angle.
- :round or 1
-
An arc of a circle is drawn around the point where the segments meet.
- :bevel or 2
-
The two segments are finished with butt caps and the space between the ends is filled with a triangle.
Note that the return value is always a normalized line join style (i.e. a NamedValue).
Returns the current line join style (see GraphicsState#line_join_style) when no argument is given. Otherwise sets the line join style to the given style and returns self. The setter version can also be called in the line_join_style= form.
If the style and a block are provided, the changed line join style is only active during the block by saving and restoring the graphics state.
Examples:
#>pdf
canvas.line_join_style(:miter)
canvas.line_join_style # => #<NamedValue @name=:miter, @value=0>
canvas.line_join_style = :round # => #<NamedValue @name=:round, @value=1>
canvas.line_join_style(:bevel) do
canvas.line_join_style # => #<NamedValue @name=:bevel, @value=2>
end
canvas.line_join_style # => #<NamedValue @name=:round, @value=1>
# visual example
[:miter, :round, :bevel].each_with_index do |style, index|
canvas.line_join_style(style).
line_width(10).stroke_color("black").
polyline(20 + index * 60, 30, 40 + index * 60, 170, 60 + index * 60, 30).stroke
canvas.stroke_color("white").line_width(1).line_join_style(:bevel).
polyline(20 + index * 60, 30, 40 + index * 60, 170, 60 + index * 60, 30).stroke
end
See: PDF2.0 s8.4.3.4, Content::LineJoinStyle
731 732 733 |
# File 'lib/hexapdf/content/canvas.rb', line 731 def line_join_style(style = nil, &block) gs_getter_setter(:line_join_style, :j, style && LineJoinStyle.normalize(style), &block) end |