From ed4b84d2ca7e5b13d010effefb8ae676d084124a Mon Sep 17 00:00:00 2001
From: Akshay Nair <phenax5@gmail.com>
Date: Wed, 3 Jun 2026 23:57:21 +0530
Subject: Refactor image.sh to handle png + cleanup sql

---
 src/gradient.sql | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

(limited to 'src/gradient.sql')

diff --git a/src/gradient.sql b/src/gradient.sql
index f04cdad..4ad1820 100644
--- a/src/gradient.sql
+++ b/src/gradient.sql
@@ -1,5 +1,4 @@
-DELETE FROM images WHERE id = 'gradient';
-INSERT INTO images (id, width, height) VALUES ('gradient', 200, 200) RETURNING id;
+INSERT OR REPLACE INTO images (id, width, height) VALUES ('gradient', 400, 400) RETURNING id;
 
 WITH RECURSIVE
   image AS (SELECT * FROM images WHERE id = 'gradient'),
@@ -8,5 +7,5 @@ WITH RECURSIVE
   vertical(y) AS
     (SELECT height FROM image 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)
+    (SELECT x, y, x*255/width, y*255/height, 100 FROM vertical, horizontal, image)
 INSERT INTO pixels (image_id, x, y, r, g, b) SELECT 'gradient', x, y, r, g, b FROM _pixels;
-- 
cgit v1.3.1

