diff --git a/index.html b/index.html index d50e1c7..cd01435 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,10 @@

Upload an image

-

+

+ Continue → + reGlitch → +

diff --git a/package.json b/package.json index 31618a4..aab4baf 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", + "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "GPL3", @@ -13,7 +13,7 @@ "data-uri-to-buffer": "0.0.3", "express": "^4.8.2", "glitch-jpg": "^1.0.3", - "nconf": "^0.6.9", + "nconf": "^0.6.9" }, "devDependencies": { "nodemon": "^1.2.1" diff --git a/public/css/main.css b/public/css/main.css index d7ce46c..eb78906 100644 --- a/public/css/main.css +++ b/public/css/main.css @@ -1,4 +1,6 @@ body { + background: url('../noise.png'); + background-size: cover; width: 100%; margin: 0; font-family: monospace, sans-serif; @@ -23,18 +25,23 @@ img { } .msbtn { + text-decoration: none; + color: black; margin-bottom: 10px; padding: 4px; border-radius: 2px; border-bottom: 2px solid #000; - border-right: 2px solid #000; - border-top: 2px solid #FFF; + border-right: 2px solid #000; border-top: 2px solid #FFF; background: #EBE8D9; border-left: 2px solid #FFF; } -.ms-btn:first-letter { - text-decoration: underline; +.msbtn::first-letter { + text-decoration: underline !important; +} + +.resubmit { + display: none; } .kill { diff --git a/public/js/bundle.js b/public/js/bundle.js deleted file mode 100644 index 3aa528e..0000000 --- a/public/js/bundle.js +++ /dev/null @@ -1,404 +0,0 @@ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { - var fn = queue.shift(); - fn(); - } - } - }, true); - - return function nextTick(fn) { - queue.push(fn); - window.postMessage('process-tick', '*'); - }; - } - - return function nextTick(fn) { - setTimeout(fn, 0); - }; -})(); - -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -} - -// TODO(shtylman) -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; - -},{}],"/home/meandave/Code/glitch-fork/node_modules/raf/index.js":[function(require,module,exports){ -var now = require('performance-now') - , global = typeof window === 'undefined' ? {} : window - , vendors = ['moz', 'webkit'] - , suffix = 'AnimationFrame' - , raf = global['request' + suffix] - , caf = global['cancel' + suffix] || global['cancelRequest' + suffix] - , native = true - -for(var i = 0; i < vendors.length && !raf; i++) { - raf = global[vendors[i] + 'Request' + suffix] - caf = global[vendors[i] + 'Cancel' + suffix] - || global[vendors[i] + 'CancelRequest' + suffix] -} - -// Some versions of FF have rAF but not cAF -if(!raf || !caf) { - native = false - - var last = 0 - , id = 0 - , queue = [] - , frameDuration = 1000 / 60 - - raf = function(callback) { - if(queue.length === 0) { - var _now = now() - , next = Math.max(0, frameDuration - (_now - last)) - last = next + _now - setTimeout(function() { - var cp = queue.slice(0) - // Clear queue here to prevent - // callbacks from appending listeners - // to the current frame's queue - queue.length = 0 - for(var i = 0; i < cp.length; i++) { - if(!cp[i].cancelled) { - try{ - cp[i].callback(last) - } catch(e) { - setTimeout(function() { throw e }, 0) - } - } - } - }, Math.round(next)) - } - queue.push({ - handle: ++id, - callback: callback, - cancelled: false - }) - return id - } - - caf = function(handle) { - for(var i = 0; i < queue.length; i++) { - if(queue[i].handle === handle) { - queue[i].cancelled = true - } - } - } -} - -module.exports = function(fn) { - // Wrap in a new function to prevent - // `cancel` potentially being assigned - // to the native rAF function - if(!native) { - return raf.call(global, fn) - } - return raf.call(global, function() { - try{ - fn.apply(this, arguments) - } catch(e) { - setTimeout(function() { throw e }, 0) - } - }) -} -module.exports.cancel = function() { - caf.apply(global, arguments) -} - -},{"performance-now":"/home/meandave/Code/glitch-fork/node_modules/raf/node_modules/performance-now/lib/performance-now.js"}],"/home/meandave/Code/glitch-fork/node_modules/raf/node_modules/performance-now/lib/performance-now.js":[function(require,module,exports){ -(function (process){ -// Generated by CoffeeScript 1.6.3 -(function() { - var getNanoSeconds, hrtime, loadTime; - - if ((typeof performance !== "undefined" && performance !== null) && performance.now) { - module.exports = function() { - return performance.now(); - }; - } else if ((typeof process !== "undefined" && process !== null) && process.hrtime) { - module.exports = function() { - return (getNanoSeconds() - loadTime) / 1e6; - }; - hrtime = process.hrtime; - getNanoSeconds = function() { - var hr; - hr = hrtime(); - return hr[0] * 1e9 + hr[1]; - }; - loadTime = getNanoSeconds(); - } else if (Date.now) { - module.exports = function() { - return Date.now() - loadTime; - }; - loadTime = Date.now(); - } else { - module.exports = function() { - return new Date().getTime() - loadTime; - }; - loadTime = new Date().getTime(); - } - -}).call(this); - -/* -//@ sourceMappingURL=performance-now.map -*/ - -}).call(this,require('_process')) -},{"_process":"/home/meandave/Code/glitch-fork/node_modules/browserify/node_modules/process/browser.js"}],"/home/meandave/Code/glitch-fork/node_modules/spatial-noise/node_modules/float-bits/bits.js":[function(require,module,exports){ -"use strict" - -var FLOAT_VIEW = new Float32Array(1) - , INT_VIEW = new Int32Array(FLOAT_VIEW.buffer) - , UINT_VIEW = new Uint32Array(FLOAT_VIEW.buffer) - -function floatToInt(x) { - FLOAT_VIEW[0] = x - return INT_VIEW[0] -} - -function intToFloat(x) { - INT_VIEW[0] = x - return FLOAT_VIEW[0] -} - -function floatToUint(x) { - FLOAT_VIEW[0] = x - return UINT_VIEW[0] -} - -function uintToFloat(x) { - UINT_VIEW[0] = x - return FLOAT_VIEW[0] -} - -module.exports = floatToInt -module.exports.toInt = floatToInt -module.exports.fromInt = intToFloat -module.exports.toUint = floatToUint -module.exports.fromUint = uintToFloat -},{}],"/home/meandave/Code/glitch-fork/node_modules/spatial-noise/node_modules/hash-int/hashint.js":[function(require,module,exports){ -"use strict" - -var A -if(typeof Uint32Array === undefined) { - A = [ 0 ] -} else { - A = new Uint32Array(1) -} - -function hashInt(x) { - A[0] = x|0 - A[0] -= (A[0]<<6) - A[0] ^= (A[0]>>>17) - A[0] -= (A[0]<<9) - A[0] ^= (A[0]<<4) - A[0] -= (A[0]<<3) - A[0] ^= (A[0]<<10) - A[0] ^= (A[0]>>>15) - return A[0] -} - -module.exports = hashInt - -},{}],"/home/meandave/Code/glitch-fork/node_modules/spatial-noise/prng.js":[function(require,module,exports){ -"use strict" - -var hashInt = require("hash-int") - , float2Int = require("float-bits").toInt - , UINT_MAX = 4294967295.0 - , HASH_CONSTANT = 0x7997F879 - , DOUBLE_VIEW = new Float64Array(1) - , INT_VIEW = new Uint32Array(DOUBLE_VIEW.buffer) - -function hashDouble(x, y) { - DOUBLE_VIEW[0] = +x - return hashInt(INT_VIEW[0] + hashInt(INT_VIEW[1]+y)) -} - -function noise1f(x) { - return (+(hashInt(float2Int(x)+HASH_CONSTANT)>>>0)) / UINT_MAX -} - -function noise2f(x, y) { - return (+(hashInt(float2Int(y)+hashInt(float2Int(x)+HASH_CONSTANT))>>>0)) / UINT_MAX -} - -function noise3f(x,y,z) { - return (+(hashInt(float2Int(z)+hashInt(float2Int(y)+hashInt(float2Int(x)+HASH_CONSTANT)))>>>0)) / UINT_MAX -} - -function noise4f(x,y,z,t) { - return (+(hashInt(float2Int(t)+hashInt(float2Int(z)+hashInt(float2Int(y)+hashInt(float2Int(x)+HASH_CONSTANT)))>>>0))) / UINT_MAX -} - -function noiseNf() { - var n = arguments.length - , r = HASH_CONSTANT - for(var i=0; i>>0) / UINT_MAX -} - -function noise2d(x, y) { - return +(hashDouble(y, hashDouble(x, HASH_CONSTANT))>>>0) / UINT_MAX -} - -function noise3d(x, y, z) { - return +(hashDouble(z, hashDouble(y, hashDouble(x, HASH_CONSTANT)))>>>0) / UINT_MAX -} - -function noise4d(x, y, z, t) { - return +(hashDouble(t, hashDouble(z, hashDouble(y, hashDouble(x, HASH_CONSTANT))))>>>0) / UINT_MAX -} - -function noiseNd() { - var n = arguments.length - , r = HASH_CONSTANT - for(var i=0; i>>0) / UINT_MAX -} - -module.exports = noiseNd -module.exports.noise1d = noise1d -module.exports.noise2d = noise2d -module.exports.noise3d = noise3d -module.exports.noise4d = noise4d -module.exports.noiseNd = noiseNd -module.exports.noise1f = noise1f -module.exports.noise2f = noise2f -module.exports.noise3f = noise3f -module.exports.noise4f = noise4f -module.exports.noiseNf = noiseNf - -},{"float-bits":"/home/meandave/Code/glitch-fork/node_modules/spatial-noise/node_modules/float-bits/bits.js","hash-int":"/home/meandave/Code/glitch-fork/node_modules/spatial-noise/node_modules/hash-int/hashint.js"}],"/home/meandave/Code/glitch-fork/public/js/main.js":[function(require,module,exports){ -var sn = require("spatial-noise"); -var raf = require('raf'); - -var file = document.querySelector('input[type=file]'); -var submitBtn = document.querySelector('.submit') -var killswitch = document.querySelector('.kill'); - -var img = document.createElement('img'); -var canvas = document.createElement("canvas"); -canvas.id = 'noise'; -canvas.width = window.innerWidth; -canvas.height = window.innerHeight; -document.body.appendChild(canvas) - -var context = canvas.getContext("2d") -var pixels = context.getImageData(0, 0, canvas.width, canvas.height) - -var payload = {} -var killed = false; - -var noiseInterval = setInterval(function() { - var spread = Math.floor(Math.random()*20); - killswitch.style['box-shadow'] = '11px 2px 15px '+spread+'px #FE0C0C'; -}, 500); - -var submitHandler = function(e){ - e.preventDefault() - var xhr = new XMLHttpRequest() - xhr.onreadystatechange = function(){ - var parsed; - if (xhr.readyState === 4) { - parsed = JSON.parse(xhr.responseText) - img.src = parsed.content; - } - } - xhr.open('POST', '/service') - xhr.setRequestHeader('Content-Type', 'application/json') - if (payload.content) xhr.send(JSON.stringify(payload)); -} - -var fileHandler = function(e) { - var reader = new FileReader() - reader.onloadend = function() { - document.querySelector('header').appendChild(img); - img.src = reader.result - payload.content = reader.result - console.log(payload) - } - - if (!~e.target.files[0].type.indexOf("image")) { - alert('Nah, this is for images'); - } else { - reader.readAsDataURL(e.target.files[0]); - } -} - -// spatial noise background -raf(function update(dt) { - var ptr = 0 - , t = Date.now() - for(var i=0; i