summaryrefslogtreecommitdiff
path: root/src/vector/layouts.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-25 21:47:58 -0300
committerGabriel Schneider <[email protected]>2026-09-25 21:48:16 -0300
commit9c33714591a2147f7e5879e77212ca9886d0c967 (patch)
treed250be9d9bc365d7894d49455c0f6376966b58be /src/vector/layouts.zig
downloadsketchbook-9c33714591a2147f7e5879e77212ca9886d0c967.tar.gz
sketchbook-9c33714591a2147f7e5879e77212ca9886d0c967.zip
Put the game first: lib/sketchbook, sketches/vecanim
The root is the game. The platform library moves to lib/sketchbook (with serve_web.py, which serves any sketch's web build, as a tool of it), and vecanim to sketches/vecanim, still its own package on the same library.
Diffstat (limited to 'src/vector/layouts.zig')
-rw-r--r--src/vector/layouts.zig40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/vector/layouts.zig b/src/vector/layouts.zig
new file mode 100644
index 0000000..097e682
--- /dev/null
+++ b/src/vector/layouts.zig
@@ -0,0 +1,40 @@
+//! What the vector GPU backend hands its shaders. These Zig structs are the
+//! only definition: the shaders include GLSL generated from them (see
+//! `glsl.zig`). No imports, so the shader build can compile this alone.
+
+pub const max_stops = 32;
+
+/// A path point in device pixels.
+pub const Vertex = extern struct {
+ position: [2]f32,
+
+ pub const glsl = .vertex;
+};
+
+pub const Viewport = extern struct {
+ size: [2]f32,
+ pad: [2]f32 = .{ 0, 0 },
+
+ pub const glsl = .{ .uniform = .{ .set = 1, .instance = "viewport" } };
+};
+
+/// A resolved `Paint`, as `cover.frag` reads it.
+pub const Paint = extern struct {
+ /// Premultiplied solid color.
+ color: [4]f32,
+ /// Device pixels to gradient space: a, c, e; then the kind (0 solid,
+ /// 1 linear, 2 radial).
+ row0: [4]f32,
+ /// b, d, f; then the spread (0 pad, 1 reflect, 2 repeat).
+ row1: [4]f32,
+ /// p0 then p1.
+ points: [4]f32,
+ /// Radius, alpha, stop count.
+ extra: [4]f32,
+ /// Stop offsets, four per element.
+ offsets: [max_stops / 4][4]f32,
+ /// Straight stop colors.
+ colors: [max_stops][4]f32,
+
+ pub const glsl = .{ .uniform = .{ .set = 3, .instance = "paint" } };
+};