diff --git a/foozy.html b/foozy.html index fa10130..97bafdc 100644 --- a/foozy.html +++ b/foozy.html @@ -27,20 +27,10 @@ return false; }); - $("#sort_hue").click(function() { - lol.displayHue(); - return false; - }); - - $("#sort_sat").click(function() { - lol.displaySat(); - return false; - }); - - $("#sort_val").click(function() { - lol.displayBright(); - return false; - }); + $("#sort_reset").click( function() { lol.displayImg(); return false; }); + $("#sort_hue").click( function() { lol.displayHue(); return false; }); + $("#sort_sat").click( function() { lol.displaySat(); return false; }); + $("#sort_val").click( function() { lol.displayBright(); return false; }); }); @@ -79,6 +69,7 @@

+ Reset Sort by Hue Saturation Brightness diff --git a/js/franz.js b/js/franz.js index 6537859..282adf5 100644 --- a/js/franz.js +++ b/js/franz.js @@ -46,7 +46,7 @@ var franz = function(franzProps) { var that = this; franz.util.loadEvent(function() { document.body.appendChild(that.canvas); - that.draw(); + typeof that.canvas_id !== 'undefined' ? that.draw(that.canvas_id) : that.draw(); if(typeof franzProps.callback !== "undefined" && typeof franzProps.callback === "function") franzProps.callback(); }); } else { @@ -83,7 +83,6 @@ franz.prototype = { rgba: [], hsb: [], hsl: [], - origIndex: [], extra_canvas: null, extra_ctx: null, @@ -94,7 +93,7 @@ franz.prototype = { this.extra_canvas = document.getElementById(different_canvas); this.extra_ctx = this.extra_canvas.getContext('2d'); } - + var working = this; working.img = new Image(); working.img.onload = function() { @@ -108,7 +107,7 @@ franz.prototype = { /* If you're looking for the non- portion of this, check the associated Flash files. */ var hidden_canvas = document.getElementById("lol_hidden"), extra_ctx = hidden_canvas.getContext('2d'); - + extra_ctx.drawImage(this.img, 0, 0, 33, 33); var imageData = extra_ctx.getImageData(1, 1, 32, 32).data; @@ -141,11 +140,15 @@ franz.prototype = { }, displayColors: function(order_array) { - console.log("displaying colors"); var docStr = ""; - - for(var i = 0; i < this.rgba.length; i++) { - docStr += '

'; + if (typeof order_array === 'undefined'){ + for(var i = 0; i < this.rgba.length; i++) { + docStr += '
'; + } + } else { + for(var i = 0; i < this.rgba.length; i++) { + docStr += '
'; + } } document.getElementById("log_colors").innerHTML = docStr; @@ -159,14 +162,19 @@ franz.prototype = { }, displayImg: function() { - this.resetIndex(); - this.displayColors(this.origIndex); + this.displayColors(); return false; }, - displayHue: function() { this.sortArray(this.hsb,0); }, - displaySat: function() { this.sortArray(this.hsb,1); }, - displayBright: function() { this.sortArray(this.hsb,2); }, + displayHue: function() { this.sortArray(this.hsb,0); this.displayOut(this.hsb); }, + displaySat: function() { this.sortArray(this.hsb,1); this.displayOut(this.hsb);}, + displayBright: function() { this.sortArray(this.hsb,2); this.displayOut(this.hsb);}, + displayOut: function(array) { + var index = []; + for(var i=0;i hsb[] = [h,s,b,index][] @@ -176,11 +184,6 @@ franz.prototype = { */ sortArray: function(array,position) { array.sort(function(a,b){ return a[position] - b[position]; }); - - var index = []; - for(var i=0;i