diff --git a/color_palette_generator/Readme.md b/color_palette_generator/Readme.md new file mode 100644 index 000000000..e94937e3a --- /dev/null +++ b/color_palette_generator/Readme.md @@ -0,0 +1,64 @@ +# Color Palette Generator + +## Short Description +This is a simple web application built with Flask that generates a random color palette. Users can specify the number of colors in the palette (between 1 and 10), and the app will display the corresponding colors in a visually appealing way. + +## Functionality +- Generate random color palettes with customizable color count. +- Display color hex codes for each generated color. +- Interactive UI to adjust the number of colors displayed. + +## Folder Structure + + color_palette_generator/ + │ + ├── app.py # Main Flask application file + ├── templates/ + │ └── index.html # HTML template for the app + ├── requirements.txt # Python dependencies file + └── README.md # Instructions for the program + + +## Instructions for Each File: +1. app.py: +The main Flask application script, which generates random color palettes and serves them via a web interface. + +2. templates/index.html: +HTML file that displays the color palette on the front end and allows the user to input the number of colors. + +3. requirements.txt: +List of dependencies required to run the project. + +## Setup Instructions +1. Clone the repository or download the project files. +2. Navigate to the project folder in your terminal: + ```bash + cd color_palette_generator + ``` +3. Install the required dependencies using pip: + ```bash + pip install -r requirements.txt + ``` +4. Run the Flask app: + ```bash + python app.py + ``` +5. Open your browser and go to http://127.0.0.1:5000/ to use the app. + + +## Detailed Explanation +- The app.py script creates a Flask web server that serves an HTML page (index.html) where users can generate color palettes. +- The generate_color_palette() function in app.py generates a list of random hexadecimal colors using the random module. +- The front-end (index.html) uses a form to capture the user's input for the number of colors, and the results are displayed using a simple CSS grid for visualization. +- Each color is displayed as a square with its corresponding hex code. + +## Output + +![Output](image.png) + +## Author(s) +explooit +https://github.com/ExPl0iT-29 + +## Disclaimers +- The project uses random color generation and does not guarantee aesthetically balanced palettes. \ No newline at end of file diff --git a/color_palette_generator/image.png b/color_palette_generator/image.png new file mode 100644 index 000000000..8b559da1a Binary files /dev/null and b/color_palette_generator/image.png differ diff --git a/color_palette_generator/main.py b/color_palette_generator/main.py new file mode 100644 index 000000000..eefc8fe49 --- /dev/null +++ b/color_palette_generator/main.py @@ -0,0 +1,28 @@ +from flask import Flask, render_template, request +import random + +app = Flask(__name__) + + +# Function to generate random color palette +def generate_color_palette(num_colors=5): + colors = [] + for _ in range(num_colors): + color = "#{:06x}".format(random.randint(0, 0xFFFFFF)) # Generate a random hex color + colors.append(color) + return colors + + +# Home route to display the color palette generator +@app.route('/', methods=['GET', 'POST']) +def home(): + if request.method == 'POST': + num_colors = int(request.form.get('num_colors', 5)) + color_palette = generate_color_palette(num_colors) + else: + color_palette = generate_color_palette() # Default palette with 5 colors + return render_template('index.html', color_palette=color_palette) + + +if __name__ == '__main__': + app.run(debug=True) \ No newline at end of file diff --git a/color_palette_generator/requirements.txt b/color_palette_generator/requirements.txt new file mode 100644 index 000000000..67a3b6d3b --- /dev/null +++ b/color_palette_generator/requirements.txt @@ -0,0 +1 @@ +Flask==2.2.3 \ No newline at end of file diff --git a/color_palette_generator/templates/index.html b/color_palette_generator/templates/index.html new file mode 100644 index 000000000..45ca584cf --- /dev/null +++ b/color_palette_generator/templates/index.html @@ -0,0 +1,41 @@ + + + + + + Color Palette Generator + + + +

Random Color Palette Generator

+
+ + + +
+ +
+ {% for color in color_palette %} +
+ {% endfor %} +
+ +