![]() For example, textheight(txt, w) returns the height of a paragraph displaying txt with a width of w. ![]() You may have noticed that some commands in NodeBox have a return value that you can store in a variable. NodeBox would now execute all of the code in the header() definition, with txt being "Templating", x being 20, and y being 40. Once the command is called, you supply real values for txt, x and y. ![]() ![]() Theses are used like variables inside the definition. This is where parameters come in: notice how the definition of header() uses a txt, a x, and a y parameter. Command definitions need to be called from somewhere else in the script. Ĭommand definitions are not executed by themselves: you are instead teaching NodeBox something, for example, what a header is. Commands that change and return a value use a verb: adjust_contrast, strip_tags.Commands that return True or False start with is: is_white, is_alive, is_big.Use lower_case_with_underscores (except for essential commands like imagesize).Use a simple and relevant word that describes what the command does.Don't forget the colon at the end of the line - this tells NodeBox that the intented statements below are what the command does. The definition of a command starts with def, followed by the name of the command (pick a relevant name), and a list of parameters. If we want to modify the way a flower is drawn, we only need to modify the code at one location.ĭefining your own commands is like composing your own toolbox, with a set of tools that you can apply to your creations over and over.Īs a simple example I've defined my own header() command below: def header (txt, x, y ):įill ( 1, 0, 0 ) font ( "Dolly-Bold", 18 ) text (txt, x, y ) We only need to define the actions to draw a flower once. This command can then be called one time, a hundred times, or a thousand times. Creating a command is a design strategy in which you re-use certain actions or pieces of your script.įor example, in the above example all the actions to draw a flower (ten red-pinkish ovals connected by lines) are grouped in a handy flower() command. NodeBox version 1.9.5 for Mac OS X.Aside from the predefined commands in the NodeBox reference you can also define your own custom commands. for i in range(100):ĭe Bleser F., De Smedt T., Nijs L. It draws a number of ellipses to the canvas, in random shades of transparent red, with random size and position. This example demonstrates a simple NodeBox script. NodeBox 1 has been stable for a long time and is now in “maintenace mode”: we only release new versions to fix critical issues. Ports exist for other platforms that use the same API, such as Shoebot. NodeBox 1 is built on Mac OS X’s Quartz rendering engine, using PyObjC. For an exponent of generative art made with NodeBox, see Spamghetto (Olivero, 2009). Several (free) plug-in libraries have been developed for NodeBox, for example for Core Image filters, SVG import, organic systems such as graphs, boids, L-systems, and an OSC wrapper. NodeBox 1 is a Mac OS X application that lets you create 2D visuals (static, animated or interactive) using Python programming code and export them as a PDF or a QuickTime movie.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |