Adjustment- & shape parameters in shape declaration

If you're having trouble using Context Free or don't understand the language, ask for help here.

Moderators: chris, MtnViewMark, MtnViewJohn

Post Reply
User avatar
DeFleur
Posts: 41
Joined: Sat Feb 07, 2009 7:49 am
Location: Switzerland

Adjustment- & shape parameters in shape declaration

Post by DeFleur » Mon Mar 05, 2012 8:36 am

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 ?
kind regards from DeFleur

User avatar
MtnViewJohn
Site Admin
Posts: 842
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Re: Adjustment- & shape parameters in shape declaration

Post by MtnViewJohn » Mon Mar 05, 2012 3:17 pm

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
}

User avatar
MtnViewJohn
Site Admin
Posts: 842
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Re: Adjustment- & shape parameters in shape declaration

Post by MtnViewJohn » Mon Mar 05, 2012 3:30 pm

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
}

User avatar
DeFleur
Posts: 41
Joined: Sat Feb 07, 2009 7:49 am
Location: Switzerland

Re: Adjustment- & shape parameters in shape declaration

Post by DeFleur » Tue Mar 06, 2012 6:24 am

Appreciate posted examples and food for thoughts.
kind regards from DeFleur

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests