You are currently viewing Geometric Art Generator using HTML, CSS & JavaScript

Geometric Art Generator using HTML, CSS & JavaScript

Free Coding Ebook 👉 Get Now

Geometric Art Generator using HTML, CSS & JavaScript


Hello, today we’re going to learn how to use HTML, CSS & JavaScript to create a Geometric Art Generator. By following these instructions, you can simply make this Geometric Art Generator in HTML, CSS & JavaScript. Simply by adhering to the procedures mentioned below, you will be able to develop this amazing Geometric Art Generator.

Geometric Art Generator Javascript Project

Project Description

Step 1
The HTML (Hypertext Markup Language) will help us to create the structure for the list with some necessary attributes and elements to make Geometric Art Generator Project.


Step 2
Then we will use CSS (Cascading Stylesheet) which will help us to style or design the project with suitable padding and alignment in the Geometric Art Generator Project.

Step 3
At last we will use JS (JavaScript) which will add a logic to make the Geometric Art Generator Project functioning from the user end.

Ecommerce Website Using HTML, CSS, & JavaScript (Source Code)

I hope you have got an idea about the project.

HTML Code for Geometric Art Generator

<html lang="en">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Geometric Art Generator</title>
    <!-- Google Font -->
    <!-- Stylesheet -->
    <link rel="stylesheet" href="style.css" />
    <div class="wrapper">
      <div class="container">
      <button id="btn">Generate</button>
    <!-- Script -->
    <script src="script.js"></script>

First we’ll start with creating the structure of the Geometric Art Generator project for that as you can see the above code we have used all the necessary elements & attributes to setup the structure. Let us know code the CSS part to add styling and aligned the tags.

CSS Code for Geometric Art Generator

Restaurant Website Using HTML And CSS With Source Code

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
.wrapper {
  position: absolute;
  transform: translate(-50%, -50%);
  left: 50%;
  top: 50%;
.container {
  background-color: #000000;
  height: calc(15vmin * 5);
  width: calc(15vmin * 4);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 15px;
  gap: 10px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(90, 90, 180, 0.4);
.container div {
  position: relative;
  height: 100%;
  width: 100%;
button {
  width: 100%;
  margin-top: 30px;
  background-color: #000000;
  padding: 18px 0;
  border: none;
  outline: none;
  cursor: pointer;
  color: #ffffff;
  font-family: "Poppins", sans-serif;
  font-size: 3.5vmin;
  border-radius: 5px;
.quad-circle-1 {
  clip-path: circle(100% at 0 0);
.quad-circle-2 {
  clip-path: circle(100% at 100% 0);
.quad-circle-3 {
  clip-path: circle(100% at 100% 100%);
.quad-circle-4 {
  clip-path: circle(100% at 0 100%);
.triangle-1 {
  clip-path: polygon(0 0, 0% 100%, 100% 0);
.triangle-2 {
  clip-path: polygon(0 0, 100% 0, 100% 100%);
.triangle-3 {
  clip-path: polygon(0 100%, 100% 0, 100% 100%);
.triangle-4 {
  clip-path: polygon(0 0, 0 100%, 100% 100%);
.circle {
  border-radius: 50%;

Second comes the CSS code, which is mentioned above in that we have styled for the structure we have padded as well as aligned the Geometric Art Generator project so that it is properly situated and doesn’t get messy with suitable CSS elements. Now we have created the structure using HTML and styled the webpage using CSS its time to add the functionality using JavaScript in this project.

JavaScript Code for Geometric Art Generator

100+ JavaScript Projects With Source Code ( Beginners to Advanced)

const btn = document.getElementById("btn");
const shapes = [
const colors = ["#01d2fd", "#ffc700", "#fe9f12", "#06d0c7"];

const boxes = document.querySelectorAll(".container div");

let generatePattern = () => {
  boxes.forEach((box) => {
    box.className = "";
    let i = Math.floor(Math.random() * shapes.length);
    let j = Math.floor(Math.random() * colors.length);
    box.classList.add(shapes[i]); = colors[j];

btn.addEventListener("click", generatePattern);
window.addEventListener("load", generatePattern);

Last stage of the project the JavaScript which we added the logic and coded as per the requirement with some conditions. By adding the necessary functions such as Math floor and Math random we can able to set the shape of the geometry. We defined the shapes in the beginning and then we used mathfloor function to make the shapes random.

Let us see the Final Output of the project Geometric Art Generator using HTML, CSS & JavaScript.


Live Preview of Geometric Art Generator 

See the Pen
by Harsh Sawant (@harshh9)
on CodePen.

We have successfully created our Geometric Art Generator using HTML, CSS & JavaScript. You can use this project for your personal needs and the respective lines of code are given with the code pen link mentioned above.

10+ Javascript Projects For Beginners With Source Code

If you find out this Blog helpful, then make sure to search codewithrandom on google for Front End Projects with Source codes and make sure to Follow the Code with Random Instagram page.

Code Idea – codingartist

Written By – Harsh Sawant

Code By – @harshh9

Free Coding Ebook 👉 Get Now

Leave a Reply