Skip to content

jalfr3d/canvas-drawing-python

Repository files navigation

Canvas Drawing Program

Overview

The Canvas Drawing Program is a Python script that allows users to draw rectangles and squares on a canvas. Users can specify the canvas size, color, and draw different shapes using this interactive program.

Features

  • Canvas Configuration: Users can set the canvas width, height, and background color (white or black).

  • Drawing Shapes: Users can draw rectangles and squares with custom dimensions and colors.

  • Image Output: The program converts the canvas into an image file (canvas.png) containing the drawn shapes.

How It Works

  1. Run the script using Python.

  2. Enter the canvas width, canvas height, and canvas color (white or black) as prompted.

  3. The program initializes a canvas with the specified properties.

  4. Users can draw shapes by entering 'rectangle' or 'square' based on their choice.

  5. For rectangles, users need to provide the X and Y coordinates, width, height, and color components (red, green, and blue).

  6. For squares, users need to provide the X and Y coordinates, side length, and color components (red, green, and blue).

  7. The program draws the specified shape on the canvas and continues to prompt for more shapes.

  8. To stop drawing and save the canvas as an image file, enter 'quit' when prompted for the shape type.

  9. The program saves the canvas as "canvas.png" in the same directory.

Prerequisites

Before using this program, ensure you have the following:

  • Python installed on your system.

  • Required Python libraries: numpy and Pillow (PIL). You can install these libraries using pip if not already installed.

Customization

  • You can customize the canvas's background color by modifying the canvas_color variable in the main script.

  • Add more shape options and parameters to enhance the program's functionality.

  • Modify the output file name or format if needed.

Notes

  • This program serves as a simple canvas drawing tool that can be used for educational purposes and interactive shape creation.

  • It provides a basic interface for drawing shapes and saving the canvas as an image for further use.

  • Feel free to extend the program with additional features, such as different shapes, colors, or saving options, to suit your specific needs.

That's it! Use the Canvas Drawing Program to create and save your own custom drawings and explore the world of digital art with code.

License

This project is licensed under the MIT License. You are free to use and modify the code for your own purposes.