4 ms·
Snek: An experimental system for writing generative art systems
- qubex 9y agoI follow this guy's (@inconvergent) generative art on twitter and I highly recommend it as it is awesome: organic and yet clearly procedural.
- octref 9y agoThe author also wrote On Generative Algorithms[0] which is a very inspiring overview for many types of generative art. [0]: http://inconvergent.net/generative/ http://inconvergent.net/generative/
- inconvergent 9y agoHi, I'm the author of the repo. If you want to read about the "framework", rather than look at the code: http://inconvergent.net/snek-is-not-an-acronym/ http://inconvergent.net/snek-is-not-an-acronym/ .
- dri_ft 9y agoGreat! I like the other stuff on your website too.
- inconvergent 9y agoi'm glad to hear it!
- dang 9y agoSince that link gives more background, we've changed to it from https://github.com/inconvergent/snek https://github.com/inconvergent/snek. Thanks!
- kowdermeister 9y agoI find the description confusing: "snek is a simple data structure for working with vertices and edges" If I hear data structure lisp code is not on my mind, so it's rather an API or a drawing library? What am I manipulating exactly? ; context start (with-snek (snk) What's in `snk`? Sorry, I never used lisp before Do you plan to write an API documentation?
- inconvergent 9y agoyou manipulate a data structure that contains vertices and edges. there is more about it here http://inconvergent.net/snek-is-not-an-acronym/ http://inconvergent.net/snek-is-not-an-acronym/. snk is an instance of snek, so it contains a realisation of the structure and its current state.
- pje 9y agoso...snk is a graph?
- inconvergent 9y agoyes, it is.
- Retra 9y agoMost data structures are graphs. This one just happens to be "self-aware" enough to use graph terminology.
- aerique 9y agoIf I hear data structure lisp code is not on my mind, so it's rather an API or a drawing library? Most Lisps, especially Common Lisp which inconvergent is using, have plenty of data structures: http://www.lispworks.com/documentation/lw70/CLHS/Front/Contents.htm http://www.lispworks.com/documentation/lw70/CLHS/Front/Conte... Common Lisp doesn't have a nice literal structure for hash tables/maps/dicts but that is easily mended with a macro. "(with-snek (snk) ..." is a macro which abstracts away lower level tedious boilerplate. It hands you "snk" on a platter so you can manipulate it. Common Lisp itself also comes with some of these macros: http://www.lispworks.com/documentation/lw70/CLHS/Front/X_Alph_W.htm http://www.lispworks.com/documentation/lw70/CLHS/Front/X_Alp... "with-open-file" (skip to the examples) is a nice one since it takes care of opening and closing the file for you so you can write your block of code inside of it and be sure the file gets opened and closed properly: (with-open-file (f "/path/to/file" :direction :output :if-exists :supersede) ... your code writing to "f" comes here ... )
- MooMooMilkParty 9y agoI've used his differential-line repo to make some wall art for my apartment, it's some beautiful stuff: http://imgur.com/a/BoKdy http://imgur.com/a/BoKdy Repo at: https://github.com/inconvergent/differential-line https://github.com/inconvergent/differential-line
- pka 9y agoSo if I'm understanding this correctly, you are generating a data structure describing geometry manipulations which can then be applied to a distinct geometry "instance?" If so, isn't this just a free monad? Also, what are the advantages of this approach over simple function composition operating on immutable data structures/geometries?
- inconvergent 9y agoi don't know what a free monad is. not sure if there are any advantages. this is an experiment i'm working on because i find it interesting. separating the data structure from the instructions that attempt to manipulate it has the advantage of making it easier to deal with the state [the state is not changed inside (with-snek ...)]. basically it's a kind of map-reduce. i'm sure you can achieve this in multiple other ways as well. one of the reasons i'm interested in this particular pattern is described further here: http://inconvergent.net/a-method-for-mistakes/ http://inconvergent.net/a-method-for-mistakes/.
- pka 9y agoIt's indeed very interesting! What I meant is that it might be simpler to just have pure functions operating on immutable data structures, which you could then compose in whichever you want. I.e. you could have a function collapse-vertices that takes some geometry and produces some new geometry (without altering the initial one!), which you could then compose with some other pure function, like produce-random-vertices, and so on, much like a Unix pipe. A free monad is just a formalization of the command/interpreter pattern in a purely functional context (i.e. most useful in languages like Haskell or Clojure).
- inconvergent 9y agoI'm not sure about how you would efficiently do this. (I'm not experienced with pure functional programming.) cloning the entire structure for every applied function sounds like it will be slow? is that not what you will have to do in practice? i basically want the alterations to change the data structure, and i want them to do it according to a particular priority eventually. atm there is no priority ordering. i can already make (almost) arbitrary functions, but you have to register them ahead of time, and they have to follow a particular pattern: http://inconvergent.net/arbitrary-alterations/ http://inconvergent.net/arbitrary-alterations/. this is so that i can control the order in which they are applied, eventually.