avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 16, 2018, 10:29 PM
  • Proudly celebrating 13 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Box, a new figure description language, to make graphics  (Read 3740 times)


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,431
    • View Profile
    • Donate to Member
Box, a new figure description language, to make graphics
« on: January 21, 2009, 07:30 AM »
Box is in its early stage of development.


Box is a vector graphics language developed to make graphics as easy as possible. Box is in its early stage of development, but it already provides most of the features needed to create quality pictures and figures. Box has many advantages over traditional GUI graphics editors:

    * Reusability: you can draw things inside a Window; you can then translate, rotate, scale and put it inside another Window;
    * Transformation matrices can be calculated automatically from constraints given by the user;
    * Flexible syntax: the philosophy is "don't complain if something is missing, use default values!". You can specify many parameters, but you don't have to!
    * Even more flexible syntax: if p is a list of points then p.Get[3] gives the third point, p.Get[3.5] gives a point between the third and the fourth and p.Get[(3.5, 1)]... look at the documentation ;-)
    * You can even draw fractal pictures;
    * Box compiles under Linux, Mac and Windows. Packages are available for Ubuntu and a zip archive (containing the executable) is available for Windows.

Box has also the following features:

    * Translucency: the alpha channel of colors can be set to draw partially transparent objects;
    * Radial and linear color gradients can be set very easily, specifying even more than two colors;
    * Supported output formats are Postscript (EPS), PDF, SVG, PNG.


The documentation of Box is still under construction. However you may find some examples inside the tarball (examples directory). Some of them can be browsed >here<.

Box example

A simple electric circuit

Figure: the output produced by Box.

// Under a shell type: box -l g
// ---
// This example shows how to use Window.Put to place figures.

include "g"
include "electric"

// This is not a real Wheatstone bridge.
// We replace some of the resistors with other components, just to make
// the thing more interesting!
wheatstone = Window["fig"][
  d1 = 20.0 // d1 = half diagonal
  p1 = (0, -d1), p2 = (d1, 0), p3 = (0, d1), p4 = (-d1, 0)

  // Places the four components.
  // Each component has two connections. Here we want to rotate and translate
  // ("rt") a resistor such that the first of its terminals is near to
  // the point p1 and the second one is near to p2.
  r12 = .Put[resistor, "rt", .Near[1, p1], .Near[2, p2]]
  // We proceed in a similar way for the other components:
  r23 = .Put[diode, "rt", .Near[1, p2], .Near[2, p3]]
  r34 = .Put[inductance, "rt", .Near[1, p3], .Near[2, p4]]
  r41 = .Put[resistor, "rt", .Near[1, p4], .Near[2, p1]]

  // Connecting the four resistors
  \ .Line[0.2, p1, r12.Get[1]; r12.Get[2], p2; p2, r23.Get[1]; r23.Get[2], p3;
          p3, r34.Get[1]; r34.Get[2], p4; p4, r41.Get[1]; r41.Get[2], p1]

  // Drawing small circles on the nodes
  // Here you see how a single Circle instruction can be used to draw many
  // circles. To start a new circle one should use the separator ";" and
  // specify only the quantities that changed with respect to the previous
  // circle. Here we change only the center, so we need to specify the radius
  // only once!
  \ .Circle[0.8, p1; p2; p3; p4]

  .Save["wheatstone.eps"]  // Saving to eps file


Box can be used also to create simple animations, here are some examples:

1bouncing.gif 1losing_eyes.gif 1machine.gif 1shy.gif 1washing_machine.gif

-yet another discovery made on Freeware World Team, all 4 you


  • Member
  • Joined in 2007
  • **
  • Posts: 141
    • View Profile
    • Donate to Member
Re: Box, a new figure description language, to make graphics
« Reply #1 on: January 21, 2009, 08:03 AM »
Nodebox on Mac


Shoebot on multi platforms