Method: HexaPDF::Content::Canvas#clip_path
- Defined in:
- lib/hexapdf/content/canvas.rb
#clip_path(rule = :nonzero) ⇒ Object
:call-seq:
canvas.clip_path(rule = :nonzero) => canvas
Modifies the clipping path by intersecting it with the current path. Returns self.
The argument rule may either be :nonzero to use the nonzero winding number rule or :even_odd to use the even-odd rule for determining which regions lie inside the clipping path. Details on how these rules work are found in the PDF 2.0 spec section 8.5.3.3 or via Internet search.
The initial clipping path includes the entire canvas. Once the clipping path is reduced to a subset of the canvas, there is no way to enlarge it. To restrict the effect of this method, use #save_graphics_state before modifying the clipping path.
Note that the current path cannot be modified after invoking this method! This means that one of the path painting methods or #end_path must be called immediately afterwards.
Examples:
#>pdf
canvas.ellipse(100, 100, a: 50, b: 30). # Restrict operations to this intersecting path
ellipse(100, 100, a: 30, b: 50). # where the inside is not part of it
clip_path(:even_odd).end_path
canvas.rectangle(0, 0, 200, 200).fill # Fills everything inside the clipping path
See: PDF2.0 s8.5.4, #end_path
1701 1702 1703 1704 1705 |
# File 'lib/hexapdf/content/canvas.rb', line 1701 def clip_path(rule = :nonzero) raise_unless_in_path invoke0(rule == :nonzero ? :W : :'W*') self end |