Skip to content

Latest commit

 

History

History
198 lines (123 loc) · 7.55 KB

README.md

File metadata and controls

198 lines (123 loc) · 7.55 KB

ASCII ART

Welcome to this years Python challenge for Hacktoberfest, a project with beginners and aspiring developers in mind, utilizing Python to convert images into ASCII Art.

❇️ Getting Started with Hacktoberfest

Hacktoberfest is a month-long celebration of open source, organised by Digital Ocean. (More details here)

If you've never made a pull request before, or participated in an open-source project, we recommend taking a look at:

These two resources have everything you need to learn about open-source, with a step-by-step guide to making your very first PR. Once you've got your feet wet, you're ready to come back and dive into Hacktoberfest fun!



❇️ But what is ASCII Art?

ASCII art is a graphic design technique that uses computers for presentation and consists of pictures pieced together from the 95 printable characters defined by the ASCII Standard from 1963 and ASCII compliant character sets with proprietary extended characters. ~ Wikipedia

❇️ How to get started:

In order to get started on this project, it is recommended that you watch the section on Scripting in the Python course. We talk about sys.argv and Pillow library (Image processing) in that section which would help you!

Step 1: Setup the project environment

  1. First up you need to fork (make a copy) of this repo to your Github account.

  2. Clone (download) your fork to your computer.

git clone https://github.com/{your-username}/ascii-art.git
  1. Navigate to your project directory.
cd ascii-art
  1. Set your streams so you can sync your clone with the original repo (get the latest updates)

    • git remote add upstream https://github.com/zero-to-mastery/ascii-art.git
    • git pull upstream master
    • The above 2 commands will synchronize your forked version of the project with the actual repository.
  2. Create a virtual environment.

python3 -m venv venv
  1. Activate the virtual environment:

    • On Windows:
    venv\Scripts\activate
    • On Mac/Linux:
    source venv/bin/activate
  2. Install the required packages using the requirements.txt file.

pip install -r requirements.txt

Step 2: Running the example code

  1. Run the example code with the command.
python3 community-version.py example/ztm-logo.png
  1. Stare with amazement 😮

Step 3: Contribute and Collaborate

Start chatting with other ZTM students in the #hacktoberfest-2024 channel on our Discord to get help, work together, and share your contributions!

IMPORTANT: DO NOT MODIFY THE make_art.py FILE. ONLY THE community_version.py FILE SHOULD BE MODIFIED.

  1. Make sure you have Python 3 installed on your machine
  2. Run the command cd example
  3. Run the example code with the command: python3 community-version.py example/ztm-logo.png
  4. Stare with amazement 😮
  5. Start chatting with other ZTM students in the #hacktoberfest-2024 channel on our Discord to get help, work together, and share your contributions!
  6. IMPORTANT: DO NOT MODIFY THE make_art.py FILE. ONLY THE community_version.py FILE SHOULD BE MODIFIED.

❇️ How to contribute?

Now that you see how this command line tool works, let's see how we can evolve it with our ZTM community help!! Maybe we want to display this on an HTML web page where users can submit images and we convert it to ASCII art? Maybe we want to improve how the Command Line Tool works/make it more customizeable? Or maybe modify the script to do many other types of art beyond ASCII.

The options are endless and there is no wrong answer. This is all for fun, so try to customize the tool whichever way you think would be best and let's see what we get at the end of the month! Enjoy!

⚠ Please do not make changes to the files in the example directory, These files should remain intact for future contributors to examine and compare with the community version! Pull requests with changes to these files will be closed.

  1. Examine the code in community-version.py, figure out what improvements your fellow community members have made (check out FEATURES.md for a list of existing features you can add to or improve).
  2. Make an improvement, it doesnt have to be elaborate
  3. Create a pull request
  4. Tweet about making your first Hacktoberfest pull request

Congratulations! You are now one pull request closer. Repeat these steps until you have made at least 4 qualifying pull requests. You can check how many qualifying pull requests you have made at https://hacktoberfest.digitalocean.com/profile Have Fun and Happy Coding!

Bonus Task

Looking for a challenge? We have left the original code which was written in Python 2 under the example/make_art_python2.py file. See what happens when you run it with Python 3. See all of the errors? Can you fix it so it works with python 3? The answer is with the example/make_art.py file which is written in Python 3.

All discussions around this event can now be had in our dedicated Hacktoberfest channel on Discord!

My Contribution

Simple Python Script

def greet(name):
    return f"Hello, {name}!"

print(greet("Hacktoberfest"))
### New ASCII Art Example

_______

/
/ O O
| ^ | |-| _________/

Code Quality and Linting

This project uses Ruff, a fast Python linter, to ensure code quality and consistency. Ruff checks for common Python code issues, ensures consistent code style, and enforces best practices. It is integrated as part of the development workflow to maintain a clean codebase.

Installation

To install pre-commit and Ruff, simply install the dependencies listed in requirements.txt:

pip install -r requirements.txt

Then, install the pre-commit hooks:

pre-commit install

This will set up Ruff to automatically check your code before each commit.

Running Ruff

Ruff will automatically run when you make a commit, but you can also manually check your code with the following command:

ruff check .

To automatically fix issues detected by Ruff, you can use:

ruff check . --fix

Configuration

Ruff is configured through the pyproject.toml file. You can modify the linter rules by adjusting the following section:

[tool.ruff]
line-length = 100  # Adjust as necessary
select = ["E", "F", "I", "UP"]  # Add or remove specific rules here

Pre-commit Hook

We have configured Ruff as a pre-commit hook, so it will run automatically before every commit. If you'd like to manually run it on all files, you can use:

pre-commit run --all-files

Ignoring Rules

If you want to ignore specific files or directories, or disable certain rules, you can do so by editing the .ruffignore file or configuring rule exceptions in pyproject.toml.