diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..f02e477 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +github: [SkwalExe, adi1090x] +ko_fi: SkwalExe +custom: https://www.paypal.com/paypalme/SkwalDev diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml new file mode 100644 index 0000000..4324918 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -0,0 +1,60 @@ +name: ☢️ Bug Report +description: File a bug report +title: "[Bug]: " +labels: ["bug"] +assignees: + - SkwalExe +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + - type: input + id: contact + attributes: + label: Contact Details + description: How can we get in touch with you if we need more info? + placeholder: ex. email@example.com + validations: + required: false + - type: textarea + id: what-were-doing + attributes: + label: What were you trying to do when the bug happened? + placeholder: ex. I was trying to do something + value: "I was trying to do something" + validations: + required: false + - type: textarea + id: expected-behavior + attributes: + label: What was the expected behavior? + placeholder: ex. The program should have.... + value: "The program should have continued to run normally" + validations: + required: false + - type: textarea + id: what-actually-happened + attributes: + label: What actually happened? + placeholder: Tell us what happened + value: "A bug happened!" + validations: + required: false + - type: textarea + id: how-to-reproduce + attributes: + label: How can we reproduce this? + placeholder: ex. step 1 - step 2... + value: "step 1 - step 2..." + validations: + required: false + - type: textarea + id: how-to-fix + attributes: + label: Possible solutions + description: Do you have an idea for how we could fix this? + placeholder: ex. Replace this line of code with... + value: "Replace this line of code with..." + validations: + required: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/EMPTY_ISSUE.yml b/.github/ISSUE_TEMPLATE/EMPTY_ISSUE.yml new file mode 100644 index 0000000..a10e550 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/EMPTY_ISSUE.yml @@ -0,0 +1,27 @@ +name: ❇️ Other issue +description: Other than a bug report or feature request +title: "[OTHER]:" +labels: [] +assignees: + - SkwalExe +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this issue! + - type: input + id: contact + attributes: + label: Contact Details + description: How can we get in touch with you if we need more info? + placeholder: ex. email@example.com + validations: + required: false + - type: textarea + id: description + attributes: + label: Description + placeholder: ex. my issue is... + value: "my issue is..." + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml new file mode 100644 index 0000000..912e632 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml @@ -0,0 +1,41 @@ +name: 💠 Feature request +description: File a feature request +title: "[Feature]: " +labels: ["enhancement"] +assignees: + - SkwalExe +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this feature request! + - type: input + id: contact + attributes: + label: Contact Details + description: How can we get in touch with you if we need more info? + placeholder: ex. email@example.com + validations: + required: false + - type: textarea + id: feature-description + attributes: + label: Feature Description + placeholder: ex. I would like to see... + value: "I would like to see..." + validations: + required: false + - type: textarea + id: problem-solved + attributes: + label: Problem Solved + description: What problem would this feature solve? + validations: + required: false + - type: textarea + id: how-to-implement + attributes: + label: How can we implement this? + description: Do you have an idea for how we could implement this? + validations: + required: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..b92c70c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,2 @@ +blank_issues_enabled: true + diff --git a/.github/workflows/greeting.yml b/.github/workflows/greeting.yml new file mode 100644 index 0000000..4c43995 --- /dev/null +++ b/.github/workflows/greeting.yml @@ -0,0 +1,16 @@ +name: Greetings + +on: [pull_request, issues] + +jobs: + greeting: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/first-interaction@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + issue-message: 'Hi @${{ github.actor }} Thanks for opening this issue :tada: You should receive a response soon.' + pr-message: 'Hi @${{ github.event.pull_request.user.login }} Thank you for taking your time and effort for this contribution :100: it really helps us :tada:' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6769e21 --- /dev/null +++ b/.gitignore @@ -0,0 +1,160 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3674ce9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 KOPRIVNIK IBGHY Léopold, @SkwalExe + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 2d36414..008243a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,80 @@ -# octo-logo -💠 Simple program that generates a logo for your open source project +

