Spiral

Developer
Size
2,466 Kb
Views
40,480

How do I make an spiral?

Draws a spiral. What is a spiral? How do you make a spiral? This script and codes were developed by Not Important on 13 July 2022, Wednesday.

Spiral Previews

Spiral - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>spiral</title>
</head>
<body> <script src="js/index.js"></script>
</body>
</html>

Spiral - Script Codes JS Codes

(function() { var Spiral, spiral, vectors; vectors = [[1, 0], [0, 1], [-1, 0], [0, -1]]; Spiral = (function() { function Spiral(size1) { this.size = size1; } Spiral.prototype.draw = function() { this.createSpiralArray(); this.iteration(0, 0, this.size); return this.display(); }; Spiral.prototype.iteration = function(x, y, size) { if (!(size > 0)) { return; } this.drawFloor(x, y, size); this.drawWall(x + size, y, size); size = size - 1; this.drawFloor(x + 1, y + size, size); this.drawWall(x + 1, y + 2, size - 2); return this.iteration(x + 2, y + 2, size - 3); }; Spiral.prototype.display = function() { var i, outputString, ref, y; outputString = ''; for (y = i = 0, ref = this.size; 0 <= ref ? i < ref : i > ref; y = 0 <= ref ? ++i : --i) { outputString += this.spiralArray[y].join(''); outputString += '\n'; } return outputString; }; Spiral.prototype.createSpiralArray = function() { var i, ref, results, x, y; this.spiralArray = []; results = []; for (y = i = 0, ref = this.size; 0 <= ref ? i < ref : i > ref; y = 0 <= ref ? ++i : --i) { this.spiralArray[y] = []; results.push((function() { var j, ref1, results1; results1 = []; for (x = j = 0, ref1 = this.size; 0 <= ref1 ? j < ref1 : j > ref1; x = 0 <= ref1 ? ++j : --j) { results1.push(this.spiralArray[y][x] = ' '); } return results1; }).call(this)); } return results; }; Spiral.prototype.drawFloor = function(x, y, size) { var i, iX, ref, results; results = []; for (iX = i = 0, ref = size; 0 <= ref ? i < ref : i > ref; iX = 0 <= ref ? ++i : --i) { results.push(this.spiralArray[y][iX + x] = '*'); } return results; }; Spiral.prototype.drawWall = function(x, y, size) { var i, iY, ref, results; results = []; for (iY = i = 0, ref = size; 0 <= ref ? i < ref : i > ref; iY = 0 <= ref ? ++i : --i) { results.push(this.spiralArray[iY + y][x] = '*'); } return results; }; return Spiral; })(); spiral = new Spiral(20); document.body.innerHTML = '<pre>' + spiral.draw() + '</pre>';
}).call(this);
Spiral - Script Codes
Spiral - Script Codes
Home Page Home
Developer Not Important
Username clindsey
Uploaded July 13, 2022
Rating 3
Size 2,466 Kb
Views 40,480
Do you need developer help for Spiral?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Not Important (clindsey) Script Codes
Create amazing art & images with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!