Some old stuff I had laying around in a work folder - massive refactoring ahoy
This commit is contained in:
parent
595abe62c6
commit
8e985309ff
5 changed files with 228 additions and 299 deletions
104
foozy.html
Normal file
104
foozy.html
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Franz - client side color palettes from logos</title>
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="css/example.css">
|
||||
<script type="text/javascript" src="http://images.webs.com/static/global/js/jquery/jquery-1.3.2.min.js"></script>
|
||||
<script type="text/javascript" src="js/franz.js"></script>
|
||||
<script type="text/javascript">
|
||||
var lol;
|
||||
|
||||
$(document).ready(function() {
|
||||
lol = new franz({
|
||||
canvas: "lol",
|
||||
src: "awesome/lol.png",
|
||||
callback: function() {
|
||||
console.log("Instantiated new Franz instance");
|
||||
}
|
||||
});
|
||||
|
||||
$("#sort_hue").click(function() {
|
||||
franz.displayHue();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#sort_sat").click(function() {
|
||||
franz.displaySat();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#sort_val").click(function() {
|
||||
franz.displayVal();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#sort_light").click(function() {
|
||||
franz.displayLight();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#sort_satL").click(function() {
|
||||
franz.displaySatL();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Franz - client side color swatches</h1>
|
||||
|
||||
<div id="container_top">
|
||||
<a href="#" title="Upload an image" id="upload_button">Upload an image</a>
|
||||
<div id="lol_container">
|
||||
<canvas id="lol" width="100" height="100"></canvas>
|
||||
<canvas id="lol_hidden" width="33" height="33"></canvas>
|
||||
</div>
|
||||
|
||||
<div id="interface">
|
||||
<form id="uploader" name="uploader" method="post" action="upload.php" enctype="multipart/form-data">
|
||||
<input id="file" type="file" name="dragonfruit">
|
||||
<input type="submit" class="img_submit" value="Upload and be awesome">
|
||||
</form>
|
||||
<form method="post" action="#" id="franz_form">
|
||||
<input type="text" id="img_input" value="awesome/lol.png">
|
||||
<input type="submit" class="img_submit" value="Go for it!">
|
||||
</form>
|
||||
<p id="try_these"><strong>Try out:</strong>
|
||||
<a href="#" title="awesome/lol.png">lol.png</a>,
|
||||
<a href="#" title="awesome/testjubs.jpg">testjubs.jpg</a>,
|
||||
<a href="#" title="awesome/stars.jpg">stars.jpg</a>,
|
||||
<a href="#" title="awesome/1600.jpg">1600.jpg</a>,
|
||||
<a href="#" title="awesome/fallout.jpg">fallout.jpg</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<canvas id="lol_texture" width="50" height="50" style="visibility: hidden; position: absolute; top: 0px; left: 0px;"></canvas>
|
||||
|
||||
<div id="options">
|
||||
<p id="hsv">
|
||||
<a href="#" id="sort_hue" title="Sort by Hue">Sort by Hue</a>
|
||||
<a href="#" id="sort_sat" title="Sort by Saturation HSV">Saturation (HSV)</a>
|
||||
<a href="#" id="sort_satL" title="Sort by Saturation HSL">Saturation (HSL)</a>
|
||||
<a href="#" id="sort_val" title="Sort by Value">Value (HSV)</a>
|
||||
<a href="#" id="sort_light" title="Sort by Lightness">Lightness (HSL)</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="container_bottom">
|
||||
<div id="log_colors">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p id="footer">
|
||||
This experiment was brought to you in Technicolor (get it?) by <a href="http://twitter.com/ryanmcgrath" title="Ryan McGrath">Ryan McGrath</a> & <a href="http://twitter.com/enotionz" title="Dominick Pham">Dominick Pham</a>,
|
||||
two of the most awesome people you'll ever hear about. If you're interested in helping out,
|
||||
hit up Franz on <a href="http://github.com/ryanmcgrath/franz/tree/master" title="Franz on GitHub">GitHub</a>!
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
218
index2.php
218
index2.php
|
|
@ -1,218 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Franz - client side color palettes from logos</title>
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="css/example.css">
|
||||
<script type="text/javascript" src="http://images.webs.com/static/global/js/jquery/jquery-1.3.2.min.js"></script>
|
||||
<script type="text/javascript" src="js/franz.js"></script>
|
||||
<script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script>
|
||||
<script type="text/javascript">
|
||||
var img_input,
|
||||
layoutMods,
|
||||
selectedColor,
|
||||
previewMainBG,
|
||||
previewBannerBG,
|
||||
previewContentBG,
|
||||
previewSidebarBG,
|
||||
previewFooterBG;
|
||||
|
||||
/* Oh god a global function wrrrryyyy */
|
||||
function lol() {
|
||||
franz.loadImg(img_input.value);
|
||||
$("#options").fadeIn("fast");
|
||||
return false;
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
layoutMods = $("#layoutMods");
|
||||
previewMainBG = $("#testLayout");
|
||||
previewBannerBG = $("#testBanner");
|
||||
previewContentBG = $("#testContent");
|
||||
previewSidebarBG = $("#testSidebar");
|
||||
previewFooterBG = $("#testFooter");
|
||||
franz.init("lol");
|
||||
|
||||
img_input = document.getElementById("img_input");
|
||||
$("#franz_form").submit(lol);
|
||||
|
||||
$("#upload_button").click(function() {
|
||||
var f_form = $("#franz_form"),
|
||||
uploader = $("#uploader");
|
||||
|
||||
if(f_form[0].style.display == "none") {
|
||||
uploader.hide();
|
||||
f_form.fadeIn("slow");
|
||||
$(this).html("Upload an image");
|
||||
} else {
|
||||
f_form.hide();
|
||||
uploader.fadeIn("slow");
|
||||
$(this).html("Use an existing image?");
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#try_these a").click(function() {
|
||||
img_input.value = "awesome/" + $(this)[0].innerHTML;
|
||||
return false;
|
||||
});
|
||||
|
||||
<?php /* This hack sucks, but it's worth it for right now. -- Ryan */
|
||||
if($_REQUEST["image"])
|
||||
echo 'img_input.value = "awesome/' . $_REQUEST["image"] . '"; lol();';
|
||||
?>
|
||||
|
||||
$("#sort_hue").click(function() {
|
||||
franz.displayHue();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#sort_sat").click(function() {
|
||||
franz.displaySat();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#sort_val").click(function() {
|
||||
franz.displayVal();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#sort_light").click(function() {
|
||||
franz.displayLight();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#sort_satL").click(function() {
|
||||
franz.displaySatL();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#setMainBG").click(function() {
|
||||
previewMainBG.css({"background-color": selectedColor});
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#setHeaderBG").click(function() {
|
||||
previewBannerBG.css({"background-color": selectedColor});
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#setContentBG").click(function() {
|
||||
previewContentBG.css({"background-color": selectedColor});
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#setFooterBG").click(function() {
|
||||
previewFooterBG.css({"background-color": selectedColor});
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#setSidebarBG").click(function() {
|
||||
previewSidebarBG.css({"background-color": selectedColor});
|
||||
return false;
|
||||
});
|
||||
|
||||
$(".color_boxd").live("mousedown", function(e) {
|
||||
// Yes, this function is horribly un-optimized. It's 4AM, we'll clean it up later. ;P
|
||||
selectedColor = franz.RGBtoHex($(this)[0].style.backgroundColor.replace(")", "").replace("rgb(", "").replace(" ", "").split(","));
|
||||
var coords = {x: e.pageX, y: e.pageY};
|
||||
layoutMods.hide();
|
||||
layoutMods.css({"top": coords.y + "px", "left": coords.x + "px"});
|
||||
layoutMods.fadeIn("slow");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="layoutMods">
|
||||
<a href="#" id="setMainBG" title="Set as background color">Set as Main Background</a>
|
||||
<a href="#" id="setHeaderBG" title="Set as Header BG">Set as Header Background</a>
|
||||
<a href="#" id="setContentBG" title="Set as Content BG">Set as Content Background</a>
|
||||
<a href="#" id="setSidebarBG" title="Set as Sidebar BG">Set as Sidebar Background</a>
|
||||
<a href="#" id="setFooterBG" title="Set as Footer BG">Set as Footer Background</a>
|
||||
</div>
|
||||
|
||||
<div id="testLayout">
|
||||
<div id="testBanner">
|
||||
This is an example layout
|
||||
</div>
|
||||
<div id="testContent">
|
||||
<p>
|
||||
This is an example layout to test colors with.
|
||||
</p>
|
||||
<p>
|
||||
Click on a color to set it for one of these layout sections!
|
||||
</p>
|
||||
</div>
|
||||
<div id="testSidebar">
|
||||
Sidebar
|
||||
</div>
|
||||
<div id="testFooter">
|
||||
© lol enterprises
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h1>Franz - client side color swatches</h1>
|
||||
|
||||
<div id="container_top">
|
||||
<a href="#" title="Upload an image" id="upload_button">Upload an image</a>
|
||||
<div id="lol_container">
|
||||
<canvas id="lol" width="100" height="100"></canvas>
|
||||
<canvas id="lol_hidden" width="33" height="33"></canvas>
|
||||
</div>
|
||||
|
||||
<div id="interface">
|
||||
<form id="uploader" name="uploader" method="post" action="upload.php" enctype="multipart/form-data">
|
||||
<input id="file" type="file" name="dragonfruit">
|
||||
<input type="submit" class="img_submit" value="Upload and be awesome">
|
||||
</form>
|
||||
<form method="post" action="#" id="franz_form">
|
||||
<input type="text" id="img_input" value="awesome/lol.png">
|
||||
<input type="submit" class="img_submit" value="Go for it!">
|
||||
</form>
|
||||
<p id="try_these"><strong>Try out:</strong>
|
||||
<a href="#" title="awesome/lol.png">lol.png</a>,
|
||||
<a href="#" title="awesome/testjubs.jpg">testjubs.jpg</a>,
|
||||
<a href="#" title="awesome/stars.jpg">stars.jpg</a>,
|
||||
<a href="#" title="awesome/1600.jpg">1600.jpg</a>,
|
||||
<a href="#" title="awesome/fallout.jpg">fallout.jpg</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="options">
|
||||
<p id="hsv">
|
||||
<a href="#" id="sort_hue" title="Sort by Hue">Sort by Hue</a>
|
||||
<a href="#" id="sort_sat" title="Sort by Saturation HSV">Saturation (HSV)</a>
|
||||
<a href="#" id="sort_satL" title="Sort by Saturation HSL">Saturation (HSL)</a>
|
||||
<a href="#" id="sort_val" title="Sort by Value">Value (HSV)</a>
|
||||
<a href="#" id="sort_light" title="Sort by Lightness">Lightness (HSL)</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="container_bottom">
|
||||
<div id="log_colors">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p id="footer">
|
||||
This experiment was brought to you in Technicolor (get it?) by <a href="http://twitter.com/ryanmcgrath" title="Ryan McGrath">Ryan McGrath</a> & <a href="http://twitter.com/enotionz" title="Dominick Pham">Dominick Pham</a>,
|
||||
two of the most awesome people you'll ever hear about. If you're interested in helping out,
|
||||
hit up Franz on <a href="http://github.com/ryanmcgrath/franz/tree/master" title="Franz on GitHub">GitHub</a>!
|
||||
|
||||
<br><br>
|
||||
Brought to you (in part) by <a href="http://webs.com/" title="Webs.com - get a free website!">Webs.com</a>, the company that employs Ryan and Dominick, and graciously
|
||||
lets them experiment like this at work.
|
||||
</p>
|
||||
|
||||
<script type="text/javascript">
|
||||
try { var pageTracker = _gat._getTracker("UA-9252411-2"); pageTracker._trackPageview(); } catch(err) {}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
BIN
js/expressInstall.swf
Normal file
BIN
js/expressInstall.swf
Normal file
Binary file not shown.
197
js/franz.js
197
js/franz.js
|
|
@ -4,8 +4,6 @@
|
|||
* @Author Dominick Pham (http://twitter.com/enotionz)
|
||||
*/
|
||||
|
||||
/* Define some basic prototypes that we'll require later.. */
|
||||
|
||||
if(!Array.prototype.swap) {
|
||||
Array.prototype.swap = function(a, b) {
|
||||
var tmp = this[a];
|
||||
|
|
@ -15,15 +13,60 @@ if(!Array.prototype.swap) {
|
|||
}
|
||||
}
|
||||
|
||||
/* allows numeric sorting for built in js sort */
|
||||
function sortNumber(a,b) { return a - b;}
|
||||
var franz = function(franzProps) {
|
||||
/* new franz({
|
||||
canvas: "canvas_id",
|
||||
src: "image_src",
|
||||
callback: fn() { ... }
|
||||
});
|
||||
|
||||
/* Franz - this is where the magic happens, pay close attention. ;) */
|
||||
var franz = {
|
||||
canvas: {},
|
||||
ctx: {},
|
||||
img: {},
|
||||
Stores a reference to our canvas and the canvas context for future use. Accepts
|
||||
an optional callback function to tie this into further methods.
|
||||
|
||||
Note: Since there's no way to get the type of <canvas> support we need in Internet Explorer,
|
||||
we actually branch the codepath here - IE gets a small flash applet that handles pulling color data out. We additionally serve
|
||||
this if, for some reason, <canvas> support is lacking or broken in newer browser (or Firefox 2, etc).
|
||||
|
||||
The data is still parsed via JS by using externalInterface() callbacks into the Flash applet, so it's safe to
|
||||
assume that anything occuring after getColors() is back in global-browser-use land.
|
||||
*/
|
||||
this.canvas_id = franzProps.canvas;
|
||||
if(typeof document.getElementById(franzProps.canvas).getContext === "function") {
|
||||
/* Canvas is natively supported, go down the normal path... */
|
||||
this.canvas = document.getElementById(franzProps.canvas);
|
||||
this.ctx = this.canvas.getContext('2d');
|
||||
if(typeof franzProps.callback !== "undefined" && typeof franzProps.callback === "function") franzProps.callback();
|
||||
} else {
|
||||
/* We're dealing with something that belongs in an old folks home; throw in the life support. (Embed Flash junk) :(
|
||||
Inject SWFObject so we can deal with Flash embedding in a sane manner...
|
||||
*/
|
||||
if(typeof swfobject === "undefined") {
|
||||
var newScript = document.createElement("script");
|
||||
newScript.type = "text/javascript";
|
||||
newScript.src = "/js/swfobject.js";
|
||||
document.body.appendChild(newScript);
|
||||
|
||||
if(typeof franzProps.callback !== "undefined" && typeof franzProps.callback === "function") {
|
||||
// Catch the callback function for IE...
|
||||
newScript.onreadystatechange = function() {
|
||||
if(newScript.readyState == "loaded" || newScript.readyState == "complete") franzProps.callback();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Catch all other misguided browsers, just in case (Really old versions of Safari that don't have good <canvas> support will fail totally, but that's far too much to care about)
|
||||
newScript.onload = function() {
|
||||
franzProps.callback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// If swfobject was already appended once, just catch the callback and run
|
||||
if(typeof franzProps.callback !== "undefined" && typeof franzProps.callback === "function") franzProps.callback();
|
||||
}
|
||||
}
|
||||
|
||||
franz.prototype = {
|
||||
alpha: [],
|
||||
red: [],
|
||||
green: [],
|
||||
|
|
@ -37,59 +80,37 @@ var franz = {
|
|||
|
||||
origIndex: [],
|
||||
|
||||
init: function(canvas_id) {
|
||||
franz.canvas = document.getElementById(canvas_id);
|
||||
franz.ctx = franz.canvas.getContext('2d');
|
||||
return false;
|
||||
},
|
||||
|
||||
clone: function(obj) {
|
||||
if(typeof obj !== "undefined") {
|
||||
/* Recursively iterate through objects and clone them (Don't even try to put this on the Object prototype (recursion fail)) */
|
||||
var returnObj = (obj instanceof Array) ? [] : {};
|
||||
|
||||
for(i in obj) {
|
||||
if(i == 'clone') continue;
|
||||
if(obj[i] != null && typeof obj[i] == "object") {
|
||||
returnObj[i] = franz.clone(obj[i]);
|
||||
} else {
|
||||
returnObj[i] = obj[i];
|
||||
}
|
||||
}
|
||||
|
||||
return returnObj;
|
||||
}
|
||||
},
|
||||
|
||||
loadImg: function(img_src) {
|
||||
franz.img = new Image();
|
||||
franz.img.onload = function() {
|
||||
franz.ctx.drawImage(franz.img, 0, 0, 100, 100);
|
||||
setTimeout(function() { franz.getColors(); }, 100);
|
||||
/* If you're looking for the non-<canvas> portion of this, check the associated Flash files. */
|
||||
var working = this;
|
||||
working.img = new Image();
|
||||
working.img.onload = function() {
|
||||
working.ctx.drawImage(working.img, 0, 0, 100, 100);
|
||||
setTimeout(function() { working.getColors(); }, 100);
|
||||
}
|
||||
franz.img.src = img_src;
|
||||
return false;
|
||||
working.img.src = img_src;
|
||||
},
|
||||
|
||||
getColors: function() {
|
||||
/* If you're looking for the non-<canvas> portion of this, check the associated Flash files. */
|
||||
var hidden_canvas = document.getElementById("lol_hidden"),
|
||||
extra_ctx = hidden_canvas.getContext('2d');
|
||||
|
||||
extra_ctx.drawImage(franz.img, 0, 0, 33, 33);
|
||||
extra_ctx.drawImage(this.img, 0, 0, 33, 33);
|
||||
var imageData = extra_ctx.getImageData(1, 1, 32, 32).data;
|
||||
|
||||
for(var i = 0; i*4 < imageData.length; i++) {
|
||||
franz.red[i] = imageData[i*4];
|
||||
franz.green[i] = imageData[i*4 + 1];
|
||||
franz.blue[i] = imageData[i*4 + 2];
|
||||
franz.alpha[i] = imageData[i*4 + 3];
|
||||
this.red[i] = imageData[i*4];
|
||||
this.green[i] = imageData[i*4 + 1];
|
||||
this.blue[i] = imageData[i*4 + 2];
|
||||
this.alpha[i] = imageData[i*4 + 3];
|
||||
}
|
||||
|
||||
/* get hue sat val array */
|
||||
franz.RGBtoHSVHL();
|
||||
this.RGBtoHSVHL();
|
||||
|
||||
/* show original image */
|
||||
franz.displayImg();
|
||||
this.displayImg();
|
||||
|
||||
return false;
|
||||
},
|
||||
|
|
@ -98,13 +119,13 @@ var franz = {
|
|||
RGBtoHSVHL: function() {
|
||||
var min, max;
|
||||
|
||||
for(var i = 0; i < franz.alpha.length; i++) {
|
||||
franz.value[i] = franz.getValHSV(franz.red[i],franz.green[i],franz.blue[i]);
|
||||
franz.satV[i] = franz.getSatHSV(franz.red[i],franz.green[i],franz.blue[i]);
|
||||
franz.hue[i] = franz.getHue(franz.red[i],franz.green[i],franz.blue[i]);
|
||||
for(var i = 0; i < this.alpha.length; i++) {
|
||||
this.value[i] = this.getValHSV(this.red[i], this.green[i], this.blue[i]);
|
||||
this.satV[i] = this.getSatHSV(this.red[i], this.green[i], this.blue[i]);
|
||||
this.hue[i] = this.getHue(this.red[i], this.green[i], this.blue[i]);
|
||||
|
||||
franz.satL[i] = franz.getSatHSL(franz.red[i],franz.green[i],franz.blue[i]);
|
||||
franz.light[i] = franz.getLightHSL(franz.red[i],franz.green[i],franz.blue[i]);
|
||||
this.satL[i] = this.getSatHSL(this.red[i], this.green[i], this.blue[i]);
|
||||
this.light[i] = this.getLightHSL(this.red[i], this.green[i], this.blue[i]);
|
||||
}
|
||||
|
||||
return false
|
||||
|
|
@ -148,7 +169,7 @@ var franz = {
|
|||
getSatHSL: function(red, green, blue) {
|
||||
var min = Math.min(red, Math.min(green, blue)),
|
||||
max = Math.max(red, Math.max(green, blue)),
|
||||
lightness = franz.getLightHSL(),
|
||||
lightness = this.getLightHSL(),
|
||||
sat;
|
||||
|
||||
if(min == max) return 0;
|
||||
|
|
@ -166,10 +187,11 @@ var franz = {
|
|||
},
|
||||
|
||||
displayColors: function(order_array) {
|
||||
console.log("displaying colors");
|
||||
var docStr = "";
|
||||
|
||||
for(var i = 0; i < franz.alpha.length; i++) {
|
||||
docStr += '<div class="color_boxd" style="background-color: rgb(' + franz.red[order_array[i]] + ', ' + franz.green[order_array[i]] + ',' + franz.blue[order_array[i]] + ');"></div>';
|
||||
for(var i = 0; i < this.alpha.length; i++) {
|
||||
docStr += '<div class="color_boxd" style="background-color: rgb(' + this.red[order_array[i]] + ', ' + this.green[order_array[i]] + ',' + this.blue[order_array[i]] + ');"></div>';
|
||||
}
|
||||
|
||||
document.getElementById("log_colors").innerHTML = docStr;
|
||||
|
|
@ -182,48 +204,39 @@ var franz = {
|
|||
return false;
|
||||
},
|
||||
|
||||
resetIndex: function() {
|
||||
/* keep track of original index so we don't have to revert
|
||||
back to RGB just to display output */
|
||||
for (var i=0; i < franz.alpha.length; i++) {
|
||||
franz.origIndex[i] = i;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
displayImg: function() {
|
||||
franz.resetIndex();
|
||||
franz.displayColors(franz.origIndex);
|
||||
this.resetIndex();
|
||||
this.displayColors(this.origIndex);
|
||||
return false;
|
||||
},
|
||||
|
||||
displayHue: function() {
|
||||
franz.indexSort(franz.clone(franz.hue), 0, franz.alpha.length);
|
||||
franz.displayColors(franz.origIndex);
|
||||
this.indexSort(franz.util.clone(this.hue), 0, this.alpha.length);
|
||||
this.displayColors(this.origIndex);
|
||||
return false;
|
||||
},
|
||||
|
||||
displaySat: function() {
|
||||
franz.indexSort(franz.clone(franz.satV), 0, franz.alpha.length);
|
||||
franz.displayColors(franz.origIndex);
|
||||
this.indexSort(franz.util.clone(this.satV), 0, this.alpha.length);
|
||||
this.displayColors(this.origIndex);
|
||||
return false;
|
||||
},
|
||||
|
||||
displayVal: function() {
|
||||
franz.indexSort(franz.clone(franz.value), 0, franz.alpha.length);
|
||||
franz.displayColors(franz.origIndex);
|
||||
this.indexSort(franz.util.clone(this.value), 0, this.alpha.length);
|
||||
this.displayColors(this.origIndex);
|
||||
return false;
|
||||
},
|
||||
|
||||
displaySatL: function() {
|
||||
franz.indexSort(franz.clone(franz.satL), 0, franz.alpha.length);
|
||||
franz.displayColors(franz.origIndex);
|
||||
this.indexSort(franz.util.clone(this.satL), 0, this.alpha.length);
|
||||
this.displayColors(this.origIndex);
|
||||
return false;
|
||||
},
|
||||
|
||||
displayLight: function() {
|
||||
franz.indexSort(franz.clone(franz.light), 0, franz.alpha.length);
|
||||
franz.displayColors(franz.origIndex);
|
||||
this.indexSort(franz.util.clone(this.light), 0, this.alpha.length);
|
||||
this.displayColors(this.origIndex);
|
||||
return false;
|
||||
},
|
||||
|
||||
|
|
@ -242,7 +255,6 @@ var franz = {
|
|||
count++;
|
||||
}
|
||||
}
|
||||
console.log("frequency of values between " + i*step + " and " + (i*step + interval) + " = " + count);
|
||||
densityArray[i] = count;
|
||||
}
|
||||
|
||||
|
|
@ -251,18 +263,45 @@ var franz = {
|
|||
|
||||
/* bubble sort floats around and pops in your face */
|
||||
indexSort: function(inputArray, start, end) {
|
||||
franz.resetIndex();
|
||||
this.resetIndex();
|
||||
for (var i = start; i < end; i++) {
|
||||
for (var j = end-1; j >= start; j--) {
|
||||
var diff = inputArray[j] - inputArray[i]
|
||||
if (diff > 0) {
|
||||
inputArray.swap(i,j+1);
|
||||
franz.origIndex.swap(i,j+1);
|
||||
this.origIndex.swap(i,j+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
resetIndex: function() {
|
||||
/* keep track of original index so we don't have to revert back to RGB just to display output */
|
||||
for(var i = 0; i < this.alpha.length; i++) {
|
||||
this.origIndex[i] = i;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
franz.util = {
|
||||
clone: function(obj) {
|
||||
/* Utility function for deep cloning */
|
||||
if(typeof obj !== "undefined") {
|
||||
var returnObj = (obj instanceof Array) ? [] : {};
|
||||
|
||||
for(i in obj) {
|
||||
if(obj[i] != null && typeof obj[i] == "object") {
|
||||
returnObj[i] = franz.util.clone(obj[i]);
|
||||
} else {
|
||||
returnObj[i] = obj[i];
|
||||
}
|
||||
}
|
||||
|
||||
return returnObj;
|
||||
}
|
||||
},
|
||||
|
||||
RGBtoHex: function(rgb) {
|
||||
var hex = [];
|
||||
|
||||
|
|
|
|||
4
js/swfobject.js
Normal file
4
js/swfobject.js
Normal file
File diff suppressed because one or more lines are too long
Reference in a new issue