// creative commons copyright notice mathheadinclouds@stackoverflow goes here (please 'unzip' yourself)
var generateColor = (function(){
// alpha, beta, gamma must all be between 0 and 1,
// they must be irrational, and their respective ratios must be irrational also.
// further, when written as a continued fraction, the integer coefficients of that
// should be small, such as, all ones and twos. Then, with below method, you get
// a stream of colors which are "as different as possible to each other", loosely speaking.
var gamma = (Math.sqrt( 5)-1)/2;
var alpha = Math.sqrt(3) - 1;
var beta = Math.sqrt(2) - 1;
var brightnessFactor = 4; // the larger the brighter; for dark colors, make it less than 1
function _generateColor(index){
var n = 1 + index;
var nAlpha = n * alpha;
var nBeta = n * beta;
var nGamma = n * gamma;
var _r = nAlpha - Math.floor(nAlpha);
var _g = nBeta - Math.floor(nBeta);
var _b = nGamma - Math.floor(nGamma);
var expo = 1/brightnessFactor;
var _R = Math.pow(_r, expo);
var _G = Math.pow(_g, expo);
var _B = Math.pow(_b, expo);
var r = Math.floor(255.999999 * _R);
var g = Math.floor(255.999999 * _G);
var b = Math.floor(255.999999 * _B);
return 'rgb(' + [r,g,b].join(', ') + ')';
}
return _generateColor;
})();
var ast, codeContainer, analysis, colors, codeSpans, activeSpan, swatchesParent, CONSOLE;
colors = [];
function findPathAtPosition(pos){
var result = [];
function process(node){
result.push(node);
function isSubNode(key){
// caution/todo: I strongly suspect that there are one or more fringe cases
// I haven't considered, and this function is buggy. But it works most of the time ...
var child = node[key];
if (child===null) return false;
var ty = typeof child;
if (ty!=='object') return false;
if (child.constructor===Array) return ( key!=='range' );
if (child.constructor===RegExp) return false;
if (key==='loc') return false;
if ('type' in...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!