From 8c62edb87433bd0ac93fdef4585582990513236b Mon Sep 17 00:00:00 2001
From: Akshay Nair <phenax5@gmail.com>
Date: Tue, 2 Jun 2026 22:24:49 +0530
Subject: Add gradient example

---
 examples/gradient.sql | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 examples/gradient.sql

(limited to 'examples/gradient.sql')

diff --git a/examples/gradient.sql b/examples/gradient.sql
new file mode 100644
index 0000000..9aa9010
--- /dev/null
+++ b/examples/gradient.sql
@@ -0,0 +1,12 @@
+INSERT INTO images (id, width, height) VALUES ('gradient', 200, 200) RETURNING id;
+
+WITH RECURSIVE
+  width AS (SELECT width FROM images WHERE id = 'gradient'),
+  height AS (SELECT height FROM images WHERE id = 'gradient'),
+  horizontal(x) AS
+    (SELECT * FROM width UNION ALL SELECT x - 1 FROM horizontal WHERE x > 1),
+  vertical(y) AS
+    (SELECT * FROM height UNION ALL SELECT y - 1 FROM vertical WHERE y > 1),
+  _pixels(x, y, r, g, b) AS
+    (SELECT x, y, mod(x, 255), mod(y, 255), 100 FROM vertical, horizontal)
+INSERT INTO pixels (image_id, x, y, r, g, b) SELECT 'gradient', x, y, r, g, b FROM _pixels;
-- 
cgit v1.3.1

