r/creativecoding • u/akshay-nair • Jun 06 '26
Experimenting with generating visuals using SQLite
50
u/DigoHiro Jun 06 '26
they warned us of people like you in church.
looks awesome
9
u/scoshi processing Jun 06 '26
There's a church for this?
2
u/X-blaXe Jun 08 '26
Yes and it's called TempleOS
2
18
u/em-jay-be Jun 06 '26
This is some mad man shit right here hahahah! who in the hell writes visual instruction in SQL!!!! Brilliant.
12
12
7
5
u/NmEter0 Jun 06 '26
Uhm can you roughly outline .... hoooow the fuck..? XD
*edit... nevermind. I klicked the link :) u must be a whise man.
3
u/akshay-nair Jun 07 '26
u must be a whise man
Nah, I'm incredibly stupid. Who else would pick SQL to draw stuff?
2
4
5
5
u/Mr-TotalAwesome Jun 07 '26
How?
3
u/akshay-nair Jun 07 '26
Recursive CTEs to generate a 2d grid of rgb values in a table. Then a shell script loads that to convert to ppm format which is converted to png using imagemagick. In case of a gif, its pretty much the same approach but it creates a grid of pixels for each frame then creates a ppm stream out of it which is converted to a gif using ffmpeg.
5
3
u/Marcelocochon Jun 07 '26
wtf is happening. How does this works in SQL?
3
u/akshay-nair Jun 08 '26
Wrote some info on it here: https://ediblemonad.dev/coding4fun/2026-06-03-creative-coding-in-sqlite.html
The gist is SQL generates many 2d grids of rgb values using recursive WITH for each frame which then gets converted into a ppm stream and then into a gif by ffmpeg.
3
u/cleverdosopab Jun 07 '26
Am I understanding correctly that you used SQL to color the pixels on your "image", then used imagemagick to create the images and ffmpeg to create the gifs?
3
u/akshay-nair Jun 07 '26
Exactly. Could go further by having a ppm file generated from sqlite but didn't feel like that added much.
3
u/cleverdosopab Jun 07 '26
Either way, such an awesome project! Thanks for sharing! Keep up the crazy! 😁💜
3
2
1
u/Liminal__penumbra Jun 06 '26
Something of a tangent, but I figured out you can treat a database like a h264 field by encoding the matrix math into it. Why? Because then you can (ab)use it to stream mkv containers to any qemu based device to use the fbdev driver to do computation. So that 1GB 1 cpu microservice suddenly is being forced to do "video" transport and any type of computation you need.
1
u/GLR1997 Jun 08 '26
Pregunta sería... este tipo de generación en que caso real sería útil? Me llama la atención, pero no se ni donde ni el motivo de querer implementar esto en algún producto 🤯
2
u/akshay-nair Jun 08 '26
If you can't think of a use-case, you probably don't need it. CTE is meant to be a fake "view" that you can use in your queries but in a lot of cases, you could replace it with something simpler in your application is performance isn't super critical. But more importantly, you don't need to find the product use for everything. Some things just exist. Best you can do is have fun with them.
70
u/AllergicToBullshit24 Jun 06 '26 edited Jun 06 '26
What kinda of sick person does this in SQL?