A Python-based application that uses turtle graphics to draw images. This project allows users to convert image files into turtle-drawn representations, showcasing a unique blend of image processing and graphical output.
- Converts any image into a turtle graphics drawing
- Utilizes the Python Imaging Library (PIL) for image manipulation
- Fast drawing using turtle graphics with performance optimizations
To use this project, you need to have Python and the required libraries installed. Follow these steps to set up your environment:
-
Clone the repository:
git clone https://github.com/MH-Alikhani/turtle-image-processor.git cd turtle-image-processor
-
Install the required libraries:
pip install -r requirements.txt
Ensure
requirements.txt
contains the following:Pillow
-
Prepare an image:
Ensure you have an image file you want to process.
-
Run the script:
python main.py
-
Follow the prompts:
Enter the path to your image file when prompted.
$ python main.py
Please provide the image path: /path/to/your/image.jpg
The turtle graphics window will open, and the drawing process will begin. The script updates the progress in the terminal, showing the current line being processed.
A base class for image processing that loads and prepares the image.
Attributes:
image_path
: Path to the image file.img
: The original image.rgb_img
: The image converted to RGB format.width
,height
: Dimensions of the image.
Methods:
process_image()
: Abstract method to be overridden by subclasses.
Inherits from ImageProcessor
and implements the turtle graphics drawing.
Attributes:
screen
: The turtle graphics screen.offset_x
,offset_y
: Initial turtle position.
Methods:
_set_initial_turtle_position()
: Sets the initial turtle position.process_image()
: Draws the image using turtle graphics.
A factory class to create different types of image processors.
Methods:
create_image_processor(processor_type, image_path)
: Creates an instance of the specified image processor type.
The entry point of the script that initializes and starts the image processing.
Steps:
- Prompts the user for the image path.
- Creates a
TurtleImageProcessor
. - Calls
process_image()
to start drawing.
Contributions are welcome! Please fork the repository and submit a pull request.
- Fork the repository.
- Create a new branch.
- Make your changes.
- Submit a pull request.