Skip to main content

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:

  1. Immediate Results: Students see their code's effects instantly
  2. Mathematical Concepts: Coordinates, angles, and geometry become tangible
  3. Problem Solving: Students can create visual solutions to programming challenges
  4. Creativity: Encourages experimentation and artistic expression through code
  5. 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 window
  • done() - Keep the window open until user closes it

Drawing Control

  • set_speed(speed) - Set drawing speed (1-10)
  • set_color(color) - Set drawing color
  • draw() - Display all shapes since last draw
  • redraw() - Clear screen and redraw everything

Shapes

  • circle(x, y, radius, stroke) - Draw a circle
  • rectdegrees(x, y, width, height, stroke, rotation_angle, rotation_point) - Draw a rectangle
  • line(x1, y1, x2, y2, stroke) - Draw a line between points
  • vector(x, y, length, angle, stroke) - Draw a line with angle
  • ellipse(x, y, width, height, stroke) - Draw an ellipse
  • arc(x, y, width, height, start_angle, end_angle, stroke) - Draw an arc

Polygons

  • polygon_begin(stroke) - Start creating a polygon
  • add_poly_point(x, y) - Add a point to the polygon
  • polygon_end() - Complete and draw the polygon

Text and Terminal

  • text(x, y, text, size, font) - Draw text
  • terminal_output(*message) - Display message in terminal
  • terminal_input(*prompt) - Get user input from terminal
  • terminal_clear() - Clear terminal area

Background Drawing

  • background_begin() - Start drawing background elements
  • background_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

drawly-1.1.6.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drawly-1.1.6-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file drawly-1.1.6.tar.gz.

File metadata

  • Download URL: drawly-1.1.6.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for drawly-1.1.6.tar.gz
Algorithm Hash digest
SHA256 6a0976a40d2e4f88f444ed3fa21abb5be943b6b8a1a1ed5255ac8efed742afd1
MD5 f1b4b5f553eb17bc1934549e292b2601
BLAKE2b-256 31a8cf83bb73e8da7682d7d470abcb8918c1ef2f66afc21650d146a99c0b9106

See more details on using hashes here.

File details

Details for the file drawly-1.1.6-py3-none-any.whl.

File metadata

  • Download URL: drawly-1.1.6-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for drawly-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 775d824632240244735c68f7a6f55d4d90987987c637c0f34b2fb7e5e1e2c29b
MD5 63bfd23dd0a1a42d57287bcf05ba50d1
BLAKE2b-256 733f950636c06c4cd5ce7473f83962e43b1bbf9e103ce7975d8c7c687e12114f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page