Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@ jobs:
test:
name: Compile and test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Every version pygame ships a prebuilt wheel for (see
# https://pypi.org/project/pygame/#files), matching requires-python
# in pyproject.toml. Anything outside this range would force a
# from-source build that fails on the runner (missing SDL/freetype
# dev headers), so the declared floor and the tested floor must
# stay in lockstep.
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
# Pinned rather than "3.x": pygame only ships prebuilt wheels up to
# cp313 (see https://pypi.org/project/pygame/#files), and installing
# on a newer interpreter forces a from-source build that fails on
# the runner (missing SDL/freetype dev headers).
python-version: "3.13"
python-version: ${{ matrix.python-version }}

- name: Install package with test dependencies
run: python -m pip install --upgrade pip && python -m pip install -e .[test]
Expand Down
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@
# Graphik
This library assists developers with graphics programming.

## Installation
```bash
pip install graphik
```

## Usage
```python
import pygame
from preponderous.graphik import Graphik

pygame.init()
gameDisplay = pygame.display.set_mode((900, 600))
graphik = Graphik(gameDisplay)

graphik.drawRectangle(100, 100, 200, 50, Graphik.blue)
graphik.drawText("Hello, world!", 200, 125, 24, Graphik.white)
graphik.drawButton(100, 200, 200, 50, Graphik.green, Graphik.black, 24, "Click me", lambda: print("clicked"))
graphik.drawImage("path/to/image.png", 100, 300, 200, 200)
```

Public `Graphik` methods:
- `Graphik(gameDisplay=None)` — construct a helper bound to a pygame display surface (creates a default 900x600 window if none is given).
- `getGameDisplay()` — returns the bound display surface.
- `getVersion()` — returns the installed graphik version string.
- `drawRectangle(xpos, ypos, width, height, color)`
- `drawText(text, xpos, ypos, size, color)`
- `drawButton(xpos, ypos, width, height, colorBox, colorText, sizeText, text, function)` — draws a rectangle and centered text, and calls `function()` on click.
- `drawImage(filePath, xpos, ypos, width, height)`

Color constants: `Graphik.black`, `Graphik.white`, `Graphik.red`, `Graphik.green`, `Graphik.blue`.

## Dependencies
- pygame

## Projects
[Projects that utilize this library](https://github.com/Preponderous-Software/Graphik/wiki/Projects)
[Projects that utilize this library](https://github.com/Stephenson-Software/graphik/wiki/Projects)

## 📄 License

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "graphik"
dynamic = ["version"]
description = "Simple helper methods for graphics programming with pygame."
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"
license = { text = "MIT" }
authors = [{ name = "Daniel McCoy Stephenson" }]
dependencies = ["pygame"]
Expand Down
Loading