秀丸エディタスレ Part5

このエントリーをはてなブックマークに追加
398名無しさん@お腹いっぱい。
// http://pc2.2ch.net/test/read.cgi/software/1074319808/
// 285 名無しさん@お腹いっぱい。 sage 04/01/21 21:07 ID:9DspJYw6
function Spiral(dr, reverseY) {
this.dr = dr;
this.reverseY = reverseY;
}
Spiral.prototype.setAngle = function(angle) {this.angle = angle}
Spiral.prototype.r = function(angle){return this.dr * angle / (2 * Math.PI);}
Spiral.prototype.x = function(angle){
return this.r(angle) * Math.cos(angle);
}
Spiral.prototype.y = function(angle) {
var reg = this.reverseY ? -1 : 1;
return this.r(angle) * Math.sin(angle) * reg;
}
Spiral.prototype.angleAtLength = function(l) {
return Math.sqrt(4 * Math.PI * l / this.dr);
}
function getSpiralString(str, spiral, pitch, ratio) {
str = str.replace(/[\r\n]+/g, "");
var lineCount = Math.floor(spiral.r(
spiral.angleAtLength(str.length * pitch)) * 2) + 2;
var lineLength = Math.floor(lineCount * ratio);
var centerX = Math.floor(lineLength / 2);
var centerY = Math.floor(lineCount / 2);

var lines = new Array(lineCount);
for(var i = 0; i < lineCount; i++) {
lines[i] = "";
for(var j = 0; j < lineLength; j++) {lines[i] += " " ;}