Golden ratio

Size
1,893 Kb
Views
40,480

How do I make an golden ratio?

Just a golden ratio creator. What is a golden ratio? How do you make a golden ratio? This script and codes were developed by Darby Rathbone on 13 October 2022, Thursday.

Golden ratio Previews

Golden ratio - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>golden ratio</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script src="js/index.js"></script>
</body>
</html>

Golden ratio - Script Codes JS Codes

var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
canvas.height = 350;canvas.width=600;
canvas.style.zoom = "1";
canvas.style.border = "solid black 1px";
document.body.appendChild(canvas);
var square = function(size,x,y){ this.width = size; this.height = size; this.top = y; this.left = x; this.bottom = y+size; this.right = x+size; this.center ={x:(x+x+size)/2.0,y:(y+y+size)/2.0}; this.color = "rgba("+((Math.random()*255)|0)+","+((Math.random()*255)|0)+","+((Math.random()*255)|0)+","+1.0+")"; this.draw = function(c){ c.fillStyle = this.color; c.fillRect(this.left,this.top,this.width,this.height); c.strokeRect(this.left,this.top,this.width,this.height); c.fill(); c.stroke(); }; return this;
};
ctx.lineWidth = 1;
var sq = [];
sq.push(new square(1,canvas.width/2,canvas.height/2));
sq.push(new square(1,canvas.width/2+1,canvas.height/2));
for (var i = 0;i<200;i++){ var f =sq[sq.length-1], s = sq[sq.length-2]; if (f.height+s.height == Math.abs(f.right-s.left)) sq.push(new square(f.height+s.height,s.left,f.bottom)); if (f.height+s.height == Math.abs(f.bottom-s.top)) sq.push(new square(f.height+s.height,f.left-(f.height+s.height),s.top)); if (f.height+s.height == Math.abs(f.left-s.right)) sq.push(new square(f.height+s.height,f.left,f.top-(f.height+s.height))); if (f.height+s.height == Math.abs(f.top-s.bottom)) sq.push(new square(f.height+s.height,f.right,f.top));
}
sq.forEach(function(e,i,a){ e.draw(ctx);
});
Golden ratio - Script Codes
Golden ratio - Script Codes
Home Page Home
Developer Darby Rathbone
Username blackkbot
Uploaded October 13, 2022
Rating 3
Size 1,893 Kb
Views 40,480
Do you need developer help for Golden ratio?

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!

Darby Rathbone (blackkbot) 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!