Package: vsketch
vsketchWhat isvsketch?vsketchis a Python generative art toolkit for plotters with the following focuses:Accessibility:vsketchis easy to learn and feels familiar thanks to its API strongly inspired fromProcessing.Minimized friction:vsketchautomates every part of the creation process
(project initialisation, friction-less iteration, export to plotter-ready files) through a CLI tool calledvskand a tight integration withvpype.Plotter-centric:vsketchis made for plotter users, by plotter users. It's feature set is focused on the
peculiarities of this medium and doesn't aim to solve other problems.Interoperability:vsketchplays nice with popular packages such asNumpyandShapely, which are true enabler for plotter generative art.vsketchis the sum of two things:A CLI tool namedvskto automate every part of a sketch project lifecycle::Sketch creation based on a customizable template.Interactive rendering of your sketch with live-reload and custom parameters.Batch export to SVG with random seed and configuration management as well as multiprocessing support.An easy-to-learn API similar toProcessingto implement your sketches.This project is at an early the stage and needscontributions.
You can help by providing feedback and improving the documentation.InstallingvsketchThe recommended way to installvsketchis as a stand-alone installation using pipx:$pipxinstallvsketchTo run the examples, they must bedownloadedseparately. After decompressing the archive, they can be run using the following command:$vskrunpath/to/vsketch-master/examples/schotterCheck theinstallation instructionsfor more details.Getting startedThis section is meant as a quick introduction of the workflow supported byvsketch. Check thedocumentationfor a more complete overview.Open a terminal and create a new project:$vskinitmy_projectThis will create a new project structure that includes everything you need to get started:$lsmy_project
config
output
sketch_my_project.pyThesketch_my_project.pyfile contains a skeleton for your sketch. Theconfigandoutputsub-directories are used
byvskto store configurations and output SVGs.Opensketch_my_project.pyin your favourite editor and modify it as follows:importvsketchclassSchotterSketch(vsketch.SketchClass):defdraw(self,vsk:vsketch.SketchClass)->None:vsk.size("a4",landscape=False)vsk.scale("cm")forjinrange(22):withvsk.pushMatrix():foriinrange(12):withvsk.pushMatrix():vsk.rotate(0.03*vsk.random(-j,j))vsk.translate(0.01*vsk.randomGaussian()*j,0.01*vsk.randomGaussian()*j,)vsk.rect(0,0,1,1)vsk.translate(1,0)vsk.translate(0,1)deffinalize(self,vsk:vsketch.Vsketch)->None:vsk.vpype("linemerge linesimplify reloop linesort")if__name__=="__main__":SchotterSketch.display()Your sketch is now ready to be run with the following command:$vskrunmy_projectYou should see this:Congratulation, you just reproducedGeorg Nees' famous artwork!Wouldn't be nice if you could interactively interact with the script's parameters? Let's make this happen.Add the following declaration at the top of the class:classSchotterSketch(vsketch.SketchClass):columns=vsketch.Param(12)rows=vsketch.Param(22)fuzziness=vsketch.Param(1.0)# ...Change thedraw()method as follows:defdraw(self,vsk:vsketch.Vsketch)->None:vsk.size("a4",landscape=False)vsk.scale("cm")forjinrange(self.rows):withvsk.pushMatrix():foriinrange(self.columns):withvsk.pushMatrix():vsk.rotate(self.fuzziness*0.03*vsk.random(-j,j))vsk.translate(self.fuzziness*0.01*vsk.randomGaussian()*j,self.fuzziness*0.01*vsk.randomGaussian()*j,)vsk.rect(0,0,1,1)vsk.translate(1,0)vsk.translate(0,1)Hitctrl-S/cmd-Sto save and, lo and behold, corresponding buttons just appeared in the viewer without even needing to restart it! Here is how it looks with some more fuzziness:Let's play a bit with the parameters until we find a combination we like, then hit theSavebutton and enter a "Best config" as name.We just saved a configuration that we can load at any time.Finally, being extremely picky, it would be nice to be able to generate ONE HUNDRED versions of this sketch with various random seeds, in hope to find the most perfect version for plotting and framing.vskwill do this for you, using all CPU cores available:$vsksave--config"Best config"--seed0..99my_projectYou'll find all the SVG file in the project'soutputsubdirectory:Next steps:Usevskintegrated help to learn about the all the possibilities (vsk --help).Learn the vsketch API on the documentation'soverviewandreferencepages.AcknowledgmentsPart of this project's documentation is inspired by or copied from theProcessing project.LicenseThis project is licensed under the MIT license. The documentation is licensed under theCC BY-NC-SA 4.0license. See thedocumentationfor details.