Hardware-accelerated DOM-based UI & 2D Game Engine
Project description
Doodle Engine ๐จ๐
Hardware-Accelerated Hybrid C-Python UI & 2D Game Engine
Doodle is a high-performance, lightweight UI and 2D game engine combining a native C rendering core (powered by Raylib) with a highly reactive Python scripting layer.
By bypassing heavy browser runtimes (like Chromium/Electron), Doodle parses dynamic HTML-like templates and CSS stylesheets in a single pass directly to GPU-accelerated graphics, procedural audio synths, and collision meshes.
๐ Repository Organization
Doodle/
โโโ docs/ # Full reference specifications & requirements
โ โโโ cheatsheet.md # API & layout syntax quick reference
โ โโโ requirements.md # Engine specifications and architecture blueprint
โ โโโ unused_reference.md # Unused HTML/CSS/C engine features reference
โโโ doodle/ # Python package wrapper
โ โโโ __init__.py # Tween animations, reactive state binding, event emitter
โ โโโ cli.py # PyInstaller packager cli
โโโ examples/ # Game demonstrations
โ โโโ breakout/ # Breakout game demo
โ โโโ layout.html # Game view DOM nodes & inline handlers
โ โโโ styles.css # Retro arcade UI styles, flexbox, and crt shaders
โ โโโ shaders/ # Custom GLSL Fragment shaders
โ โโโ main.py # Collision, input, and game state script
โโโ src/ # C-Extension Core (complies to _doodle.pyd)
โ โโโ setup.py # Setuptools compilation script
โ โโโ expose_raylib.c # Python-to-C bindings, Raylib window, and particle pool
โ โโโ mparser.h / .c # n-ary DOM parser, CSS registry handler, and layout box solver
โ โโโ dutils.h / .c # Custom color parser, fast unit converter, and math helpers
โ โโโ daudio.h / .c # Polyphonic synth, multi-voice ADSR envelope generator
โโโ third_party/ # Static Raylib binaries & dependencies
โโโ README.md # You are here!
๐ ๏ธ Getting Started & Compilation
1. Requirements
- OS: Windows (x64) / linux
- Python: Python 3.11+ (with virtual environment capability)
- C Toolchain: MSYS2/MinGW-w64 (
C:\msys64\ucrt64\binforgccand compilation libraries) / linux cc compiler
2. Quick Setup & Build
From the repository root directory, run the setuptools compilation with your virtual environment's python. Specify the compiler:
# Add GCC to PATH (if not global)
$env:PATH = "C:\msys64\ucrt64\bin;" + $env:PATH
# Compile the native C extension
cd src
..\.venv\Scripts\python.exe setup.py build_ext --inplace -c mingw32
# Copy the compiled pyd module to the doodle library
cd ..
Copy-Item -Path "src\_doodle.cp311-win_amd64.pyd" -Destination "doodle\_doodle.pyd" -Force
3. Run the Breakout Demo
Launch the breakout game:
cd examples/breakout
..\..\.venv\Scripts\python.exe main.py
๐๏ธ XML Markup (layout.html) & CSS (styles.css)
Doodle supports layout-driven layouts with traditional tag structures and inline event bindings.
Core Elements
<view>: Structural container. Standard flex container or a 2D camera boundary using<view camera="true">.<text>: Text layout with reactive state-bound variables likeSCORE: {{ score }}.<image>: Renders cached bitmaps usingsrc="...".<button>: Clickable target with mouse state callbacks.<circle>: Renders shapes usingradiusandcolorparameters.<line>: Renders vectors usingx2,y2,thickness, andcolor.
Event Hooks
Directly attach Python functions inline:
onclick="python_function_name"onhover="python_function_name"
Layout Styles
- Sizing Rules:
width/heightsupport pixels (100px), percentages (50%), growth parameters (grow), and content sizing (fit). - Flexbox Attributes:
display: flex,flex-direction(row|column),justify-content(center|space-between|space-around),align-items. - Cosmetics:
background-color,border-radius,border-color,border-width,opacity,font-family,font-size. - Juice Shaders: Add custom GLSL fragment shaders directly to views using
shader-path: "shaders/crt.fs".
๐ Python OOP APIs
Initialization
import doodle
# Game state passed for template rendering
state = {"score": 0, "lives": 3}
doodle.run(
layout="layout.html",
style="styles.css",
width=800,
height=600,
title="Game Window",
state=state
)
Node Manipulation
# Fetch reference
paddle = doodle.get_node("paddle")
# Read/Write positions
paddle.position = (350, 500)
paddle.x += 10.0
# Easing animations
doodle.animate("paddle", target_x=350, target_y=500, duration=0.4, ease="quad_out")
Input Polling
# Keys
doodle.is_key_down(263) # Left arrow key code
doodle.is_key_pressed(82) # R key code
# Mouse
mx = doodle.get_mouse_x()
doodle.set_mouse_cursor(4) # Changes mouse pointer style
๐ Polyphonic Procedural Sound Synthesizer
Doodle includes an integrated multi-voice synthesizer utilizing ADSR Envelopes to play retro sound waves without lagging the update tick loop.
# Play procedural tone
doodle.play_synth(
freq=440.0,
duration=0.15,
wave_type=doodle.WAVE_TRIANGLE,
attack=0.01,
decay=0.05,
sustain=0.3,
release=0.05
)
Wave Types: WAVE_SINE (0), WAVE_SQUARE (1), WAVE_TRIANGLE (2), WAVE_SAWTOOTH (3), WAVE_NOISE (4)
โก Performance Optimizations
Doodle is engineered for maximum performance, featuring multiple custom optimizations:
- Single-Item DOM Lookup Cache: Node lookup (
FindNodeById) caches the pointer of the last requested node. Repetitive state checks (like checking click and hover events in the same frame) resolve in $O(1)$ without scanning the DOM tree. - Precompiled Format Templating: Template variables
{{ score }}are compiled once into native Python{score}string format structures, converting reactive updates from regex replacements to C-speed string builders. - Loop Division Elimination: Particle shaders and polyphonic audio generators use cached precalculated inverse values (
inv_max_lifetimeandphase_increment) to replace expensive division operations with single-clock multiplication instructions. - Square Wave Optimization: Square waves skip standard trignometric
sinfcalculations, computing high-low status directly from phase boundaries.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
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 doodle_ui-0.1.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: doodle_ui-0.1.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 577.6 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeff1da8ccfe7a86aa5bc42f9dacc729717320e293d792deea7f2f2c442e77c6
|
|
| MD5 |
7cd8525bca38043f63db27f65f9736b6
|
|
| BLAKE2b-256 |
99cf7ae93796cd303ab29389d29345fa2cb62c7621d937a62079236f3ffcc635
|
File details
Details for the file doodle_ui-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: doodle_ui-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.8 MB
- Tags: CPython 3.11, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ec4b6dee6bf9eb175e548bee1211fd61cad6938d056368ea92db961e3f00914
|
|
| MD5 |
e7fba81905daa80c777c1e6a1c7ba23a
|
|
| BLAKE2b-256 |
43f640d82706d253a7ab2b7287712ebc984209819cf178987f028dc01dfa29a4
|
Provenance
The following attestation bundles were made for doodle_ui-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl:
Publisher:
release.yml on DUDDLEGOD/Doodle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
doodle_ui-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl -
Subject digest:
7ec4b6dee6bf9eb175e548bee1211fd61cad6938d056368ea92db961e3f00914 - Sigstore transparency entry: 1880686536
- Sigstore integration time:
-
Permalink:
DUDDLEGOD/Doodle@3f08a23de8f6993a90fe3ba5ee229add635149f3 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/DUDDLEGOD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3f08a23de8f6993a90fe3ba5ee229add635149f3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file doodle_ui-0.1.0-cp311-cp311-musllinux_1_2_i686.whl.
File metadata
- Download URL: doodle_ui-0.1.0-cp311-cp311-musllinux_1_2_i686.whl
- Upload date:
- Size: 1.8 MB
- Tags: CPython 3.11, musllinux: musl 1.2+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50155cb4bff71c9df776d5da25d67d056a39073b3102954799530f5a76626263
|
|
| MD5 |
a645e6f4eba51cbe00e484de3460061f
|
|
| BLAKE2b-256 |
fd2105d2b3869e72d8695118c0681988c8f6848927f19171eda799ecef1caca9
|
Provenance
The following attestation bundles were made for doodle_ui-0.1.0-cp311-cp311-musllinux_1_2_i686.whl:
Publisher:
release.yml on DUDDLEGOD/Doodle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
doodle_ui-0.1.0-cp311-cp311-musllinux_1_2_i686.whl -
Subject digest:
50155cb4bff71c9df776d5da25d67d056a39073b3102954799530f5a76626263 - Sigstore transparency entry: 1880687030
- Sigstore integration time:
-
Permalink:
DUDDLEGOD/Doodle@3f08a23de8f6993a90fe3ba5ee229add635149f3 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/DUDDLEGOD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3f08a23de8f6993a90fe3ba5ee229add635149f3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file doodle_ui-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: doodle_ui-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 909.9 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06fea729230f8ff60f9677a99c469252f86c393e758656dcd167ce201fe47054
|
|
| MD5 |
39a540c1a7ab400d8a62a4a8474a5525
|
|
| BLAKE2b-256 |
4fb9e345e10719d359cacd38cefb57393e1a507a5d45aab4aa0319f0e4545eb7
|
Provenance
The following attestation bundles were made for doodle_ui-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on DUDDLEGOD/Doodle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
doodle_ui-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
06fea729230f8ff60f9677a99c469252f86c393e758656dcd167ce201fe47054 - Sigstore transparency entry: 1880687483
- Sigstore integration time:
-
Permalink:
DUDDLEGOD/Doodle@3f08a23de8f6993a90fe3ba5ee229add635149f3 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/DUDDLEGOD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3f08a23de8f6993a90fe3ba5ee229add635149f3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file doodle_ui-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: doodle_ui-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 657.8 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a36741c1e329a3d838baf8415786fe565ac863767fe56e085792a0d2d933a96
|
|
| MD5 |
4223126ccb0b392f03c3a42306ef3398
|
|
| BLAKE2b-256 |
c8325aff43752d3fd0e13fedcbd65edbfa4eb727a150599f93be2a96d3b7b0ee
|
Provenance
The following attestation bundles were made for doodle_ui-0.1.0-cp311-cp311-macosx_11_0_arm64.whl:
Publisher:
release.yml on DUDDLEGOD/Doodle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
doodle_ui-0.1.0-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
9a36741c1e329a3d838baf8415786fe565ac863767fe56e085792a0d2d933a96 - Sigstore transparency entry: 1880686427
- Sigstore integration time:
-
Permalink:
DUDDLEGOD/Doodle@3f08a23de8f6993a90fe3ba5ee229add635149f3 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/DUDDLEGOD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3f08a23de8f6993a90fe3ba5ee229add635149f3 -
Trigger Event:
workflow_dispatch
-
Statement type: