This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTMLCanvasElement.prototype.contrast = function (value) { | |
var | |
canvas = this, | |
context = canvas.getContext('2d'), | |
imageData = context.getImageData(0, 0, canvas.width, canvas.height), | |
canvasPixelArray = imageData.data, | |
canvasPixelArrayLength = canvasPixelArray.length, | |
i = 0; | |
value = (parseFloat(value) || 0) + 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTMLCanvasElement.prototype.desaturate = function () { | |
var | |
canvas = this, | |
context = canvas.getContext('2d'), | |
imageData = context.getImageData(0, 0, canvas.width, canvas.height), | |
canvasPixelArray = imageData.data, | |
canvasPixelArrayLength = canvasPixelArray.length, | |
i = 0, | |
grayscale = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTMLCanvasElement.prototype.trim = function () { | |
var | |
canvas = this, | |
width = canvas.width, | |
height = canvas.height, | |
pixels = width * height, | |
context = canvas.getContext('2d'), | |
imageData = context.getImageData(0, 0, width, height), | |
canvasPixelArray = imageData.data, | |
top = height, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTMLCanvasElement.prototype.getImageData = function (x, y, width, height) { | |
return this.getContext('2d').getImageData(parseFloat(x) || 0, parseFloat(y) || 0, width != null ? parseFloat(width) : this.width, height != null ? parseFloat(height) : this.height); | |
}; | |
HTMLCanvasElement.prototype.putImageData = function (imageData, x, y, width, height) { | |
var canvas = this; | |
canvas.width = width != null ? parseFloat(width) : canvas.width; | |
canvas.height = height != null ? parseFloat(height) : canvas.height; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Canvas Prototype (because prototyping has always proven to be such a great idea...) | |
if (HTMLCanvasElement) { | |
function RGBToHSL(r, g, b) { | |
var | |
min = Math.min(r, g, b), | |
max = Math.max(r, g, b), | |
diff = max - min, | |
h = 0, s = 0, l = (min + max) / 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function RGBToHSL(r, g, b) { | |
var | |
min = Math.min(r, g, b), | |
max = Math.max(r, g, b), | |
diff = max - min, | |
h = 0, s = 0, l = (min + max) / 2; | |
if (diff != 0) { | |
s = l < 0.5 ? diff / (max + min) : diff / (2 - max - min); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function boundingWidthFromAngle ( degree , width , height ) { | |
with ( Math ) { | |
degree = degree % 360; | |
var radian = degree * PI / 180; | |
height = ( ( degree >= 0 && degree < 90 ) || ( degree >= 180 && degree < 270 ) ) ? height : -height; | |
return ceil( abs( height * sin( radian ) + width * cos( radian ) ) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (window, screen, documentElement) { | |
/* ====================================================================== | |
Setup | |
====================================================================== */ | |
var hasEventListener = ('addEventListener' in window); | |
var hasOrientation = ('orientation' in window); | |
var hasGetComputedStyle = ('getComputedStyle' in window); | |
var regexpTrim = /^\s+|\s+$/g; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$referer = 'http://caniuse.com/index.php'; | |
$url = 'http://caniuse.com/jsonp.php'; | |
$user_agent = 'Mozilla/5.0 (compatible; Linux) Curl/1.0'; | |
$file = 'data.json'; | |
$curl_handle = curl_init(); | |
curl_setopt($curl_handle, CURLOPT_URL, $url); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<meta name="viewport" content="width=device-width"> | |
<script> | |
document.querySelector && document.querySelector('meta[name="viewport"]').setAttribute( | |
'content', 'width=device-' + (window.orientation ? 'height' : 'width') | |
); | |
</script> |