An engine for pygame
Project description
Phoenyx - Pygame Engine
Some simple classes in python
that could make your life much simplier. Relies on the pygame draw engine, based on the idea of the Processing language.
What it does
This library allows you to create graphical components in pygame
in a very few lines of code. It handles all color management, stroke weights and filling for you. It also provides a Vector class suitable for physics engines and mathematical drawings.
Please go and check pygame for their amazing work ! Additionnal kudos to Daniel Shiffman.
How to ?
Please refer to test.py on GitHub for a very simple but effective test file. You can now also read the helpme file for all available methods and obects.
from phoenyx import *
renderer: Renderer = Renderer(600, 600, "Perlin Noise Loop")
SHOWINFO = True
w = 10
noise = PerlinNoise(3, unbias=True)
t_offset = 0
spacing = 0.05
slider: Slider
def switch() -> None:
global SHOWINFO
SHOWINFO = not SHOWINFO
def hide() -> None:
global slider
if slider.is_hidden:
slider.reveal()
else:
slider.hide()
def setup() -> None:
global slider
renderer.create_menu("debug panel",
background=False,
text_color=0,
color=0,
show_info=switch,
hide_slider=hide)
slider = renderer.create_slider(450, 550, "speed", 0, 0.1, 0.02, 3)
renderer.no_stroke()
renderer.text_size = 15
renderer.text_color = "black"
def draw() -> None:
global slider, t_offset
y_offset = 0
for i in range(600 // w):
x_offset = 0
for j in range(600 // w):
d = noise(x_offset, y_offset, t_offset)
d = int((d+1) * 255 / 2)
renderer.fill = d
renderer.rect((i * w, j * w), w, w)
x_offset += spacing
y_offset += spacing
t_offset += slider.value
if SHOWINFO:
renderer.text(10, 10, f"fps : {round(renderer.fps)}")
if __name__ == "__main__":
renderer.run(draw, setup=setup)
Requirements
Obviously some distribution of python : python 3.9
or above is required.
You will also need pygame
in order to use the Engine and numpy
to use Vectors. Also if you are on Windows and numpy 1.19.4 happens not to work with the last Microsoft update, make sure to update the current distribution of numpy with pip install --upgrade numpy
.
Licenses
Phoenyx is licensed under the GPLv3. See LICENSE for more details. Phoenyx also includes the following components from other open source projects (see LICENSES folder for more):
- numpy licensed under the BSD 3-Clause "New" or "Revised" License
- pygame licended under the GNU LGPL version 2.1
Changelog
Please refer to the Changelog file for more detail.
This updates covers rotating and scaling of the display. It is worth noting that unlinke Processing, these methods only apply to what has been drawn on the screen rather than what will be drawn. These two methods are relative to the center of the screen (rotation around the center of the window, and scale from the center).
TODOs
option to hide buttons and sliders or to draw them only when neededoption of alts drawing methods for buttonskeyboard integration- scrollbars
and side menus interractive drawing- physics Sandbox
- widgets, canvas
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.