Celebrate Valentine's Day with a unique, coded gift using Python's Turtle graphics. This script creates a hypnotizing animation that culminates in a warm message, offering a creative way to express your affection.
The script uses Python's Turtle module to draw a dynamic background very slowly, which only accumulates the feeling of joy while waiting for the main part. followed by a series of heart shapes and a customizable message.
- Gradient Background: A double-gradient effect achieved by blending two color ranges, creating a visually appealing backdrop.
- Heart Shapes: Sequentially drawn hearts that symbolize your feelings.
- Customizable Message: Personalize the final text on the heart shapes to address the message.
To change the script to your preferences, consider adjusting the following parameters:
-
Gradient Colors: Modify the
colors_1andcolors_2variables to change the gradient hues. Each represents a color range in HSV format.colors_1 = color_range((0.56, 0, 1), (0.56, 0, 0.88), 20) colors_2 = color_range((0.56, 0, 0.88), (0.6, 0.47, 1), 20)
-
Gradient Visibility: Alter the
stepvalue in thecolor_rangefunction to adjust the gradient's prominence. A smaller step increases gradient visibility.step = [(end_rgb[i] - start_rgb[i]) / (n-1) for i in range(3)]
-
Drawing Speed: Set the Turtle's speed using
turtle.speed(). The maximum speed is 0.turtle.speed(0)
-
Cursor Shape and Size: Change the Turtle's appearance with
turtle.shape()andturtle.shapesize().turtle.shape("turtle") turtle.shapesize(2, 2)
-
Colors of Shapes and Text: Customize the colors of the hearts and text by adjusting the
turtle.color()parameters.turtle.color((0, 0.29, 0.29), (0.85, 0.2, 0.53)) # Contour and fill colors
-
Text Content and Font: Personalize the message and its appearance by modifying the
draw_textfunction call. (most important customization part, please do not forget)draw_text('Your custom text\n❤️')
- Install Python: Ensure Python is installed on your system.
- Run the Script: Execute the script in a Python environment that supports Turtle graphics.
- Enjoy the Animation: Watch as the background and hearts are drawn, culminating in your personalized message.
For a preview of the final animation, refer to the Sample file included in this repository.
Future iterations of this script may include:
- Faster Rendering: An option to bypass the gradual drawing for an immediate display.
- Enhanced Customization: Additional parameters for more personalized animations.
Thank you for exploring this creative coding project. I wish you lots of joy and hope, that it will impress you and your loved one this Valentine's Day.
This project is pure open-source and you are free to use it If you encounter bugs or have suggestions, please let me know via a descriptive pull request