Spiral
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 - 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);
Developer | Not Important |
Username | clindsey |
Uploaded | July 13, 2022 |
Rating | 3 |
Size | 2,466 Kb |
Views | 40,480 |
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!
Name | Size |
Fluid-mobius-2.1.1 | 8,472 Kb |
Immutable.js | 2,057 Kb |
SquiggleCache | 2,872 Kb |
Spectrum-shift | 4,680 Kb |
Visibility | 7,758 Kb |
FlowField | 5,931 Kb |
PokerCheck | 7,323 Kb |
SquiggleParty | 3,990 Kb |
WorldGenerator | 4,767 Kb |
Lunar-lander-0.1.0 | 11,850 Kb |
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!
Name | Username | Size |
Experiment - SCSS SVG Background Image with Variables | See8ch | 3,270 Kb |
Typefaces with descriptions | Megandoty | 2,944 Kb |
Pure CSS Dial | Lukewatts | 3,018 Kb |
A bit of elegance | Hackthevoid | 9,095 Kb |
Login with flip 3d animation | Afiq | 3,012 Kb |
Very Simple Slider | Doodlemarks | 2,682 Kb |
Slick Slider | Wearebold | 5,913 Kb |
Pure CSS Animated Photo Stack | Depthdev | 2,486 Kb |
Loading animation with css | Icebob | 2,947 Kb |
Simple Accordion | Wearebold | 3,683 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!