Hidden features in DBN



need more speed

with dbn 3.0, a slow-down feature has been re-added that had been missing since the original version (1.0). the slower-running dbn is better for seeing how things like repeat work, because one can can watch instances of a repeat being handled invidually. however, some may outgrow things being so slow. those people, when they're ready, can write fast at the beginning of their program. because, that's how you make a program fast. this tells dbn to make your program fast. no, i'm not joking.

if you want a copy of downloadable dbn never to run slowly, just add 'slowdown=false' to the 'dbn.properties' file in the 'lib' folder.


flicker flicker

when your dbn program is running, the interpreter uses patented ai-refresh(tm) technology to guess when the dbn window should be updated. but like most AI, it isn't (and can't be) perfect. so the discriminating programmer (the anal retentive designer), often finds that their program is flickering way too much.

the solution is to put refresh in your program wherever you want the screen updated. the dbn parser, seeing that refresh has been used, will no longer update automatically, but only on your command. it will instead wait until your program calls refresh to show your changes in the drawing area.


   norefresh

   forever
   {
      paper <mouse 1>
      pen  <mouse 2>
      line 30 30 <mouse 1> <mouse 2>
      refresh   // update the screen
   }


saving dbn images

by holding down the 'control' key, and clicking inside the dbn image area, you can save the current image to disk as a tiff file.


arrays

dbn doesn't support arrays, which makes some programmers very sad. in a moment of weakness, the maintainer of dbn succumbed to these whiners and added an extra connector, called array. this array has 1000 elements, which you may get and set to your heart's content.


    // a boring example to show syntax
    set <array 1> 30
    set <array 2> 80
    set <array 1000> 40
    paper <array 1000>
    // draw a line from 40, 40 to 30, 80
    line 40 40 <array 1> <array 2>


pause

pause is the german word for 'recess' (pronounced pow-zuh).


   pause 5     // wait for 5 hundredths of a second
   pause 200   // wait for 2 seconds


modulo this and that

modulo, the % sign, is a math operator that gives you the remainder of a division between two numbers.


   // sets a to the remainder of 11 divided by 2
   set a (11 % 2)  


the magical line number buffer

after running a program, hold down the shift key while dragging the mouse to and fro inside the dbn graphics area. as you drag over each pixel, the dbn editor highlight the line that was last to draw that pixel. ooh ahh! useful in understanding how dbn programs work.



having read this far

i may as well tell you that this version includes color. this is just a for-fun basis, and we only rarely use it, because it's not part of the 'real' dbn language. but in case you're curious, it's there.

instead of just 'pen 45' or 'paper 30' to set a 45 or 30% gray, use 'pen 10 30 50' for red, green, and blue values of 10, 30, and 50 (on a scale of 0 to 100) same goes for paper, i.e. 'paper 20 70 40'. because rgb works differently than gray, note that to get a 0% gray (paper 0) using rgb color, the command would be 'paper 100 100 100'.

get/set are a little stranger, however. the command 'set [50 50] 30' will set location 50, 50 to 30% gray; because color requires three entries, you have to specify which one you'd like. so 'set [40 40 red] 30' will set the amount of red at location 40, 40 to 30%. similarly, 'set blah [40 40 red]' will set the variable 'blah' to the red value at location 40, 40.




bigger? morebigger?

and while on the topic of unsanctioned dbn features, now is a good time to mention that the drawing area can be resized, using the 'size' command. 'size 200 200' in your code will cause the drawing window to grow to 200 by 200 pixels (instead of the usual 101 by 101).

it is also possible to use a magnification on the drawing area. add the amount to magnify by to the end of the size command. for instance, a 4x magnification and a 200x200 drawing area would be: 'size 200 200 4'

this implementation isn't perfect, and of course it's not real dbn, but it may be fun to play with. keep in mind, however, that the area can't get enormously large, because it just wasn't designed for that sort of thing.



 



 

Design By Numbers is Copyright 1999-2001, Massachusetts Institute of Technology.
DBN was developed by the Aesthetics and Computation Group at the MIT Media Laboratory.