WITH centers AS (
SELECT angle
, len
, ROUND(len * SIN(2 * PI() * angle)) AS x
, ROUND(len * COS(2 * PI() * angle)) AS y
, ROUND(len * 0.3)::INTEGER + 1 AS trace
FROM (SELECT RANDOM() AS angle
, 8 * (1 - POWER(RANDOM(), 3)) AS len
FROM generate_series (1, 50) s
) q
),
traces AS (
SELECT *
, generate_series(1, trace) AS part
FROM centers
),
parts AS (
SELECT CASE
WHEN trace = part THEN
LEAST(len * 0.2, 2)::INTEGER
ELSE
TRUNC(angle * 8 - 0.5)::INTEGER % 4 + 3
END AS symbol
, TRUNC(x + part * SIN(2 * PI() * angle)) AS x
, TRUNC(y + part * COS(2 * PI() * angle)) AS y
FROM traces
)
SELECT ARRAY_TO_STRING(ARRAY(
SELECT COALESCE((
SELECT SUBSTR('.??\\-/|', MIN(symbol) + 1, 1)
FROM parts
WHERE x = col - 14
AND y = row - 12
), ' ')
FROM generate_series(1, 25) col
), '') AS FIREWORKS
FROM generate_series(1, 24) row;
result:
上面的SQL Command中使用了emoji,貼的時候有正常顯示,發表時變成問號了...
不過沒關係, 若要複製時,可以自行修正. 到以下網址,可以複製.
https://emojipedia.org/moon-cake/
https://emojipedia.org/full-moon-symbol/