GetRekt

Size
2,206 Kb
Views
8,096

How do I make an getrekt?

What is a getrekt? How do you make a getrekt? This script and codes were developed by Anthony Keithley on 24 December 2022, Saturday.

GetRekt Previews

GetRekt - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>getRekt</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h1>Rectangle Maker</h1>
<h2>Enter the desired width and height</h2>
<p>Width:<input type="number" id="w" min="1" ></p>
<p>Height:<input type="number" id="h" min="1" ></p>
<button onclick="getRekt()">GO!</button>
<button onclick="random()">Random Size</button>
<p>Perimeter: <span id="p">400px</span> Area: <span id="a">10000px<sup>2</sup></span></p>
<div id="rectangle"></div> <script src="js/index.js"></script>
</body>
</html>

GetRekt - Script Codes CSS Codes

body { text-align: center;
}
#rectangle { width: 100px; height: 100px; background: blue; margin:0 auto;
}

GetRekt - Script Codes JS Codes

function getRekt(){ //Get the numbers from the input fields var rektWidth = 100; var rektHeight = 100; rektWidth = document.getElementById("w").value; rektHeight = document.getElementById("h").value; //The div that makes the rectangle var rekt = document.getElementById("rectangle"); //Sets the width and height properties to the //inputs if(rektWidth > 0){ rekt.style.width = rektWidth + "px"; rekt.style.height = rektHeight + "px"; } else { rekt.style.width = "0px"; rekt.style.height = "0px"; } //Chooses random values for red, green, blue var randoR = Math.floor(Math.random() * 255); var randoG = Math.floor(Math.random() * 255); var randoB = Math.floor(Math.random() * 255); //Changes to random background color rekt.style.background = "rgb(" + randoR + ", " + randoG + "," + randoB + ")"; //Calculate and set the perimeter and area calcPandA(rektWidth, rektHeight);
}
function random(){ //Get the numbers from the input fields var rektWidth = Math.floor(Math.random() * 990) + 10; var rektHeight = Math.floor(Math.random() * 990) + 10; //The div that makes the rectangle var rekt = document.getElementById("rectangle"); //Sets the width and height properties to the //inputs rekt.style.width = rektWidth + "px"; rekt.style.height = rektHeight + "px"; //Chooses random values for red, green, blue var randoR = Math.floor(Math.random() * 255); var randoG = Math.floor(Math.random() * 255); var randoB = Math.floor(Math.random() * 255); //Changes to random background color rekt.style.background = "rgb(" + randoR + ", " + randoG + "," + randoB + ")"; calcPandA(rektWidth, rektHeight);
}
function calcPandA(w,h){ //Calculate and set the perimeter and area document.getElementById("p").innerHTML = 2 * w + 2 * h + "px"; document.getElementById("a").innerHTML = w * h + "px<sup>2</sup>";
}
GetRekt - Script Codes
GetRekt - Script Codes
Home Page Home
Developer Anthony Keithley
Username KeithleySLHS
Uploaded December 24, 2022
Rating 3
Size 2,206 Kb
Views 8,096
Do you need developer help for GetRekt?

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!

Anthony Keithley (KeithleySLHS) 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!