CanvasRenderingContext2D.removeHitRegion()

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The CanvasRenderingContext2D.removeHitRegion() method of the Canvas 2D API removes a given hit region from the canvas.

Syntax

void ctx.removeHitRegion(id);

Parameters

id
A DOMString representing the id of the region that is to be removed.

Examples

Using the removeHitRegion method

This is just a simple code snippet which uses the removeHitRegion method.

HTML

<canvas id="canvas"></canvas>

JavaScript

var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');

// set a hit region 
ctx.addHitRegion({id: 'eyes'});

// remove it from the canvas
ctx.removeHitRegion('eyes');

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'CanvasRenderingContext2D.removeHitRegion' in that specification.
Living Standard  

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support Yes1 ?302 Yes Yes Yes
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support No No ?302 Yes Yes No

1. This feature is behind the ExperimentalCanvasFeatures preference. To change preferences in Chrome, visit chrome://flags.

2. From version 30: this feature is behind the canvas.hitregions.enabled preference. To change preferences in Firefox, visit about:config.

See also

Document Tags and Contributors

Contributors to this page: fscholz, nmve
Last updated by: fscholz,