Page 1 of 1

End position of recursion

Posted: Sun Nov 25, 2018 11:59 am
by ehhc
Hey guys,
I'm new to CFA and i have a question: Can i figure out the end position of a recursion? I mean:
If i have the following:

Code: Select all

startshape START
rule START{
 REC {y -1}
}
rule REC {
  SQUARE {s 0.05}
  REC{y 0.06 s 0.965 x -0.1}
}
rule REC {
  SQUARE {s 0.05}
  REC{y 0.06 s 0.965 x 0.1}
}
and i want to add a circle at the top of the stack.. how can i get the position of it?
Is there a way? Since the stack/path alsways ends somewhere different, i cannot simply draw the circle at a static position...

Thank you :)

Re: End position of recursion

Posted: Sun Nov 25, 2018 6:47 pm
by MtnViewJohn
You can't know where shape REC will end from within shape START. All you can do if have shape REC have a recursion termination rule that draws the circle.

Code: Select all

startshape START
rule START{
 REC {y -1}
}
rule REC {
  SQUARE {s 0.05}
  REC{y 0.06 s 0.965 x -0.1}
}
rule REC {
  SQUARE {s 0.05}
  REC{y 0.06 s 0.965 x 0.1}
}
rule REC 0.05 {
  CIRCLE {s 0.1 a -0.5}
}

Re: End position of recursion

Posted: Mon Nov 26, 2018 11:22 am
by ehhc
Sad to hear that :(
But thanks a lot for your answer :)