Canvas 5 Polyfill is a Javascript polyfill library to fill in new features for HTML 5
Canvas that browsers may not have implemented yet, such as Path2D objects and
ellipse() on CanvasRenderingContext2D.
Installation
Canvas 5 Polyfill uses Bower to make installation easy:
<html>
<head>
<title>Test Canvas Polyfill</title>
<script
src='//mirrors/canvas-5-polyfill/tree/master/bower_components/canvas-5-polyfill/canvas.js'
type='text/javascript'></script>
</head>
<body>
<canvas id=ID width=500 height=500>
<script type='text/javascript' charset='utf-8'>
var ctx = document.getElementById('ID').getContext('2d');
var p = new Path2D();
p.moveTo(100, 10);
p.lineTo(10, 100);
ctx.strokeStyle = '#555';
ctx.lineWidth = 10;
ctx.stroke(p);
</script>
</body>
</html>
Status
Canvas 5 Polyfill adds the following classes and methods to an existing HTML
Canvas implementation if they are missing, if they are not missing the native
implementations are used:
The polyfill adds the following methods to CanvasRenderingContext2D:
With this polyfill installed, the calls to context.clip(path),
context.isPointInPath(path, x, y) and context.isPointInStroke(path, x, y)
all affect the current path.
When using the polyfill the best approach is to move strictly to using
Path2D objects to describe paths and then use the path enabled calls
on the context, such as ctx.fill(path). Do not mix and match such calls.
Canvas 5 Polyfill
Canvas 5 Polyfill is a Javascript polyfill library to fill in new features for HTML 5 Canvas that browsers may not have implemented yet, such as Path2D objects and ellipse() on CanvasRenderingContext2D.
Installation
Canvas 5 Polyfill uses Bower to make installation easy:
You can also get the code directly at GitHub.
Usage
Status
Canvas 5 Polyfill adds the following classes and methods to an existing HTML Canvas implementation if they are missing, if they are not missing the native implementations are used:
The polyfill adds the following methods to CanvasRenderingContext2D:
It also adds Path2D with the following constructors:
Where Path2D has the following methods:
Caveats
With this polyfill installed, the calls to context.clip(path), context.isPointInPath(path, x, y) and context.isPointInStroke(path, x, y) all affect the current path.
When using the polyfill the best approach is to move strictly to using Path2D objects to describe paths and then use the path enabled calls on the context, such as ctx.fill(path). Do not mix and match such calls.