Graphics library
Project description
PIX (pixpy)
A graphics library with a python interface. Designed for learning and 2D game development.
Install
pip install pixpy
For Linux pip builds from source so you need a few dependecies;
sudo apt install libxinerama-dev libxi-dev libxrandr-dev libxcursor-dev
The Basics
The following is a full program that opens a window and draws a circle;
import pixpy as pix
screen = pix.open_display(width=1280, height=720)
screen.circle(center=(640,360), radius=300)
NOTE: This simple example works because if you try to exit before doing anything besides drawing, pix will "swap" the screen automatically to display what you drawn, and then leave the window open until you try to quit.
Normally you create your own main loop and do this yourself;
import pixpy as pix
screen = pix.open_display(width=1280, height=720)
x = 0
while pix.run_loop():
screen.clear()
screen.circle(center=(x,360), radius=x/4)
x += 1
screen.swap()
To read the keyboard and/or mouse, you can use is_pressed() or was_pressed()
import pixpy as pix
screen = pix.open_display(width=1280, height=720)
x = 0
moving = True
while pix.run_loop():
if pix.was_pressed(' '):
moving = not moving
if moving:
x += 1
screen.clear()
screen.circle(center=(x,360), radius=100)
screen.swap()
For more advanced needs you use events
import pixpy as pix
screen = pix.open_display(width=1280, height=720)
while pix.run_loop():
for e in pix.all_events():
if type(e) == pix.events.Click:
screen.filled_circle(center=e.pos, radius=15)
screen.swap()
NOTE: This will not produce the desired effect; since we are double buffering, the circles will be randomly drawn to either of the two buffers and appear to blink.
The Console
A major part of pix is the Console
In its simplest form, it can be used for text output
The console needs to be drawn to be visible, just like everything else.
con = pix.Console(cols=80, rows=50)
con.write('Hello\n')
con.render(screen)
console.read_line()
can be used to read lines of text. The result will be posted
as a TextEvent.
import pixpy as pix
screen = pix.open_display(width=1280, height=720)
con = pix.Console(cols=40, rows=25)
con.write('What is your name?\n')
con.read_line()
while pix.run_loop():
match pix.get_event():
case pix.event.Text(text):
con.write("Hello " + text)
con.read_line()
con.render(screen)
screen.swap()
The Core Objects
-
A Vec2 is a 2D dimensional vector with an x and y field that are used to represent 2D coordinates and sizes.
-
An Image is a reference to a rectangular array of pixels on the GPU, or in other words, a set of 4 UV coordinates (known to form a rectangle) and a texture reference.
-
The Screen represents the window or display.
-
A Context ties together rendering state with a rendering target. The Screen, and all Images, can be treated as context and can be drawn to.
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 Distributions
Hashes for pixpy-0.1.2-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f7286d6d00e9458a073b3d4f74aae742bf9feeaf790adf13bfca9b4bc525306 |
|
MD5 | 56d8268044674ae1a0f334daecd680a8 |
|
BLAKE2b-256 | 6a8548dc595f328f980ebe334eae10d0d10d59ac73f719e9726a69afc60f5c92 |
Hashes for pixpy-0.1.2-pp39-pypy39_pp73-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84fc1b0c166b5424928b7313bf4fb5c757c5b4a957c9332d06802919182ebf79 |
|
MD5 | 9c66aff1da5046e32a08b04298cccd58 |
|
BLAKE2b-256 | bfbba5709f3b5b87d1cdb1aad7c8a9e1684c49dfeced4470f5c9b952ba85ab34 |
Hashes for pixpy-0.1.2-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e0db92534299d7b3653a5957115950b5f878a7676e3d5b20b35d9f0581dfd66 |
|
MD5 | cf8d32e96338a4962e15adf08a6fcb37 |
|
BLAKE2b-256 | 445fda743e47a64e96a14602a153e7b5ec0dd1e19030a1ae2c1815ef11c1bbf8 |
Hashes for pixpy-0.1.2-pp38-pypy38_pp73-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88c2042ae5113341585310988ec65ca0317d563914ef189758cacd71d221c695 |
|
MD5 | 1a48093cb7846d7401e9c3f9a64f542a |
|
BLAKE2b-256 | a0a3ca076e6d4735f240dac645cf91ec29b0268c2ab792e0d00379dbc28fa26a |
Hashes for pixpy-0.1.2-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcf85d0d71af056d871441bc1c43ad6aec9db7ae8cd57361a08cfa4b5dc84e97 |
|
MD5 | afcfe3255ca3b78f0fcf89a41165101a |
|
BLAKE2b-256 | 8981ebaf90bc8bc49242eff3053420cc8427753af025e06bb1f5c899d43918f3 |
Hashes for pixpy-0.1.2-pp37-pypy37_pp73-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1614eab6ed3b859ad95cd888a07dfc75d8a299785baf124c266fef2b1e8488e |
|
MD5 | 123ffebd777aff34ea70560ff1c1d175 |
|
BLAKE2b-256 | 315e2d43ec185ca24983f9572c0ff255c1db91d3d507fcafdb465b47b664dd68 |
Hashes for pixpy-0.1.2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01de931ad4b9a8da8e4dcd4d2b60bcbecc5a244c1b7527a7fd472abf7dd8303a |
|
MD5 | 14419eb9733ed8c0df430033d2952b12 |
|
BLAKE2b-256 | c873c09f94139b300e3230f2040e4f576139a6ffab6237c410effe8cc30e8410 |
Hashes for pixpy-0.1.2-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ebf9353e4f0b1fe8be1c6258343073cf961d0126279760d67e101acdaa57e9b |
|
MD5 | ccc004db19b9c8f068d8c97ad2944bc8 |
|
BLAKE2b-256 | 92067add067683c693ebe0b7447c092d917b608f87ee0442b241538c35cd6fe2 |
Hashes for pixpy-0.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1748e8ea368a6a5182229a523ecbcde143739895289e84822b098c300d388e5 |
|
MD5 | bb9dde2d0d7ad86083a447f84419927b |
|
BLAKE2b-256 | 1be1d9fd084f88d3fd0fd3281d966d6b0e1dc36583a115bdbea5a5085359c7b1 |
Hashes for pixpy-0.1.2-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20c40df79023e8750d68d2f984157ee3c03401776457cd3a4eca01db6f282de4 |
|
MD5 | c7b3f3eed33eb2f0b9f8a1bf69c222fa |
|
BLAKE2b-256 | 62a28248bde7fb488271b477a40df162dc2bed441b64527f44c3f4442fc1a92e |
Hashes for pixpy-0.1.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4318b016f3aa10c7bca8aaec59e1afe9d310936675498e6d2051d493611ab957 |
|
MD5 | 7cfa4bad589de5b9fb1480f2a3665227 |
|
BLAKE2b-256 | 4c36a3181fcb024df8977a6cf40e29667f0d99507a43cb20897da4b76943110e |
Hashes for pixpy-0.1.2-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f63d5c869a59520f66805c584dbfa9a3af5a756cc36defdbbaa4cf59144be420 |
|
MD5 | fdd7ba8d8019c9086e059005b5cb3e16 |
|
BLAKE2b-256 | 4c8ee364f178129ec9dc025b36f1eb4590f15590068cb95a7239e04650115a6e |
Hashes for pixpy-0.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebc1a53841c0574afbb74fcca30a398d456dec047364eaf62d523ea956d11a9b |
|
MD5 | 81becfa9a254add86905a6aa9cec0a37 |
|
BLAKE2b-256 | 95e4911e05ad9b352c83827ee0c15682d11d7a7e308f6e640a0fab00d8cb142c |
Hashes for pixpy-0.1.2-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56d1e1fdbfb9ad3629c2faa555a4b282c236985e01362e07005a49b36badae0d |
|
MD5 | e98bf3186d543d9f1ee17f570600c07b |
|
BLAKE2b-256 | 132701c62227240c5950d5836199cbb5ed8dc17683f78d7fa7f71a304c49bcaa |
Hashes for pixpy-0.1.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d9f8565036bba56c4e2ec9c8e85d29155a1bbab22d46ecfeff129116bde759d |
|
MD5 | 0accb8c9f6f954580ee382e56cc21f76 |
|
BLAKE2b-256 | 4eb00c63104fc0c1a3c2b9c4b0f0e44f3c4bc59fd64c6a4f80afe40aa502189e |
Hashes for pixpy-0.1.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36068bd679bc47e8d34dcc7335acb7d513a502f2fbaf699a45f80b75e477015e |
|
MD5 | cf2485f9cd77b2cd31da7cd3e8d3da02 |
|
BLAKE2b-256 | e08499342a2f54383503af7b4a3d26b8bfcb0bf7bc9e95b5f4c546f9424b46aa |
Hashes for pixpy-0.1.2-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a84c13a9c912f27873e4b51e3364bda0dd7eb7a0a666eda8776625b82cedfb5 |
|
MD5 | c9cfbb382ffcce53e2f5617812037234 |
|
BLAKE2b-256 | 9e44f57f3ffe8e437dfa65949c1b6ca0231029e30a1e2586cd501da1c3358318 |
Hashes for pixpy-0.1.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea1b234dfbd6162f870cdd24df0cab1b70cc2fa85e84462f29c6c0c6c41e00ed |
|
MD5 | b73373efe8c08b7733c18b2f5e847341 |
|
BLAKE2b-256 | 6b337ec79e88f7f2a464ffaa29ff3548d551924eda57d2e86ffa53b91c1f9230 |
Hashes for pixpy-0.1.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f771ac1c04de14b70952ad76a47a8d93720849342eae726f700434b30a927a29 |
|
MD5 | 9387ed14ae63e0ecb16a1de8d17359cf |
|
BLAKE2b-256 | bf882c682fd23979fee9a98e2b37350b274f57916433dacc850a5e0ae107a0a3 |
Hashes for pixpy-0.1.2-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6cf911cf2e1288eca5b6a31b71196803eb062c71d465444558f5f4ce3a077d8 |
|
MD5 | 8cd905749fac9e205149cd203700e184 |
|
BLAKE2b-256 | ef5151760386440a0ad42bb4f354c0fda65e09d1181e8ddbee22377b7a099cbc |
Hashes for pixpy-0.1.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d776a6504fb4a5749a69aa72892e2c5e99f197082b5e2741db6a468eb841f6f |
|
MD5 | 05d8c822ce816cc4b4fb8e20eae496d7 |
|
BLAKE2b-256 | 204941a9c8064fa78d3527a15fce4fba28f9c52c19bb98774e004ab7b897fc8c |
Hashes for pixpy-0.1.2-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14bccebbd490e2eb2c56fc72cf19839b4d8cd37a6258ca75bb60b62ed7b2a2fc |
|
MD5 | 5e2f20d6db55b4d1094aaf31057b157d |
|
BLAKE2b-256 | 901b9aa5b771915af05dafd004c95afce59f4363b196a3059ef05649f4a19018 |
Hashes for pixpy-0.1.2-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18f71cf8064a0288aeb2d8b272c5c9632e2c198f26f9efb38ba40b33031990f6 |
|
MD5 | 79f78e78b86bb5f564fc80ccc23dc652 |
|
BLAKE2b-256 | bb9a3a557dbcd53dadefb524b3cdf119cd7f129a6ee97ebd7a341436e00ee1a0 |