A Pattern Dsl
The goal of this project is to create a very simple and concise language that I can use to create complex patterns which can then be sent to various machines to be processed (so I need to output in some sort of vector format.)
Before even starting the DSL portion of the project, I spent a lot of time experimenting with different ways to build patterns using python output to some sort of machine readable format. I started using DXF but it was weird and new (to me) and I didn’t really like how much work it took to do anything in it. Then I switched over to using svg which is nice since it handles a lot of the transformations for me. Once I got some python code working that could output vector patterns, I moved on to making the DSL to control it.
The tech stack
ga = ((E20,20 T10,0 C0 )(RS4), (E15,15 T10,0 C1 )(RS4), (E8,4 T13,0 C0)(RS4)); mrgrid = GRID60,60,10,10,60,ga; gb = (R10,10 RT45 C0); tmp = GRID90,90,9,9,60,gb; RENDER(mrgrid, tmp);
Basic overview of what is above: ( full grammar )
- E : create an ellipse
- T : Translate to a new position (everything starts at 0,0
- RS : copy an object around a circle X times
- GRID : take a group of objects and copy them onto a grid
Off to the presses (cutter)
Cleaning it up
Where I’m going from Here?
What I have now is a good proof of concept, but I really want to implment CSG functionality into it (so I can get cleaner/smaller output to work with), which means i’ll probablly need to scrap most of the way i’m currently doing things. Also, I need to scrap the idea of using “shapes” and just make everything a ploygon, which will make working with the CSG libraries and converting back to svg much easier.