aboutsummaryrefslogtreecommitdiff
path: root/src/circle.image.sql
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-06-07 17:46:08 +0530
committerAkshay Nair <phenax5@gmail.com>2026-06-07 17:46:08 +0530
commitafaf82538d09cd77ee4f5a435b79995e88be84f5 (patch)
tree5fb4db643debbd3a04b010e1470838750b427dd6 /src/circle.image.sql
parentb893b29d7be4fadb563187d2c6ed20865686aeff (diff)
downloadsqlite-creative-coding-afaf82538d09cd77ee4f5a435b79995e88be84f5.tar.gz
sqlite-creative-coding-afaf82538d09cd77ee4f5a435b79995e88be84f5.zip
Rename the files
Diffstat (limited to 'src/circle.image.sql')
-rw-r--r--src/circle.image.sql17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/circle.image.sql b/src/circle.image.sql
new file mode 100644
index 0000000..c4ac18a
--- /dev/null
+++ b/src/circle.image.sql
@@ -0,0 +1,17 @@
+INSERT OR REPLACE INTO images (id, width, height) VALUES ('circle', 400, 400) RETURNING id;
+
+WITH RECURSIVE
+ image AS (SELECT * FROM images WHERE id = 'circle'),
+ circle AS (SELECT width/2 AS cx, height/2 AS cy, 160 AS radius FROM image),
+ horizontal(x) AS
+ (SELECT width FROM image UNION ALL SELECT x - 1 FROM horizontal WHERE x > 1),
+ 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,
+ 150,
+ 255 * MAX(0, MIN(1, (SELECT (x - cx)*(x - cx) + (y - cy)*(y - cy) - radius*radius FROM circle))),
+ 150
+ FROM vertical, horizontal
+ )
+INSERT INTO pixels (image_id, x, y, r, g, b) SELECT 'circle', x, y, r, g, b FROM _pixels;