Menu

local variables

Neon22
2008-12-30
2013-05-28
  • Neon22

    Neon22 - 2008-12-30

    I would really like to be able to set a value with a named variable.
    E.g.
    set j 6
    mat
    rule mat {
    j  * { x 1 hue 20 } j  * { y 1 hue 20 } split
    }

    instead of:
    rule mat {
    6  * { x 1 hue 20 } 6  * { y 1 hue 20 } split
    }

    This would make localizing the users control of the variances more controllable by defining these at the head of the file. (and one day maybe in the UI)

    Is this possible please ?

     
    • Mikael Hvidtfeldt Christensen

      Yes. Actually the next thing I'll do is to add simple constant variables.

      I'll do it by adding a preprocessor step, using a syntax like:

      -----------
      #define angle 120

      R1
      rule R1 {
         { z 1 rz angle } R1
         Sphere
      }
      ----------

      The preprocessor will do pure text substitution (so there will be no dynamic variables - only constants).

      I'll do this because I've been playing around with an embedded JavaScript interpreter, in order to control and automate the rendering (for instance it should be possible to control the camera and some variables and create an automated process which renders frames for an animation).

       
      • Mikael Hvidtfeldt Christensen

        I've added preprocessor substitutions - the code is checked in in the SVN repository.

        Example:

        /*
            An example of using preprocessor defines
        */

        #define sizeStep 0.98
        #define angle 4

        set maxdepth 400
        R1
        R2

        rule R1 {
          {  x 1 rz angle ry angle s sizeStep hue 1 a 0.97 } R1
          { s 2 } sphere
        }

        rule R2 {
          { x -1 rz angle ry angle s sizeStep hue -1  sat 1 a 0.97  } R2
          { s 2 } sphere

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.