Mountains

Developer
Size
2,389 Kb
Views
10,120

How do I make an mountains?

Inspiration: https://www.openprocessing.org/sketch/85797. What is a mountains? How do you make a mountains? This script and codes were developed by Pogany on 09 November 2022, Wednesday.

Mountains Previews

Mountains - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Mountains</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas id="canvas"></canvas> <script src="js/index.js"></script>
</body>
</html>

Mountains - Script Codes CSS Codes

body { background-color: #333; overflow: hidden;
}
canvas { background-color: rgb(200,200,200); display: block; margin: 0 auto; margin:calc(50vh - 250px) auto;
}

Mountains - Script Codes JS Codes

var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var cw = canvas.width = 800, cx = cw / 2;
var ch = canvas.height = 500, cy = 2*ch / 3;
ctx.strokeStyle = "#fff";
var rad = Math.PI / 180;
var rot;
var R = 100;
var r = 40;
var c = { x: -R, y: cy
}
var points = [];
var angles = [{ a: -20 * rad, r: r
}, { a: +107 * rad, r: R
}, { a: -95 * rad, r: r
}, { a: +75 * rad, r: R
}, { a: +117 * rad, r: r
}, { a: -100 * rad, r: R
}];
function Point(o) { this.a = o.a; this.r = o.r; this.x = c.x + this.r * Math.cos(this.a); this.y = c.y + this.r * Math.sin(this.a); this.rotatePoint = function(c, rot) { var cos = Math.cos(rot); var sin = Math.sin(rot); var x = c.x + (this.x - c.x) * cos - (this.y - c.y) * sin; var y = c.y + (this.x - c.x) * sin + (this.y - c.y) * cos; this.x = x; this.y = y; }
}
function drawShape() { drawLine(points[0], points[1], "rgba(255,255,255,.3)"); drawLine(points[1], points[2], "rgba(200,200,200,.3)"); drawLine(points[2], points[0], "rgba(175,175,175,.3)"); drawLine(points[3], points[4], "rgba(150,150,150,.3)"); drawLine(points[4], points[5], "rgba(100,100,100,.3)"); drawLine(points[5], points[3], "rgba(50,50,50,.3)");
}
for (var i = 0; i < angles.length; i++) { var point = new Point(angles[i]); points.push(point);
}
ctx.save();
var d = -R;
var h = 0;
function Draw() { requestId = window.requestAnimationFrame(Draw); rot = -.01; if (d <= cw + R) { d++; ctx.translate(1, 0); } else { d = -R; c = { x: -R, y: cy }; ctx.restore(); ctx.save(); } for (var i = 0; i < points.length; i++) { points[i].rotatePoint(c, rot); } drawShape();
}
Draw();
function drawLine(p1, p2, stroke) { ctx.beginPath(); ctx.strokeStyle = stroke; ctx.moveTo(p1.x, p1.y); ctx.lineTo(p2.x, p2.y); ctx.stroke();
}
Mountains - Script Codes
Mountains - Script Codes
Home Page Home
Developer Pogany
Username giaco
Uploaded November 09, 2022
Rating 3
Size 2,389 Kb
Views 10,120
Do you need developer help for Mountains?

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!

Pogany (giaco) Script Codes
Name
Matrix Falling Code
Helianthus
Fuzzies
Basket
Tiles
Tiles nr.2
Out of the blue
Circles
Swim Smooth
Create amazing blog posts 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!