--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sierpinski.js Sat Mar 12 22:33:23 2016 +0800
+// Generated by CoffeeScript 1.10.0
+ extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
+ hasProp = {}.hasOwnProperty;
+ function L($el, width, height, order) {
+ L.prototype.init = function() {
+ var fillrow, i, j, ref, ref1;
+ fillrow = function(len) {
+ for (i = 1, ref = len; 1 <= ref ? i <= ref : i >= ref; 1 <= ref ? i++ : i--) {
+ for (i = 1, ref = this.height; 1 <= ref ? i <= ref : i >= ref; 1 <= ref ? i++ : i--) {
+ this.rows.push(fillrow(this.width));
+ for (j = 1, ref1 = this.order; 1 <= ref1 ? j <= ref1 : j >= ref1; 1 <= ref1 ? j++ : j--) {
+ this.rule = this.rule.replace(/a/g, 'x').replace(/b/g, 'y').replace(/x/g, this.a).replace(/y/g, this.b);
+ L.prototype.putc = function(x, y, c) {
+ replacec = function(str, pos, c) {
+ return str.substr(0, pos) + c + str.substr(pos + c.length);
+ if ((0 <= x && x < this.width) && (0 <= y && y < this.height)) {
+ this.rows[y] = replacec(this.rows[y], x, c);
+ L.prototype.line = function() {
+ 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, '\\');
+ L.prototype.step = function(visible) {
+ if (this.pointer >= this.rule.length) {
+ switch (this.rule[this.pointer]) {
+ this.angle = (this.angle + 60 + 360) % 360;
+ this.angle = (this.angle - 60 + 360) % 360;
+ L.prototype.draw = function() {
+ return this.$el.text(this.rows.join('\n'));
+ window.Sierpinski = (function(superClass) {
+ extend(Sierpinski, superClass);
+ function Sierpinski() {
+ return Sierpinski.__super__.constructor.apply(this, arguments);
+ Sierpinski.prototype.a = 'b-a-b';
+ Sierpinski.prototype.b = 'a+b+a';
+ Sierpinski.prototype.init = function() {
+ this.x = this.width - 2;
+ this.y = this.height - 2;
+ return Sierpinski.__super__.init.apply(this, arguments);
+ window.Flowsnake = (function(superClass) {
+ extend(Flowsnake, superClass);
+ return Flowsnake.__super__.constructor.apply(this, arguments);
+ Flowsnake.prototype.a = 'a-b--b+a++aa+b-';
+ Flowsnake.prototype.b = '+a-bb--b-a++a+b';
+ Flowsnake.prototype.init = function() {
+ this.x = this.width / 2;
+ return Flowsnake.__super__.init.apply(this, arguments);