new.db
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH consts AS ( | |
SELECT | |
8 AS n, -- number of iterations | |
500 AS l, -- width & height of image | |
0.7265425280053609 AS tan36, -- tan(π/5) | |
0.6180339887498948 AS d -- 1/φ | |
), tiles (p, i, t, px, py, qx, qy, rx, ry, sx, sy, tx, ty) AS ( | |
SELECT 0, n, 1, -l/tan36, 0, 0, l, l/tan36, 0, 0, 0, 0, 0 FROM consts | |
UNION ALL SELECT 1, i-1, t, px, py, qx, qy, rx, ry, (qx-px)*d+px, (qy-py)*d+py, (rx-px)*d+px, (ry-py)*d+py | |
FROM tiles, consts WHERE p = 0 and i > 0 | |
UNION ALL SELECT 0, i, 0, rx, ry, sx, sy, qx, qy, 0, 0, 0, 0 FROM tiles, consts WHERE p = 1 and t = 0 | |
UNION ALL SELECT 0, i, 1, rx, ry, sx, sy, px, py, 0, 0, 0, 0 FROM tiles, consts WHERE p = 1 and t = 0 | |
UNION ALL SELECT 0, i, 1, tx, ty, sx, sy, px, py, 0, 0, 0, 0 FROM tiles, consts WHERE p = 1 and t = 1 | |
UNION ALL SELECT 0, i, 0, tx, ty, sx, sy, qx, qy, 0, 0, 0, 0 FROM tiles, consts WHERE p = 1 and t = 1 | |
UNION ALL SELECT 0, i, 1, rx, ry, tx, ty, qx, qy, 0, 0, 0, 0 FROM tiles, consts WHERE p = 1 and t = 1 | |
) | |
SELECT (SELECT printf('<'||'svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="%d" height="%d" viewBox="%d %d %d %d"><'||'g id="t">', l, l, -l/2, -l/2, l, l) FROM consts) | |
||(SELECT group_concat(g, char(10)) FROM | |
(SELECT printf('<'||'g stroke="#044a64" stroke-width="0.3" stroke-linejoin="bevel" fill="%s">%s<'||'/g>', | |
CASE t WHEN 0 THEN '#044a64' ELSE '#fff' END, | |
group_concat(printf('<'||'path d="M%f %fL%f %fL%f %fz"/>', px, py, qx, qy, rx, ry), char(10)) | |
) as g | |
FROM tiles WHERE p = 0 and i = 0 GROUP BY t) | |
)||'<'||'/g><'||'use xlink:href="#t" transform="scale(1 -1)"/><'||'/svg>' | |
as svg; | |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN TRANSACTION; | |
PRAGMA writable_schema=ON; | |
PRAGMA writable_schema=OFF; | |
COMMIT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment