Minimalist star pattern generator using optimized one-liners.
Project description
makeastar
A minimalist Python package for printing star patterns with zero boilerplate code.
Overview
makeastar eliminates the need for writing repetitive loops when creating ASCII star patterns. Perfect for Python beginners learning loops or developers who need quick ASCII art generation.
Features
- Zero Boilerplate: Single function calls replace complex nested loops
- Type-Safe: Full type hints with Union types for flexible input
- Optimized Performance: Uses
sys.stdout.write, generator expressions, and efficient algorithms - Multilingual Support: English and Korean aliases (including phonetic and Choseong variations)
- Flexible Input: Accepts integers, floats, strings - handles commas, dots, spaces gracefully
- Production Ready: Comprehensive unit tests, CI/CD with GitHub Actions
- Lightweight: Minimal dependencies, pure Python implementation
Requirements
- Python 3.8 or higher
Installation
From PyPI (recommended):
pip install makeastar
From source:
git clone https://github.com/hslcrb/pypack_makeastar.git
cd pypack_makeastar
pip install .
Quick Start
import star
# Basic usage
star.pyramid(5)
star.diamond(7)
star.triangle(10)
# Korean aliases
star.피라미드(5)
star.다이아몬드(7)
# Flexible input handling
star.pyramid("5") # String input
star.pyramid(5.8) # Float input (auto-converted)
star.draw("pyramid 5") # Command string parsing
star.draw("triangle, 10, 5") # Handles various separators
Supported Patterns
All functions support custom width/height and character parameters.
1. Triangle (Left-aligned)
star.triangle(5)
# Output:
# *
# **
# ***
# ****
# *****
Aliases: samgak, tri, 삼각형, 삼, ㅅㄱ, ㅅㄱㅎ
2. Right Triangle (Right-aligned)
star.right_triangle(5)
# Output:
# *
# **
# ***
# ****
# *****
Aliases: usamgak, rtri, 우측삼각형, 오른쪽삼각형, 우삼, ㅇㅅㄱ, ㅇㅊㅅㄱㅎ, ㅇㄹㅉㅅㄱㅎ
3. Inverted Triangle
star.inverted(5)
# Output:
# *****
# ****
# ***
# **
# *
Aliases: yeoksamgak, inv, 역삼각형, 역삼, ㅇㅅ, ㅇㅅㄱㅎ
4. Inverted Right Triangle
star.inverted_right(5)
# Output:
# *****
# ****
# ***
# **
# *
Aliases: yeokusamgak, rtinv, rinv, 우측역삼각형, 오른쪽역삼각형, 우역, ㅇㅇ, ㅇㅊㅇㅅㄱㅎ, ㅇㄹㅉㅇㅅㄱㅎ
5. Pyramid
star.pyramid(5)
# Output:
# *
# ***
# *****
# *******
# *********
Aliases: pyra, 피라미드, 피라, ㅍㄹ, ㅍㄹㅁㄷ
6. Diamond
star.diamond(5)
# Output:
# *
# ***
# *****
# *******
# *********
# *******
# *****
# ***
# *
Aliases: dia, 다이아몬드, 다이아, 다, ㄷㅇ, ㄷㅇㅇㅁㄷ
7. Hourglass
star.hourglass(5)
# Output:
# *********
# *******
# *****
# ***
# *
# ***
# *****
# *******
# *********
Aliases: morae, 모래시계, 모, ㅁㄹ, ㅁㄹㅅㄱ
8. Arrow
star.arrow(5)
# Output:
# *
# **
# ***
# ****
# *****
# ****
# ***
# **
# *
Aliases: hwasal, 화살표, 화, ㅎㅅ, ㅎㅅㅍ
Advanced Usage
Custom Dimensions
# Triangle with custom width and height
star.triangle(10, 5) # Width=10, Height=5
# When height is omitted, it defaults to width
star.triangle(7) # Width=7, Height=7
Custom Characters
star.pyramid(5, char='#')
star.diamond(7, char='@')
Flexible Input Types
# All of these work identically
star.pyramid(5)
star.pyramid("5")
star.pyramid(5.0)
star.pyramid(5.9) # Auto-converts to 5
Command String Parsing
The draw() function accepts flexible command strings:
star.draw("pyramid 5")
star.draw("triangle, 10, 5")
star.draw("diamond.7")
star.draw("arrow 3")
Using Korean Aliases
# Full Korean names
star.피라미드(5)
star.다이아몬드(7)
# Short forms
star.피라(5)
star.다(7)
# Choseong (initial consonants)
star.ㅍㄹ(5)
star.ㄷㅇ(7)
# Using Korean package name
import 별
별.피라미드(5)
API Reference
Triangle Functions
All triangle functions accept:
width(int | str | float): Width of the triangleheight(int | str | float | None): Height (defaults to width if None)char(str): Character to use (default: '*')
Functions:
triangle(width, height=None, char='*')- Left-alignedright_triangle(width, height=None, char='*')- Right-alignedinverted(width, height=None, char='*')- Inverted left-alignedinverted_right(width, height=None, char='*')- Inverted right-aligned
Symmetric Shape Functions
All symmetric functions accept:
n(int | str | float): Size parameter (default: 5)char(str): Character to use (default: '*')
Functions:
pyramid(n=5, char='*')- Centered pyramiddiamond(n=5, char='*')- Diamond shapehourglass(n=5, char='*')- Hourglass shapearrow(n=5, char='*')- Right-pointing arrow
Utility Functions
draw(command: str)- Parse and execute command strings
Testing
Run the test suite:
python -m unittest discover tests
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Author
Rheehose (Rhee Creative)
- Email: rheehose@rheehose.com
- GitHub: @hslcrb
- Copyright 2008-2026
License
This project is licensed under the MIT License. See LICENSE for details.
Changelog
v1.0 (2026-01-15)
- Initial stable release
- 8 pattern types with full Korean/English aliases
- Flexible input parsing (strings, floats, various separators)
- Type hints and optimized performance
- Comprehensive unit tests
- GitHub Actions CI/CD
Project details
Release history Release notifications | RSS feed
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 makeastar-1.0.tar.gz.
File metadata
- Download URL: makeastar-1.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a987626ec5edecc3641aa46fc48cf205956aa895715ba1add1d91906bcbda9d
|
|
| MD5 |
ecd41b33042ceeb559a04920c5858e23
|
|
| BLAKE2b-256 |
91d44d5e33e0f3a49abd6f7698d4f831b61f08df5225dd1b99e0de99110e8cb7
|
File details
Details for the file makeastar-1.0-py3-none-any.whl.
File metadata
- Download URL: makeastar-1.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
314f9291abbfd05cbfc23ea6fd3a09819c3de21edaa9b4e28134aa39de525598
|
|
| MD5 |
87c5bed564b326b5b7fbe519aa1f8bd0
|
|
| BLAKE2b-256 |
9d93c97184fa30382a9d1b1fcc0bbfb4879aad4db34d70efc967c2bef46d002a
|