sandbox/bugs/view_arguments.c

    View not recognizing tx,ty arguments

    When setting the camera position with the parameters tx and ty, if a zero value is specified no argument is taken for those parameters. When view is called multiple times this may generate errors in the camera position. If in a previous call the camera is displaced from the default centered position, in successive calls assigning \displaystyle tx = 0 does not move back the camera to the centered position.

    #include "fractions.h"
    #include "view.h"
    
    int main() {

    We first define a volume fraction field.

      init_grid (16);
      origin (-0.5,-0.5,-0.5);
      scalar f[];
      fraction (f, sq(x) + sq(y) + sq(z) - sq(0.3));

    We set a first view displacing the camera in the x direction.

      view (tx = -0.2, ty = 0., width = 400, height = 400);
      box();
      draw_vof ("f");
      save ("out.png");
    expected expression before ‘[’ token
    ‘view_arguments’ undeclared (first use in this function)
      ![](view_arguments/out.png)
    We set a second view centered on the origin.
    expected ‘;’ before ‘view’
      view (tx = 0., ty = 0., width = 400, height = 400);
      box();
      draw_vof ("f");
      save ("out2.png");
    expected expression before ‘[’ token
    ‘View’ undeclared (first use in this function)
    ‘out2’ undeclared (first use in this function)
        ![View does not take the new argument](view_arguments/out2.png)
    A simple workaround is to specify a very small number instead of zero.
    expected ‘;’ before ‘view’
      view (tx = 1.e-12, ty = 0., width = 400, height = 400);
      box();
      draw_vof ("f");
      save ("out3.png");
    expected expression before ‘[’ token
    ‘With’ undeclared (first use in this function)
    ‘out3’ undeclared (first use in this function)
      ![With the workaround](view_arguments/out3.png)
    expected ‘;’ before ‘free_solver’
    }