Page 1 of 1

Adjustment- & shape parameters in shape declaration

Posted: Mon Mar 05, 2012 8:36 am
by DeFleur
Deriving from Documentation as well as examples in the Gallery I understand the number/natural parameters
in shapes declarations. Still I struggle with adjustment- and shape parameters in shape declarations and
haven't seen yet any examples thereof anywhere. It is possible to show examples in the documentation ?
And is tr really an abbreviation for transformation ?

Re: Adjustment- & shape parameters in shape declaration

Posted: Mon Mar 05, 2012 3:17 pm
by MtnViewJohn
Here is a shape parameter example. I will put it in the wiki too.

Code: Select all

startshape test

shape foo(number sz)
{
  SQUARE [r 0..90 s sz]
}

shape curve(number scale, number turn, shape thingie)
{
  thingie []  // invoke thingie with parameters already bound
  curve(=) [[y 0.5 s scale r turn y 0.5]]
}

shape test {
  curve(0.97, 3, foo(0.5)) [] // bind 0.5 to sz in shape foo here
}

Re: Adjustment- & shape parameters in shape declaration

Posted: Mon Mar 05, 2012 3:30 pm
by MtnViewJohn
Here is an adjustment parameter example. I forgot to put examples in the wiki. tr and transformation are not keywords in Context Free. trans and transform are the keywords used for inserting an adjustment variable or parameter into another adjustment.

Code: Select all

startshape test

shape foo(number sz)
{
  SQUARE [r 0..90 s sz]
}

shape curve(adjustment change, shape thingie)
{
  thingie[]  // invoke thingie with parameters already bound
  curve(=) [transform change]
}

shape test {
  curve([[y 0.5 s 0.97 r 3 y 0.5]], foo(0.5)) [] // bind 0.5 to sz here
}

Re: Adjustment- & shape parameters in shape declaration

Posted: Tue Mar 06, 2012 6:24 am
by DeFleur
Appreciate posted examples and food for thoughts.