Skip to content

Instantly share code, notes, and snippets.

@kevlened
Last active August 29, 2015 14:16
Show Gist options
  • Save kevlened/b4b8cfbbbaf17a93d4c3 to your computer and use it in GitHub Desktop.
Save kevlened/b4b8cfbbbaf17a93d4c3 to your computer and use it in GitHub Desktop.
Create a double helix in the terminal - http://jsfiddle.net/1ykp03kw/2/
// Open the console to watch
// http://jsfiddle.net/1ykp03kw/2/
var left = 'color:#6A287E'; // Dark purple
var right = 'color:#7F38EC'; // Light purple
var A = 'color:#736AFF'; // Blue
var T = 'color:#F5FF6B'; // Yellow
var G = 'color:#4CC417'; // Green
var C = 'color:#E42217'; // Red
var pairs = [[A, T], [C, G]];
var helix = [
" %cO ",
" %co%c=%cO ",
" %c0%c=%c==%c0 ",
"\xA0 %c0%c=%c==%c0 ",
" %cO%c=%co "
];
function getRand() {
return Math.round(Math.random());
}
var i = 0;
function showHelix() {
i = i%5;
switch(i) {
case 0:
right = [left, left = right][0];
console.log(helix[i], right);
break;
case 2:
case 3:
var pair = pairs[getRand()];
var which = getRand();
console.log(helix[i], left, pair[which], pair[which ? 0 : 1], right);
break;
case 1:
case 4:
var base = pairs[getRand()][getRand()];
console.log(helix[i], left, base, right);
}
i++;
}
setInterval(showHelix, 275);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment