Skip to content

Instantly share code, notes, and snippets.

View abods's full-sized avatar

Abdullah alotaibi abods

View GitHub Profile
@abods
abods / detect ie
Created September 27, 2012 16:46 — forked from padolsey/gist:527683
js
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@abods
abods / gist:eff35a20d85815434ad7
Created May 20, 2014 05:32
get canvas pixels rgb
ctx.drawImage(image, 0, 0);
var imageData = ctx.getImageData(0, 0, 1199, 677);
// moust used colors
var r=0,g=0,b=0,a=0;
for (var i = 0; i < imageData.data.length; i+=4) {
r+=imageData.data[i];
g+=imageData.data[i+1];
b+=imageData.data[i+2];
@mixin transition($transition-property, $transition-time, $method) {
-webkit-transition: $transition-property $transition-time $method;
-moz-transition: $transition-property $transition-time $method;
-ms-transition: $transition-property $transition-time $method;
-o-transition: $transition-property $transition-time $method;
transition: $transition-property $transition-time $method;
}
@mixin transform($transforms) {
-moz-transform: $transforms;
-o-transform: $transforms;
@abods
abods / fabricJS history
Created November 5, 2016 12:53 — forked from ZAYEC77/fabricJS history
History implementation for fabricJS
function (canvas, container) {
var history = {state: [], lock: true, mods: 0};
app.history = history;
canvas.on('history.lock', function () {
history.lock = true;
});
canvas.on('history.unlock', function () {
history.lock = false;