PhotoDa Image Generator

I created an IOS app that creates images from existing things in your camera.

check it out:



ES6 Mode Mouse Event Manager

let ui = {
  ['draw-poly-mousedown'](e) {
    console.log('draw poly mouse down');
  ['draw-poly-mouseup'](e) {
    console.log('draw poly mouse up');
  execMode(e) {
    let fn = ui[`${ui.mode}-${e.type}`];
    if (fn) fn(e);
ui.mode = 'draw-poly';

let e = {};
e.mousedown = 
e.mouseup = 
e.mousemove = (e) => ui.execMode(e);

XOR Color Invert

var color = 0xFFFF00;

function toHex(color) { 
  return '#' + ('000000' + color.toString(16)).substr(-6);

function onClick() {
  color ^= 0xFFFFFF; = toHex(color);


document.addEventListener('click', onClick);

Have a look at the slighty different ES6 version:

This is a great trick and a good reason to learn XOR and binary if you don’t already know about those things. The `toHex` function is also kind of snippet worthy in itself.