HTML5 2D Canvas support in 54 bytes. Evaluates to:
- 0 if there isn't any Canvas support
- 0.5 if there's basic support, but no text (text got added later)
- 1 if there's full support (yay!)
// canvas support: | |
// 0 = no support | |
// 0.5 = basic support, but no text | |
// 1 = full support | |
// CanvasRenderingContext2D = context object | |
// TextMetrics = text measurement object | |
!!this.CanvasRenderingContext2D / 2 + !!this.TextMetrics / 2 |
!!this.CanvasRenderingContext2D/2+!!this.TextMetrics/2 |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. |
{ | |
"name": "canvasSupport", | |
"description": "Information about what parts of the 2D HTML5 Canvas this browser supports.", | |
"keywords": [ | |
"html5", | |
"canvas-2d", | |
"support" | |
] | |
} |
<!DOCTYPE html> | |
<title>canvasSupport</title> | |
<h1>HTML5 Canvas Support</h1> | |
<div id="result">Loading.../div> | |
<script> | |
var support = !!this.CanvasRenderingContext2D/2+!!this.TextMetrics/2; | |
document.getElementById('result').innerHTML = support ? (support - 0.5 ? 'Yay! Your browser has full support!' : 'You have basic support, but no Text API') : 'Boooo! You don\'t have any support!'; | |
</script> |
Use "this" instead of "window" to save some more bytes.