HTML Canvas clip()
Method
Example
Clip a 200*120 pixel rectangular area from the canvas. Then, draw a red rectangle. Only the part of the red rectangle within the clipped area will be visible:
JavaScript:
Browser Support
Internet Explorer 9, Firefox, Opera, Chrome, and Safari support the clip()
method.
Note: Internet Explorer 8 and earlier versions do not support the <canvas>
element.
Definition and Usage
The clip()
method clips a region of any shape and size from the original canvas.
Tip: Once a region is clipped, all subsequent drawings will be limited to the clipped region (you cannot access other areas of the canvas). You can also save the current canvas region using the save()
method before using the clip()
method, and restore it at any later time using the restore()
method.
| JavaScript Syntax: | context.clip();
|
| --- | --- |