Is there really a "pipe" syntax for targeting colo

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

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
jeremydouglass
Posts: 17
Joined: Fri Mar 30, 2007 9:10 pm

Is there really a "pipe" syntax for targeting colo

Post by jeremydouglass »

The wiki page on "Shape Adjustments" lists two different ways of using the pipe "|" character to set target values. Is this feature supported, deprecated, or planned? I can't get any visible effect in CF 2.0 or 2.1b, although I might be misunderstanding the syntax. Here is the CFDG I'm using to test:

Code: Select all

startshape pipetest

include i_pix.cfdg

background { b -1 } 
rule pipetest { examples { b 1 sat 1 } }
rule examples { example1 { x 1 } example2 { x 2 } example3 { x 3 } example4 { x 4 } }

rule example1 { CIRCLE {} label1 {} example1 { s .75 y -.75 sat -.5 a -.5  h 60  } } // hue
rule example2 { CIRCLE {} label2 {} example2 { s .75 y -.75 sat -.5 a -.5        } } // no hue
rule example3 { CIRCLE {} label3 {} example3 { s .75 y -.75 sat -.5 a -.5  h 60| } } // hue-pipe - same as no hue 
rule example4 { CIRCLE {} label4 {} example4 { s .75 y -.75 sat -.5 a -.5 |h 60  } } // pipe-hue - same as no hue

rule label1 { H_5by5 { b -1 s .2 }                      }
rule label2 { }
rule label3 { H_5by5 { b -1 s .2 } P_5by5 { x .3 b -1 s .2 } }
rule label4 { P_5by5 { b -1 s .2 } H_5by5 { x .3 b -1 s .2 } }

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

Post by MtnViewJohn »

Target hues are implemented and supported in 2.0 and above, but they aren't very intuitive.

example1 changes the hue by 60 each iteration
example2 leaves the hue at 0
example3 sets the hue 6000% toward the current hue target, which is capped to 100%. But the current hue target is 0 so you don't see a hue change.
example4 changes the current hue target by 60 each iteration but doesn't change the hue

The reason that we added hue targets is that people would design cfdg files with color shifting recursive rules and they would tweak the color change to make it look right. But then if they change the resolution the rule iterates more and the end-point color is not what the designer wanted.

For example, you design a flower that is red at the tips and yellow in the center and it looks great at 500x500. But then you render it at 1000x1000 and the center is green. If you set the hue target to 60 and then use 'hue x|' to change the hue then the center will always be yellow.

jeremydouglass
Posts: 17
Joined: Fri Mar 30, 2007 9:10 pm

Got target colors working! Bug in transform order?

Post by jeremydouglass »

Thanks for your help! Sadly, it still took me another 20 minutes to get what you were describing working - the important point I needed to get was that "hue x|" is specified in degrees, whereas "|hue x" is a percentage out of 1 (not 100 - oops). Really took me a bit to wrap my head around that.

Below are my working tests so that others who find this thread can learn by example.

Incidentally, I uncover what might be a bug - using [] to specify the transform order has no effect on whether the target value is changed before or after the target-step. That is, the expected behavior of [r 45 x 1] and [x 1 r 45] is very different, but there is no difference between the behavior of [|hue .5 hue 10|] and [hue 10| |hue .5].

In the meantime, the important thing to know is that the target always shifts second.

Code: Select all


startshape targettest 

include i_pix.cfdg 

background { b -1 } 
rule targettest { examples { b 1 sat 1 |h 90} }  // all examples have a target of 60

rule examples { base { x 1 } example1 { x 2 } example2 { x 3 } example3 { x 4 } compare { x 3.5 y -.75 z -1 s .4 }  }

rule base { CIRCLE {} base { s .75 y -.75  h 30  } } // hue 0, 30, 60, 90, 120...
rule example1 { CIRCLE {} label1 {} example1 { y -.75  h .5| s .75 } }
// hue approaches target by 50% each step:
//   0   +   90/2 = 45    T 90
//  45   +   45/2 = 67.5  T 90
//  67.5 + 22.5/2 = 78.75 T 90 etc.
rule example2 { CIRCLE {} label2 {} example2 [ y -.75  h .5|  |h 10  s .75 ] }
// hue approaches moving target:
//  0    +   90/2 = 45    T 90
// 45    +   50/2 = 70    T 100 etc.
rule example3 { CIRCLE {} label3 {} example3 [ y -.75  |h 10  h .5|  s .75 ] }
// hue approaches moving target (doesn't work differently from above, should?):
// should be:
//  0    +  100/2 = 50    T 100
// 50    +   55/2 = 77.5  T 110 etc.

rule label1 { NUM_1_5by5 { b -1 s .2 } } 
rule label2 { NUM_2_5by5 { b -1 s .2 } } 
rule label3 {     X_5by5 { b -1 s .2 } } 

rule compare { CIRCLE { h 50 } }


Post Reply