Giter VIP home page Giter VIP logo

gkvgk2001 / random-color-generator Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3 KB

This project is a simple web application that generates random colors in both hexadecimal (hex) and RGB formats. It allows users to generate colors and copy the generated color value to their clipboard

Home Page: https://gkvgk2001.github.io/Random-Color-Generator/

HTML 25.45% JavaScript 49.86% CSS 24.69%
dom-manipulation eventhandling html-css-javascript random-color-generator

random-color-generator's Introduction

Random Color Generator

This project is a simple web application that generates random colors in both hexadecimal (hex) and RGB formats. It allows users to generate colors and copy the generated color value to their clipboard.

Features

  • Generate random colors in hex format.
  • Generate random colors in RGB format.
  • Copy the generated color value to the clipboard.

Technologies Used

  • HTML
  • CSS
  • JavaScript

Javascript Function Explanation:

Hex Color Generator

createhexcolor()

  • This function is triggered when the "Create Hex Color" button is clicked.
  • It generates a random hex color by randomly selecting characters from the set "0123456789ABCDEF" and concatenating them to form a 6-character hex color code.
  • It updates the text content of the .hex-color-value paragraph element with the generated hex color code.
  • It updates the background color of the .hex-color-generator div, the "Create Hex Color" button, and the "Copy To Clipboard" button with the generated hex color code.

copyHexColorToClipboard()

  • This function is triggered when the "Copy To Clipboard" button next to the hex color is clicked.
  • It copies the text content of the .hex-color-value paragraph element (hex color code) to the user's clipboard using the navigator.clipboard.writeText() method.
  • It displays an alert confirming that the hex color has been copied to the clipboard.

RGB Color Generator

createRgbColor()

  • This function is triggered when the "Create Rgb Color" button is clicked.
  • It retrieves the values of the Red, Green, and Blue sliders (#red, #green, #blue) and stores them in separate variables.
  • It updates the text content of the .rgb-color-value paragraph element with the generated RGB color code.
  • It updates the background color of the .rgb-color-generator div, the "Create Rgb Color" button, and the "Copy To Clipboard" button with the generated RGB color code.

copyRgbColorToClipboard()

  • This function is triggered when the "Copy To Clipboard" button next to the RGB color is clicked.
  • It copies the text content of the .rgb-color-value paragraph element (RGB color code) to the user's clipboard using the navigator.clipboard.writeText() method.
  • It displays an alert confirming that the RGB color has been copied to the clipboard.

Event Listeners

  • Event listeners are added to the "Create Hex Color" button, "Create Rgb Color" button, and "Copy To Clipboard" buttons for both hex and RGB colors. These listeners trigger the corresponding functions when the buttons are clicked.

Usage

  1. Clone the repository to your local machine.

    git clone  https://github.com/gkvgk2001/Random-Color-Generator.git
  2. Navigate to the project directory.

    cd random-color-generator
  3. Open the index.html file in your preferred web browser.

  4. Use the following functionalities:

    • Click the "Create Hex Color" button to generate a random hex color.
    • Use the sliders for Red, Green, and Blue to customize the RGB color, then click the "Create Rgb Color" button.
    • Click the "Copy To Clipboard" buttons to copy the generated color value (hex or RGB) to your clipboard.

Contributing

Contributions are welcome! If you have any ideas, suggestions, or improvements, feel free to open an issue or create a pull request.

random-color-generator's People

Contributors

gkvgk2001 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.