Using canvas, you can change the color of an image !
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 Vector (x,y) { | |
this.x = x; | |
this.y = y; | |
} | |
Vector.prototype.length = function() { | |
return Math.sqrt(this.x*this.x + this.y*this.y); | |
}; | |
Vector.prototype.add = function(vector) { |
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 Color (red,green,blue,alpha) { | |
this.red = red; | |
this.blue = blue; | |
this.green = green; | |
this.alpha = (alpha || 1); | |
} | |
Color.prototype.toString = function() { | |
return "rgba("+Math.floor(this.red) + | |
"," + Math.floor(this.green) + |
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 Pool (size, entity, params) { | |
"use strict"; | |
this.item = []; | |
this.dead = []; | |
var that = this; | |
this.forceIndex = 0; | |
for (var i = size - 1; i >= 0; i--) { | |
var newItem = new entity(params); |
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() { | |
"use strict"; | |
//Mon Code | |
/*********************************************************\ | |
MULTI EXPORT | |
\*********************************************************/ | |
if (typeof exports === 'object') { |
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
var express = require('express'); | |
var app = express(); | |
app.use("/",express.static(__dirname + '/')); | |
app.listen(8080); |
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() { | |
"use strict"; | |
var addEventCapabilities = function (object) { | |
object = object || {}; | |
object.listenersFor = {}; | |
object.listenersCount = 0; | |
object.specialEmiter = {}; |
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() { | |
"use strict"; | |
var characters = "abcdefghijklmnopqrstuvwxyz?!.:,-<>"; | |
var numbers = "0123456789" | |
var sizeChar = 128; | |
var kerningDefault = { | |
"a": 25, | |
"b": 25, | |
"c": 25, | |
"d": 24, |
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 callbackToPromise(callback) { | |
return function() { | |
var arg = arguments | |
return new Promise(function(succed, reject) { | |
arg.push(function(err, result) { | |
if (err) return reject(err);//Si il y a eu une erreure, on rejete la promesse. | |
if(arguments.length>2) { //Si il y a plus de 2 valeur retourné au callback, on renvoie un array. | |
result = arguments.splice(0,1); | |
} | |
succed(result); |
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 getVideoStream(succes, reject) { | |
navigator.getMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia || | |
navigator.mozGetUserMedia || navigator.msGetUserMedia); | |
if (navigator.getMedia) { | |
navigator.getMedia({video: true, audio: true}, function(stream) { | |
var video = document.createElement("video"); | |
video.src = window.URL.createObjectURL(stream); | |
video.autoplay = true; | |
succes(video); |