+ +

+ +

+ + + + + + +

+ +

💠 Simple program that generates a logo for your open source projects 💠

+ +# Credits + +I had the idea to create this project after seeing the logos made by [adi1090x](https://github.com/adi1090x) for his repositories. They were simple but gave a nice feel to his projects. I wanted a logo that gives the same energy, but didn't manage to find how he made them (most likely manually, with GIMP according the the exif data of the images). So I decided to make a program that would allow anyone to generate a cool and simple logo for their projects. + +- [adi1090x's GitHub](https://github.com/adi1090x) + +# Usage + +First, clone this repository + +```bash +git clone https://github.com/SkwalExe/octo-logohttps://github.com/SkwalExe/octo-logo +cd octo-logo +``` + +Then, install the dependencies + +```bash +pip3 install -r requirements.txt +``` + +And finally, launch the program and follow the instructions + +```bash +python3 src/main.py +``` + +# Styles + +### Style 1 - First letter underlined + +

+ +

+ + +### Style 2 - All letters underlined + +

+ +

+ +# Color schemes + +### Color scheme 1 - adi1090x's color scheme + +

+ +

+ +### Color scheme 2 - Cherry + +

+ +

+ +### Color scheme 3 - Midnight Abyss + +

+ +

+ +# Development + +Please, open an issue if you have any suggestion or if you found a bug. I will try to fix it as soon as possible. If you want to contribute, open an empty pull request and explain what you want to do, wait for me to approve it and then you can start working on it. \ No newline at end of file diff --git a/assets/color1.png b/assets/color1.png new file mode 100644 index 0000000..21a2d7a Binary files /dev/null and b/assets/color1.png differ diff --git a/assets/color2.png b/assets/color2.png new file mode 100644 index 0000000..6cbf1d1 Binary files /dev/null and b/assets/color2.png differ diff --git a/assets/color3.png b/assets/color3.png new file mode 100644 index 0000000..e7b54c0 Binary files /dev/null and b/assets/color3.png differ diff --git a/assets/logo.png b/assets/logo.png new file mode 100644 index 0000000..0d2b307 Binary files /dev/null and b/assets/logo.png differ diff --git a/assets/style1.png b/assets/style1.png new file mode 100644 index 0000000..9198e5a Binary files /dev/null and b/assets/style1.png differ diff --git a/assets/style2.png b/assets/style2.png new file mode 100644 index 0000000..3184435 Binary files /dev/null and b/assets/style2.png differ diff --git a/colors/adi1090x.toml b/colors/adi1090x.toml new file mode 100644 index 0000000..e487eca --- /dev/null +++ b/colors/adi1090x.toml @@ -0,0 +1,3 @@ +background = "#131b20" +text = "#283039" +accent = "#a8bf3e" \ No newline at end of file diff --git a/colors/cherry.toml b/colors/cherry.toml new file mode 100644 index 0000000..f1568a8 --- /dev/null +++ b/colors/cherry.toml @@ -0,0 +1,3 @@ +background = "#ffdcdc" +text = "#fda8ac" +accent = "#ef5e81" \ No newline at end of file diff --git a/colors/midnight_abyss.toml b/colors/midnight_abyss.toml new file mode 100644 index 0000000..66451fe --- /dev/null +++ b/colors/midnight_abyss.toml @@ -0,0 +1,3 @@ +background = "#000000" +text = "#272c38bd" +accent = "#30b962" \ No newline at end of file diff --git a/fonts/Iosevka-Nerd-Font-Complete.ttf b/fonts/Iosevka-Nerd-Font-Complete.ttf new file mode 100644 index 0000000..bbb351c Binary files /dev/null and b/fonts/Iosevka-Nerd-Font-Complete.ttf differ diff --git a/fonts/JetBrains-Mono-Nerd-Font-Complete.ttf b/fonts/JetBrains-Mono-Nerd-Font-Complete.ttf new file mode 100644 index 0000000..f9f0185 Binary files /dev/null and b/fonts/JetBrains-Mono-Nerd-Font-Complete.ttf differ diff --git a/output/info.txt b/output/info.txt new file mode 100644 index 0000000..baae0ef --- /dev/null +++ b/output/info.txt @@ -0,0 +1 @@ +Here you will find your generated logos. \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e5520ce --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +pillow==9.0.1 +inquirer==3.1.3 +toml==0.10.2 +importlib==1.0.4 diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..28648c0 --- /dev/null +++ b/src/main.py @@ -0,0 +1,57 @@ +import inquirer as inq +from importlib import import_module +import os +from time import time +from utils import * + +# Look for DEBUG in the environment variables +DEBUG = os.environ.get("DEBUG", "false").lower() == "true" + +def main(): + + # Load the styles in the styles directory + styles = dict() + for style in os.listdir(os.path.join(BASE_DIR, "src", "styles")): + # Only keep .py files + if not style.endswith(".py"): + continue + + # Try to import the script + # If it fails, ignore it + if DEBUG: + module = import_module(f"styles.{remove_ext(style)}") + else: + try: + module = import_module(f"styles.{remove_ext(style)}") + except: + print(f"Error while importing {style}, ignoring...") + continue + + # Only keep files with the active attribute set to True + # This allows to ignore some scripts that may be in the styles directory + if not module.active: + continue + + styles[module.name] = module + + questions = [ + inq.Text("name", message="Project's name"), + inq.List("style", message="Select a style", choices=list(styles.keys())) + ] + + answers = inq.prompt(questions) + + # Force the user to enter a name + if not len(answers["name"]) > 0: + print("Error : You must enter a name") + quit() + + selected_style = styles[answers["style"]] + + image = selected_style.get_image(answers["name"]) + + # Save result or show if debug is enabled + image.show() if DEBUG else image.save(f'output/{answers["name"]}_{int(time())}.png') + +if __name__ == "__main__": + main() diff --git a/src/styles/all_underlined.py b/src/styles/all_underlined.py new file mode 100644 index 0000000..26dd88e --- /dev/null +++ b/src/styles/all_underlined.py @@ -0,0 +1,7 @@ +from . import underline_core + +name = "All text underlined" +active = True + +def get_image(name): + return underline_core.get_image(name, "all") \ No newline at end of file diff --git a/src/styles/first_letter_underlined.py b/src/styles/first_letter_underlined.py new file mode 100644 index 0000000..7970d9a --- /dev/null +++ b/src/styles/first_letter_underlined.py @@ -0,0 +1,7 @@ +from . import underline_core + +name = "First letter underlined" +active = True + +def get_image(name): + return underline_core.get_image(name, "first_letter") \ No newline at end of file diff --git a/src/styles/underline_core.py b/src/styles/underline_core.py new file mode 100644 index 0000000..82e4f9e --- /dev/null +++ b/src/styles/underline_core.py @@ -0,0 +1,118 @@ +import toml +from PIL import Image, ImageDraw, ImageFont, ImageColor +import inquirer as inq + +import sys +sys.path.append("..") + +from utils import * + +active = False + +def get_image(name, type): + if not type in ['all', 'first_letter']: + raise ValueError("Invalid type") + + questions = [ + inq.List("font", message="Select a font", choices=font_list), + inq.List("color", message="Select a color scheme", choices=color_list, default="adi1090x"), + inq.Text("padding_x", message="Padding x (px)", default=200), + inq.Text("padding_y", message="Padding y (px)", default=20), + inq.Text( + "gap", message="Gap between the first letter and the bar (px)", default=20 + ), + inq.Text("bar_size", message="Bar size (px)", default=20), + inq.Text( + "additionnal_bar_width", message="Addionnal bar width (px)", default=5 + ), + ] + + answers = inq.prompt(questions) + + # Convert the answers to integers + try: + padding_x = int(answers["padding_x"]) + padding_y = int(answers["padding_y"]) + gap = int(answers["gap"]) + bar_size = int(answers["bar_size"]) + additionnal_bar_width = int(answers["additionnal_bar_width"]) + except ValueError: + print("px values must be integer") + exit(1) + + # Load the selected font + font_size = 500 + font = ImageFont.truetype(os.path.join(FONTS_DIR, answers["font"]), font_size) + + # Load the selected color scheme + color_scheme_file = os.path.join(COLORS_DIR, f'{answers["color"]}.toml') + color_scheme = toml.load(color_scheme_file) + + background = ImageColor.getrgb(color_scheme["background"]) + text = ImageColor.getrgb(color_scheme["text"]) + accent = ImageColor.getrgb(color_scheme["accent"]) + + # Get the width and height of the texts + text_width, text_height = get_text_size(name, font) + font_height = get_font_height(font) + + # Get the correct image width and height + image_width = 2 * padding_x + text_width + image_height = 2 * padding_y + font_height + + # Create the image + image = Image.new("RGB", (image_width, image_height), background) + draw = ImageDraw.Draw(image) + + # Get the anchor position and type + anchor_type = "lm" + anchor_x = padding_x + anchor_y = image_height / 2 - (gap + bar_size) / 2 + + anchor_pos = (anchor_x, anchor_y) + + # Get the bbox of the first letter + + first_letter_bbox = draw.textbbox( + anchor_pos, name[0], font=font, anchor=anchor_type + ) + + # Get the underline position + underline_start_x = first_letter_bbox[0] - additionnal_bar_width + underline_start_y = first_letter_bbox[3] + gap + + # The end of the underline depends on the type + # If the type is 'all', the underline will go from the start of the first letter to the end of the text + # If the type is 'first_letter', the underline will go from the start of the first letter to the end of the first letter + underline_end_x = additionnal_bar_width + (first_letter_bbox[2] if type == 'first_letter' else padding_x + text_width) + underline_end_y = underline_start_y + bar_size + + underline_start = (underline_start_x, underline_start_y) + underline_end = (underline_end_x, underline_end_y) + + underline_pos = [underline_start, underline_end] + + # Underline the first letter + draw.rectangle(underline_pos, fill=accent, width=bar_size) + + + # Draw the text + draw.text( + anchor_pos, + name, + font=font, + fill=text, + anchor=anchor_type, + ) + + # Redraw the first letter + draw.text( + anchor_pos, + name[0], + font=font, + fill=accent, + anchor=anchor_type, + ) + + + return image diff --git a/src/utils.py b/src/utils.py new file mode 100644 index 0000000..9d8d17d --- /dev/null +++ b/src/utils.py @@ -0,0 +1,34 @@ +import os +from PIL import Image, ImageDraw, ImageFont, ImageColor + +def get_text_size(text, font): + text_bbox = ImageDraw.Draw(Image.new("RGBA", (1, 1), (0, 0, 0, 0))).textbbox( + (0, 0), text, font=font + ) + text_width = text_bbox[2] - text_bbox[0] + text_height = text_bbox[3] - text_bbox[1] + + return text_width, text_height + + +def get_font_height(font): + return font.getsize("azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQASDFGHJKLMWXCVBN")[1] + + +def remove_ext(filename): + return filename.split(".")[0] + + +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +FONTS_DIR = os.path.join(BASE_DIR, "fonts") +COLORS_DIR = os.path.join(BASE_DIR, "colors") + +# Get all the fonts in the fonts directory +font_list = os.listdir(FONTS_DIR) + +# Get all the color schemes in the colors directory +# keep only files with the .toml extension +# and remove the extension +color_list = [ + remove_ext(color) for color in os.listdir(COLORS_DIR) if color.endswith(".toml") +] \ No newline at end of file