A Jupylet game object.
width (int) – The width of the game canvas in pixels.
height (int) – The height of the game canvas in pixels.
mode (str) – Game mode can be ‘jupyter’ for running the game in a Jupyter notebook, ‘window’ for running the game in a Python script, ‘hidden’ for machine learning, or ‘auto’ for let Jupylet choose the appropriate mode automatically.
resource_dir (path) – A path to the directory of the game assets.
quality (int) – Quality of game video compression specified as an integer between 10 and 100 for when the Jupyter notebook is run on a remote server.
Start the game.
If the game is run in a Jupyter notebook, the call will return immedately with the canvas object on which the game frames will be redrawn, otherwise the call will block until the game is done.
interval (float) – The interval in seconds between frame redraws.
The ipywidgets object on which the game will be redrawn.
ipywidgets.widgets.widget_media.Image
Stop given handler from running. If no handler is given stop the game.
foo (function) – The handler to stop running.
Start the default MIDI handler with given sound object as its intrument.
s (jupylet.audio.sound.Sound) – The sound object to use as MIDI instrument.
Return game canvas content as upside-down-flipped numpy array.
The content of the game canvas an a Numpy array with the shape H x W x 4 corresponding to an RGBA bitmap image.
numpy.ndarray
Scale window size so that its biggest dimension (either width or height) is px pixels.
This is useful for RL applications since smaller windows render faster.
px (int) – The target size of the rescaled canvas in pixels.
Save the state of given game objects to disk.
name (str) – If explicit path is not given, name will be used to automatically generate a filename.
path (str, optional) – An explicit path to use for file.
*args – A list of object implementing the save_state() method, to save to disk.
path to saved file.
str
Load the state of given game objects from disk.
Will also render the scene once all objects are loaded.
path (str, optional) – An explicit path to use for file.
*args – A list of object implementing the load_state() method, to load from disk.
Returns an output ipywidget to which log messages will be printed.
an output ipywidget for log messages.
ipywidgets.widgets.widget_output.Output
Schedule an async function to run repeatedly in a loop.
The function is scheduled to run based on its name, so updating its definition in a Jupyter notebook will cause the new definition to replace the previous one.
The new definition will kick in once the current iteration through the loop completes.
times (int) – the number of times to run through the loop, or indefinately if 0.
Schedule an async function to run repeatedly in a loop.
The function is scheduled to run based on its name, so updating its definition in a Jupyter notebook will cause the new definition to replace the previous one.
The new definition will kick in immediately.
times (int) – the number of times to run through the loop, or indefinately if 0.
Schedule a function to run after the specified delay.
The function is scheduled to run based on its name, so updating its definition in a Jupyter notebook will cause the new definition to replace the previous one.
delay (float) – the schedule delay in seconds.
Schedule a function to run after the specified delay.
The function is scheduled to run based on its name, so updating its definition in a Jupyter notebook will cause the new definition to replace the previous one.
delay (float) – the schedule delay in seconds.
Reports the current mouse cursor position in the window
x (int) – X postion of the mouse cursor
y (int) – Y position of the mouse cursor
dx (int) – X delta postion
dy (int) – Y delta position
Called when a mouse button in pressed
x (int) – X position the press ocurred
y (int) – Y position the press ocurred
button (int) – 1 = Left button, 2 = right button
Called when a mouse button in released
x (int) – X position the release ocurred
y (int) – Y position the release ocurred
button (int) – 1 = Left button, 2 = right button
Handle the on_key event.
key (int) – An integer specifying the key.
action (int) – An integer specifying whether the key was pressed or released.
modifiers (dict) – A dictionary specifying the state the CTRL, ALT, and SHIFT, keys at the time of the event.
Handle the on_render event.
current_time (float) – Time in seconds since start of game.
delta (float) – Time in seconds since previous call to handler.
Function decorator for an event handler.
Called when the window is closed
Loads a shader program.
Note that path should only be used if all shaders are defined in the same glsl file separated by defines.
If the path is relative the resource system is used expecting one or more resource directories to be registered first. Absolute paths will attempt to load the file directly.
path (str) – Path to a single glsl file
vertex_shader (str) – Path to vertex shader
geometry_shader (str) – Path to geometry shader
fragment_shader (str) – Path to fragment shader
tess_control_shader (str) – Path to tessellation control shader
tess_evaluation_shader (str) – Path to tessellation eval shader
defines (dict) – #define
values to replace in the shader source. Example: {'VALUE1': 10, 'VALUE2': '3.1415'}
.
varyings (List[str]) – Out attribute names for transform shaders
The program instance
moderngl.Program
Width of game canvas in pixels.
bool
Height of game canvas in pixels.
bool
A 2D game sprite.
img – either a path to a sprite image, a PIL Image object, or a numpy array with image pixel data.
x (float) – The x position for the sprite.
y (float) – The y position for the sprite.
scale (float) – value by which to scale the sprite up or down.
angle (float) – clockwise rotation of the sprite in degrees.
anchor_x (float or str) – either ‘left’, ‘center’ or ‘right’ or a value between 0.0 (for left) and 1.0 (for right) indicating the anchor point inside the sprite along its x axis.
anchor_y (float or str) – either ‘bottom’, ‘center’ or ‘top’ or a value between 0.0 (for bottom) and 1.0 (for top) indicating the anchor point inside the sprite along its y axis.
color (str or 3-tuple) – color by which to tint sprite image. Could be a color name, color hex notation, or a 3-tuple.
flip (bool) – flip the sprite upside down or not.
Render sprite to canvas.
shader (moderngl.program.Program, optional) – OpenGL shader program to use for rendering.
Render sprite to canvas - this is an alias to Sprite.render().
Set the anchor point of the sprite.
The anchor is a point in the sprite that is used for rotation and positioning. Imagine a pin going through the sprite and that you use this pin to position the sprite on the canvas and to rotate it. The point at which the pin goes through the texture is the anchor point.
The anchor point is set separately for the x axis, and for the y axis.
ax (str or float) – the x anchor can be one of ‘left’, ‘center’, ‘right’, or a float value between 0.0 (left) and 1.0 (right).
ay (str or float) – the y anchor can be one of ‘bottom’, ‘center’, ‘top’, or a float value between 0.0 (bottom) and 1.0 (top).
Compute collisions with given sprite.
o (Sprite) – The other sprite with which to check collisions.
An 2d array with collision points or an empty array if sprites do not collide.
numpy.ndarray
Compute the distance to another sprite or coordinate.
o (Sprite, optional) – Other sprite to compute distance to.
pos (tuple, optional) – An (x, y) coordinate to compute distance to.
Distance in pixels.
float
Compute clockwise angle in degrees to another sprite or coordinate.
o (Sprite, optional) – Other sprite to compute angle to.
pos (tuple, optional) – An (x, y) coordinate to compute angle to.
Angle in degrees.
float
Wrap sprite’s coordinates around given canvas width and height.
Use this method to make the sprite come back from one side of the canvas if it goes out from the opposite side.
width (float) – The canvas width to wrap around.
height (float) – The canvas height to wrap around.
margin (float, optional) – An extra margin to add around canvas before wrapping the sprite around to the opposite side.
Clip sprite’s coordinates to given canvas width and height.
Use this method to prevent the sprite from going out of the canvas.
width (float) – The canvas width to clip to.
height (float) – The canvas height to clip to.
margin (float, optional) – An extra margin to add around canvas before clipping the sprite’s coordinates.
Get a dictionary of properties defining the object state.
A dictionary of properties.
dict
Set object state from given dictionary of properties.
s (dict) – A dictionary of properties previously returned by a call to get_state()
.
Scale of sprite.
The scale equals the rendered width in pixels divided by the actual width of the texture. E.g a scale of 2 will make the sprite appear twice as big than it originally is, and a scale of 1/2 twice as small.
float
The x coordinate of the anchor position.
float
The y coordinate of anchor position.
float
The rotation angle around the anchor in degrees.
float
Width in pixels after scaling.
float
Height in pixels after scaling.
float
Bitmap image of sprite.
You can set this property with a new image or with a path to an image on disk to change the current sprite image.
PIL.Image.Image
Get the top coordinate of the sprite’s bounding box.
float
Get the right coordinate of the sprite’s bounding box.
float
Get the bottom coordinate of the sprite’s bounding box.
float
Get the left coordinate of the sprite’s bounding box.
float
Get the radius of a circle containing the sprite’s bounding box.
float
Get or set the opacity of the sprite.
Setting opacity to 0 would render the sprite completely transparent. Settint opacity to 1 would render the sprite completely opaque.
float
Get or set the color of the sprite.
The sprite color will be multiplied by the color values of its bitmap image.
The color can be specified by name (e.g. ‘white’) or in hex notation (e.g ‘#cc4488’) or as a 4-tuple or glm.vec4 value.
glm.vec4
Flip the image upside down while rendering.
bool
Compute mipmap textures when first loading the sprite image.
bool
Auto crop the image to its bounding box when first loading the sprite image.
bool
Use anisotropic filtering when rendering the sprite image.
float
A text label.
Since a text label is actually implemented as a 2D sprite, it has all the functionality and methods of a Sprite.
text (str) – text to render as label.
font (path) – path to a true type or open type font.
font_size (float) – font size to use.
line_height (float) – determines the distance between lines.
align (str) – the desired alignment for the text label. May be one of ‘left’, ‘center’, and ‘right’.
color (str or 3-tuple) – a color name, color hex notation, or a 3-tuple. specifying the color for the text label.
x (float) – the x position for the label.
y (float) – the y position for the label.
angle (float) – clockwise rotation of the label in degrees.
anchor_x (float or str) – either ‘left’, ‘center’ or ‘right’ or a value between 0.0 (for left) and 1.0 (for right) indicating the anchor point inside the label along its x axis.
anchor_y (float or str) – either ‘bottom’, ‘baseline’, ‘center’ or ‘top’ or a value between 0.0 (for bottom) and 1.0 (for top) indicating the anchor point inside the label along its y axis.
Text to render as label.
str
Path to a true type or open type font.
str
Font size to use.
float
Determines the distance between lines.
float
The desired alignment for the text label. May be one of ‘left’, ‘center’, and ‘right’.
str
Load a Blender scene or model exported with the Blender glTF 2.0 exporter.
The Blender scene should be exported using the glTF Separate (.gltf + .bin + textures) format. In the exporter make sure to check the Apply Modifiers, UVs, and Normals, options checkboxes.
Note that in principle this function should be able to load any gltf 2.0 scene, however it was only tested with and tuned to load scenes exported with Blender 2.83 and Blender 3.4.
path (str) – path to glTF 2.0 file.
A scene object.
A 3D Scene object.
While it is possible to create a Scene object manually, it is probably a better idea to call jupylet.loader.load_blender_gltf()
instead.
Render scene to canvas.
shader (moderngl.program.Program, optional) – OpenGL shader program to use for rendering.
A list of meshes.
list
A list of lights.
list
A list of cameras.
list
A list of materials.
list
A Skybox object.
Skybox
Set to True to enable shadows.
bool
Name of scene.
str
A 3D Mesh object.
While it is possible to create a Mesh object manually, it is probably a better idea to call jupylet.loader.load_blender_gltf()
instead.
Move by given displacement in local coordinate system.
xyz (glm.vec3) – Displacement.
Move by given displacement in global coordinate system.
xyz (glm.vec3) – Displacement.
Rotate counter clockwise by given angle around given axis in local coordinate system.
angle (float) – Angle in radians.
axis (glm.vec3) – Rotation axis.
Rotate counter clockwise by given angle around given axis in global coordinate system.
angle (float) – Angle in radians.
axis (glm.vec3) – Rotation axis.
Return the local front (+z) axis.
glm.vec3
Return the local up (+y) axis.
glm.vec3
List of primitives the mesh consists of.
list
List of child meshes.
list
Set to False to hide mesh from view.
bool
Name of mesh.
str
Start an audio application.
An audio application is need to run live loops.
resource_dir (str) – Path to root of resource dir, for samples, etc…
A running application object.
Set the tempo to the given beats per minute.
bpm (float) – Beats per minute.
Set the note value representing one beat.
v (float) – Note value.
Set the instrument to use in subsequent calls to play()
.
You can supply key/value pairs of properties to modify in the given instrument. If you do, the instrument will be copied first, and the modifications will be applied to the new copy.
sound (GatedSound) – Instrument to use.
**kwargs – Properties of intrument to modify.
Play given note polyphonically with the instrument previously set by call to use()
.
You can supply key/value pairs of properties to modify in the given instrument.
note (float) – Note to play in units of semitones where 60 is middle C.
duration (float, optional) – Duration to play note, in whole notes.
**kwargs – Properties of intrument to modify.
Get some sleep.
Example
@app.sonic_live_loop2 async def boom_pam(): use(tb303, resonance=8, decay=1/8, cutoff=48, amp=1) play(C2, 1/8) await sleep(1/4) play(C3, 1/8) await sleep(1/4)
duration (float) – Duration to sleep in whole notes.
A sleep coroutine to use with await.
coroutine
Fundamental requency of sound object.
float
Output amplitude - a value between 0 and 1.
float
Balance between left (-1) and right (1) output channels.
float
Waveform to generate - one of sine, triangle, sawtooth, or square.
str
Set to -1 to flip sawtooth waveform upside down.
float
The fraction of the square waveform cycle its value is 1.
float
Path to audio file.
str
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4