diff options
| author | Akshay Nair <phenax5@gmail.com> | 2026-06-03 23:57:21 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2026-06-03 23:57:21 +0530 |
| commit | ed4b84d2ca7e5b13d010effefb8ae676d084124a (patch) | |
| tree | 7aa142e52a3a2bd9e1d760dc8648e523d919dae7 /src/circle.sql | |
| parent | 3be6325b1292233fae4817b3b864eca7b9911898 (diff) | |
| download | sqlite-creative-coding-ed4b84d2ca7e5b13d010effefb8ae676d084124a.tar.gz sqlite-creative-coding-ed4b84d2ca7e5b13d010effefb8ae676d084124a.zip | |
Refactor image.sh to handle png + cleanup sql
Diffstat (limited to '')
| -rw-r--r-- | src/circle.sql | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/circle.sql b/src/circle.sql index 46874cc..c4ac18a 100644 --- a/src/circle.sql +++ b/src/circle.sql @@ -1,9 +1,8 @@ -DELETE FROM images WHERE id = 'circle'; -INSERT INTO images (id, width, height) VALUES ('circle', 200, 200) RETURNING id; +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, 80 AS radius FROM image), + 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 @@ -11,7 +10,7 @@ WITH RECURSIVE _pixels(x, y, r, g, b) AS (SELECT x, y, 150, - 255 * MAX(0, MIN(1, (SELECT POW(x - cx, 2) + POW(y - cy, 2) - POW(radius, 2) FROM circle))), + 255 * MAX(0, MIN(1, (SELECT (x - cx)*(x - cx) + (y - cy)*(y - cy) - radius*radius FROM circle))), 150 FROM vertical, horizontal ) |
