Skip to content

Commit 27b8c71

Browse files
committed
feat: Add 6 new ZRTL plugins for graphics, windowing, and media
New plugins: - zrtl_window: High-level cross-platform windowing API (SDL2 backend) - zrtl_sdl: Low-level SDL2 bindings for windows, events, rendering - zrtl_paint: 2D software rasterization with tiny-skia - zrtl_svg: SVG parsing and rendering with resvg/usvg - zrtl_image: Image encoding/decoding (PNG, JPEG, GIF, WebP, etc.) - zrtl_xml: XML parsing and generation with quick-xml Key features: - Thread-local storage pattern for SDL2's non-thread-safe types - Paint canvas buffer access for SDL/Window rendering integration - $Window$blit and $Sdl$blit_rgba for rendering paint canvases - Full event handling (keyboard, mouse, window events) - Anti-aliased 2D drawing primitives with transforms
1 parent 9421a51 commit 27b8c71

20 files changed

Lines changed: 5375 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
[workspace]
22
resolver = "2"
3-
members = ["crates/typed_ast", "crates/compiler", "crates/whirlwind_adapter", "crates/zyntax_cli", "crates/runtime", "crates/zyntax_plugin_macros", "crates/zyn_peg", "crates/haxe_zyntax_runtime", "crates/zyntax_embed", "sdk/zrtl", "sdk/zrtl_macros"]
3+
members = [
4+
"crates/typed_ast",
5+
"crates/compiler",
6+
"crates/whirlwind_adapter",
7+
"crates/zyntax_cli",
8+
"crates/runtime",
9+
"crates/zyntax_plugin_macros",
10+
"crates/zyn_peg",
11+
"crates/haxe_zyntax_runtime",
12+
"crates/zyntax_embed",
13+
"sdk/zrtl",
14+
"sdk/zrtl_macros",
15+
]
416

517

618
[workspace.dependencies]

plugins/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ members = [
1717
"zrtl_compress",
1818
"zrtl_sql",
1919
"zrtl_websocket",
20+
"zrtl_window",
21+
"zrtl_image",
22+
"zrtl_xml",
23+
"zrtl_paint",
24+
"zrtl_svg",
25+
"zrtl_sdl",
2026
]
2127

2228
[workspace.dependencies]

plugins/zrtl_image/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "zrtl_image"
3+
version = "0.1.0"
4+
edition = "2021"
5+
description = "ZRTL Image plugin - image encoding/decoding for common formats"
6+
license = "Apache-2.0"
7+
8+
[lib]
9+
crate-type = ["cdylib", "staticlib", "rlib"]
10+
11+
[dependencies]
12+
zrtl = { path = "../../sdk/zrtl" }
13+
image = { version = "0.24", default-features = false, features = ["png", "jpeg", "gif", "webp", "bmp", "ico", "tiff"] }

plugins/zrtl_image/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# zrtl_image
2+
3+
Image encoding and decoding for common formats.
4+
5+
## Supported Formats
6+
7+
- PNG, JPEG, GIF, WebP, BMP, ICO, TIFF
8+
9+
## Functions
10+
11+
### Loading/Saving
12+
- `$Image$load(path: String) -> Handle` - Load image from file
13+
- `$Image$load_bytes(data: Array[u8], format: i32) -> Handle` - Load from byte array
14+
- `$Image$save(handle: Handle, path: String, format: i32) -> i32` - Save image
15+
- `$Image$encode(handle: Handle, format: i32) -> Array[u8]` - Encode to bytes
16+
- `$Image$free(handle: Handle)` - Free image
17+
18+
### Image Info
19+
- `$Image$width(handle: Handle) -> u32` - Get width
20+
- `$Image$height(handle: Handle) -> u32` - Get height
21+
- `$Image$get_pixel(handle: Handle, x: u32, y: u32) -> Color` - Get pixel
22+
- `$Image$set_pixel(handle: Handle, x: u32, y: u32, color: Color)` - Set pixel
23+
24+
### Creation
25+
- `$Image$create(width: u32, height: u32) -> Handle` - Create blank RGBA image
26+
- `$Image$clone(handle: Handle) -> Handle` - Clone image
27+
28+
### Manipulation
29+
- `$Image$resize(handle: Handle, width: u32, height: u32) -> Handle` - Resize
30+
- `$Image$crop(handle: Handle, x: u32, y: u32, w: u32, h: u32) -> Handle` - Crop
31+
- `$Image$rotate90(handle: Handle) -> Handle` - Rotate 90 degrees
32+
- `$Image$rotate180(handle: Handle) -> Handle` - Rotate 180 degrees
33+
- `$Image$rotate270(handle: Handle) -> Handle` - Rotate 270 degrees
34+
- `$Image$flip_horizontal(handle: Handle) -> Handle` - Flip horizontally
35+
- `$Image$flip_vertical(handle: Handle) -> Handle` - Flip vertically
36+
- `$Image$grayscale(handle: Handle) -> Handle` - Convert to grayscale
37+
- `$Image$blur(handle: Handle, sigma: f32) -> Handle` - Gaussian blur
38+
- `$Image$brighten(handle: Handle, amount: i32) -> Handle` - Adjust brightness
39+
- `$Image$contrast(handle: Handle, amount: f32) -> Handle` - Adjust contrast
40+
- `$Image$invert(handle: Handle) -> Handle` - Invert colors
41+
42+
## Format Constants
43+
44+
- `FORMAT_PNG = 0`
45+
- `FORMAT_JPEG = 1`
46+
- `FORMAT_GIF = 2`
47+
- `FORMAT_WEBP = 3`
48+
- `FORMAT_BMP = 4`
49+
- `FORMAT_ICO = 5`
50+
- `FORMAT_TIFF = 6`
51+
52+
## Example
53+
54+
```
55+
// Load, resize, and save an image
56+
let img = $Image$load("input.png");
57+
let resized = $Image$resize(img, 800, 600);
58+
$Image$save(resized, "output.jpg", FORMAT_JPEG);
59+
$Image$free(resized);
60+
$Image$free(img);
61+
```
62+
63+
## Dependencies
64+
65+
- `image` crate (0.24)

0 commit comments

Comments
 (0)