--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flowsnake.css Sat Nov 09 23:28:20 2013 +0900
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flowsnake.js Sat Nov 09 23:28:20 2013 +0900
+Flowsnake = function($el, width, height, order) {
+ this.x = this.width / 2;
+ function fillrow(len) {
+ for (var i = 0; i < len; i++) {
+ for (var i = 0; i < this.height; i++) {
+ this.rows.push(fillrow(this.width));
+ for (var i = 0; i < this.order; i++) {
+ this.rule = this.rule.replace(/a/g, 'x').replace(/b/g, 'y').replace(/x/g, this.a).replace(/y/g, this.b);
+ putc: function(x, y, c) {
+ function replacec(str, pos, c) {
+ return str.substr(0, pos) + c + str.substr(pos + c.length);
+ if (x >= 0 && x < this.width && y >= 0 && y < this.height) {
+ this.rows[y] = replacec(this.rows[y], x, c);
+ this.putc(this.x, this.y, '__');
+ this.putc(this.x, this.y, '/');
+ this.putc(this.x, this.y, '\\');
+ this.putc(this.x, this.y, '__');
+ this.putc(this.x, this.y, '/');
+ this.putc(this.x, this.y, '\\');
+ step: function(visible) {
+ switch (this.rule[this.pointer]) {
+ this.angle = (this.angle + 60 + 360) % 360;
+ this.angle = (this.angle - 60 + 360) % 360;
+ if (this.pointer < this.rule.length) {
+ this.$el.text(this.rows.join('\n'));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/index.html Sat Nov 09 23:28:20 2013 +0900
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Flowsnake</title>
+ <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.3.0/pure-nr-min.css">
+ <link rel="stylesheet" href="flowsnake.css">
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
+ <script src="flowsnake.js"></script>
+ var flowsnake = new Flowsnake($('pre'), 160, 80, 3);
+ $('pre').css({'left': '50%', 'margin-left': - $('pre').width() / 2});
+ window.setInterval(function() {