Defines a shape that will mask any shapes drawn afterward.
The first parameter, callback
, is a function that defines the mask. Any shapes drawn in callback
will add to the mask shape. The mask will apply to anything drawn after clip()
is called.
The second parameter, options
, is optional. If an object with an invert
property is passed, as in beginClip({ invert: true })
, it will be used to set the masking mode. { invert: true }
inverts the mask, creating holes in shapes that are masked. invert
is false
by default.
Masks can be contained between the push() and pop() functions. Doing so allows unmasked shapes to be drawn after masked shapes.
Masks can also be defined with beginClip() and endClip().
Examples
Syntax
clip(callback, [options])
Parameters
callback
Function: a function that draws the mask shape.
options
Object: an object containing clip settings.
Notice any errors or typos? Please let us know. Please feel free to edit src/color/setting.js and open a pull request!