diff --git a/css/example.css b/css/example.css index e272d92..63b04ce 100644 --- a/css/example.css +++ b/css/example.css @@ -112,7 +112,7 @@ a:hover { text-decoration: underline; } width: 370px; } -.img_submit, #hsv a, #hsl a { +.img_submit, #hsv a, #hsl a, a.effect_button { border: 1px solid #55a2c9; background-color: #498fb2; color: #fff; @@ -121,7 +121,7 @@ a:hover { text-decoration: underline; } -webkit-border-radius: 4px; } -#hsv a, #hsl a { +#hsv a, #hsl a, a.effect_button { display: block; width: 105px; padding: 3px 0; @@ -130,13 +130,21 @@ a:hover { text-decoration: underline; } margin-right: 10px; text-decoration: none; } - +a.effect_button { + padding: 0; +} #options a:last-child { margin-right: 0px; } #try_these { clear: both; } +#core_function { + clear: both; + padding-top: 10px; + font: 1.2em/1.5em helvetica,sans-serif; +} + #logHSV { border-top: 1px solid #6D7985; clear: both; diff --git a/foozy.html b/foozy.html index 97bafdc..803b67e 100644 --- a/foozy.html +++ b/foozy.html @@ -31,6 +31,13 @@ $("#sort_hue").click( function() { lol.displayHue(); return false; }); $("#sort_sat").click( function() { lol.displaySat(); return false; }); $("#sort_val").click( function() { lol.displayBright(); return false; }); + $("#display_gradient").click( function() { + var hex1 = window.prompt("Enter the first color (hexidemical)"); + var hex2 = window.prompt("Enter the second color (hexidemical)"); + if (!hex1 || !hex2) return false; + + franz.prototype.displayColors(franz.util.getGradient(franz.util.HextoRGB(hex1),franz.util.HextoRGB(hex2),32*32)) + }); }); @@ -61,7 +68,14 @@ 1600.jpg, fallout.jpg

- + + +
+

Franz core functionality (not canvas related): +

+ Get Gradient +
+

diff --git a/js/franz.js b/js/franz.js index 282adf5..868976b 100644 --- a/js/franz.js +++ b/js/franz.js @@ -139,14 +139,14 @@ franz.prototype = { } else { return false; } }, - displayColors: function(order_array) { + displayColors: function(color_array, order_array) { var docStr = ""; if (typeof order_array === 'undefined'){ - for(var i = 0; i < this.rgba.length; i++) { - docStr += '
'; + for(var i = 0; i < color_array.length; i++) { + docStr += '
'; } } else { - for(var i = 0; i < this.rgba.length; i++) { + for(var i = 0; i < color_array.length; i++) { docStr += '
'; } } @@ -162,7 +162,7 @@ franz.prototype = { }, displayImg: function() { - this.displayColors(); + this.displayColors(this.rgba); return false; }, @@ -172,7 +172,7 @@ franz.prototype = { displayOut: function(array) { var index = []; for(var i=0;i i*step) && (inputArray[j] < i*step + interval)){ - count++; - } - } - densityArray[i] = count; - } - - return densityArray; - } + } } franz.util = { @@ -269,6 +248,43 @@ franz.util = { return '#' + hex.join(''); }, + HextoRGB: function(h) { + if (h.charAt(0)=="#") h = h.substring(1,7); + return [parseInt(h.substring(0,2),16), parseInt(h.substring(2,4),16),parseInt(h.substring(4,6),16)]; + }, + + /* Sample call: lol.displayColors(franz.util.getGradient([255,0,0],[255,255,0],32*32)) */ + getGradient: function(rgb1,rgb2,steps) { + var grad = new Array(); + var rgbSlope = [(rgb2[0]-rgb1[0])/steps,(rgb2[1]-rgb1[1])/steps,(rgb2[2]-rgb1[2])/steps]; + + for(var i=0; i i*step) && (inputArray[j] < i*step + interval)){ + count++; + } + } + densityArray[i] = count; + } + + return densityArray; + }, + clone: function(obj) { /* Utility function for deep cloning */ if(typeof obj !== "undefined") {