在JS中以螺旋形式存储像素的算法是什么?
http://www.mathematische-basteleien.de/spiral.htm
var Spiral = function(a) { this.initialize(a); } Spiral.prototype = { _a: 0.5, constructor: Spiral, initialize: function( a ) { if (a != null) this._a = a; }, /* specify the increment in radians */ points: function( rotations, increment ) { var maxAngle = Math.PI * 2 * rotations; var points = new Array(); for (var angle = 0; angle <= maxAngle; angle = angle + increment) { points.push( this._point( angle ) ); } return points; }, _point: function( t ) { var x = this._a * t * Math.cos(t); var y = this._a * t * Math.sin(t); return { X: x, Y: y }; } } var spiral = new Spiral(0.3); var points = spiral.points( 2, 0.01 ); plot(points);
http://myweb.uiowa.edu/timv/spiral.htm上的示例实施