A small package to get started drawing pictures in CS1400
Project description
Drawly
A simple Python drawing package designed for educational use at Utah State University in CS 1400 - Introduction to Computer Science. Drawly provides an easy-to-use API for creating graphical applications and learning fundamental programming concepts through visual programming.
Drawly offers a gentle introduction to:
- Function calls and parameters
- Control structures (loops, conditionals)
- User input and output
- Basic geometry and mathematics
- Event-driven programming concepts
Drawly is designed to help students learn programming concepts through visual feedback:
- Immediate Results: Students see their code's effects instantly
- Mathematical Concepts: Coordinates, angles, and geometry become tangible
- Problem Solving: Students can create visual solutions to programming challenges
- Creativity: Encourages experimentation and artistic expression through code
- Debugging: Visual output makes it easier to understand program flow
Drawly abstracts away the complexity of graphics programming while providing immediate visual feedback, making it ideal for students who are new to programming. By introducing core programming concepts through a simplified interface, Drawly prepares students for a smooth transition to more advanced programming with Pygame later in the semester.
Support
For questions or issues related to CS1400 at Utah State University, please contact your instructor or teaching assistant.
Installation
Drawly requires Python 3.10 or higher and depends on Pygame for graphics rendering.
pip install drawly
Note: Pygame will be automatically installed as a dependency when you install Drawly.
Quick Start
import drawly
# Initialize the drawing window with a title and a light blue background
drawly.start("My First Drawing", background="light blue")
drawly.set_speed(6)
# Some circles
drawly.set_color("green")
drawly.circle(200, 200, 50)
drawly.draw()
drawly.set_color("red")
drawly.circle(400, 200, 75)
drawly.draw()
# A triangle
drawly.set_color("yellow")
drawly.polygon_begin()
drawly.add_poly_point(300, 240)
drawly.add_poly_point(250, 340)
drawly.add_poly_point(350, 340)
drawly.polygon_end()
drawly.draw()
# A rectangle
drawly.set_color("orange")
drawly.rectangle(180, 375, 250, 65)
drawly.draw()
# And some text
drawly.set_color("darkblue")
drawly.text(150, 60, "Hello from Drawly!", 30)
drawly.draw()
# Keep the window open
drawly.done()
Core Features
Window Management
- Create customizable drawing windows
- Set background colors
- Optional terminal area for text input/output
Drawing Primitives
- Circles: Filled or outlined circles
- Rectangles: With optional rotation and rotation points
- Lines: Between two points or as vectors with angle/length
- Polygons: Custom shapes built point by point
- Ellipses and Arcs: Curved shapes
- Text: Customizable font, size, and color
Interactive Features
- Terminal input/output within the drawing window
- Speed control for animation effects
- Color management
- Background drawing for persistent elements
API Reference
Window Management
start(title, dimensions, background, terminal, terminal_lines, terminal_line_height)- Initialize the drawing windowdone()- Keep the window open until user closes it
Drawing Control
set_speed(speed)- Set drawing speed (1-10)set_color(color)- Set drawing colordraw()- Display all shapes since last drawredraw()- Clear screen and redraw everything
Shapes
circle(x, y, radius, stroke)- Draw a circlerectdegrees(x, y, width, height, stroke, rotation_angle, rotation_point)- Draw a rectangleline(x1, y1, x2, y2, stroke)- Draw a line between pointsvector(x, y, length, angle, stroke)- Draw a line with angleellipse(x, y, width, height, stroke)- Draw an ellipsearc(x, y, width, height, start_angle, end_angle, stroke)- Draw an arc
Polygons
polygon_begin(stroke)- Start creating a polygonadd_poly_point(x, y)- Add a point to the polygonpolygon_end()- Complete and draw the polygon
Text and Terminal
text(x, y, text, size, font)- Draw textterminal_output(*message)- Display message in terminalterminal_input(*prompt)- Get user input from terminalterminal_clear()- Clear terminal area
Background Drawing
background_begin()- Start drawing background elementsbackground_end()- End background drawing
Comprehensive Example
Here's a larger demonstration showing more of Drawly's capabilities:
from drawly import *
# Initialize with terminal enabled
start("Drawly Demo", background="lightblue", terminal=True)
set_speed(5) # Medium drawing speed
# Welcome message
terminal_output("A Drawly Demo")
# Draw some circles
circle(200, 200, 50) # Filled circle
set_color("red")
circle(400, 200, 75)
draw()
# Draw outlined circles
set_color("black")
circle(400, 200, 75, 5) # stroke=5 for outline
draw()
# Draw rectangles
set_color("blue")
rectangle(100, 100, 150, 100) # x, y, width, height
draw()
# Draw rotated rectangle
set_color("green")
rectangle(500, 100, 120, 80, stroke=3,
rotation_angle=45, rotation_point=RotationPoint.CENTER)
draw()
# Get user input and draw based on it
count = int(terminal_input("How many circles? "))
for i in range(count):
set_color("purple")
circle(100 + i * 50, 400, 25)
draw()
# Draw lines
set_color("orange")
line(50, 50, 200, 150, 3) # Thick line
draw()
# Draw vectors (lines with angle)
set_color("brown")
vector(300, 300, 100, 45) # length=100, angle=45 degrees
draw()
# Create a polygon
polygon_begin()
add_poly_point(600, 100)
add_poly_point(700, 200)
add_poly_point(650, 300)
add_poly_point(550, 250)
polygon_end()
draw()
# Draw text
set_color("darkblue")
text(50, 500, "Hello from Drawly!", 30)
draw()
# Get user input for custom text
message = terminal_input("Enter a message: ")
set_color("red")
text(50, 550, message, 25)
draw()
# Keep window open
done()
Requirements
- Python 3.10 or higher
- Pygame 2.5 or higher (automatically installed)
License
MIT License - See LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file drawly-1.1.4.tar.gz.
File metadata
- Download URL: drawly-1.1.4.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
927466f2d2c678b9fcb855749b9e1678083160c125eb343dbf1ff120c1d9d293
|
|
| MD5 |
c83d12901a51a45e4d336c78d5f7de83
|
|
| BLAKE2b-256 |
db8efb6e889b19adfc768cf0a340400ddcef0c756cb674e5ed88f1f9e5f63242
|
File details
Details for the file drawly-1.1.4-py3-none-any.whl.
File metadata
- Download URL: drawly-1.1.4-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2134e0dbeb56f1bf21313ee77b56d4b1e82ab8eec32151564b934f0d5957c884
|
|
| MD5 |
dddbd53b1195c291bf80a5fa85a40eaa
|
|
| BLAKE2b-256 |
9e5599265fc0f8c10b0856d4627173a472536c8bc5828a7c450bc5016970b012
|