Combined use of For, Line and Poly


the output produced by Box To run this example you will need the following file(s): ./ If the example requires more than one file, then you should put them into the same directory. You can then launch Box with box -l g ./

// Under a shell type: box -l g
// ---
// This example shows how to define a function and use it to draw
// generic curves and polygons.

include "g"

// In Box all functions are associated to objects, therefore we must create
// a new object for each new function.
Cycloid = Point

// Real@Cycloid will be called when a Real number appears inside
// a Cycloid box, such as in Cycloid[1.234]
  t = $ // $ is the Real argument (1.234 in the above example)
  pi = Atan[1]*4
  big_r = 10.0, big_v = 2.0*pi
  small_r = 4.0, small_v = 2.0*pi*5
  $$ = big_r*Vec[big_v*t] + small_r*Vec[small_v*t] // $$ is the Cycloid object

// Here we use the a For loop to draw a Poly object.
// For is a type derived from Int, which has a particular feature:
// it induces a jump to the begin of the current box, when it is equal to 1.
w = Window[][
  t = 0.0
  Poly[Cycloid[t], For[(t += 0.01) <= 1.0]
       color.yellow, Style[FillStyle["eo"], Border[0.4,]]]

w.Save["cycloid.png", Window["rgb24", .Res[Dpi[200]]]]

Table Of Contents

This Page

Get The figure description language: Box at Fast, secure and Free Open Source software downloads