Constant-width rules

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

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
User avatar
pakin
Posts: 43
Joined: Sat Apr 21, 2007 8:59 pm
Location: United States
Contact:

Constant-width rules

Post by pakin »

I'm new to CFDG and have just run into my first problem. I'm trying to draw an image in which all of the lines have the same thickness but different lengths. However, CFDG isn't transforming my shapes in the way that I'd expect. Consider the following code:

Code: Select all

startshape CW

rule UnitLine {
  SQUARE { x 0.5 size 1 0.1}
}

rule CW {
  UnitLine { }
}
That draws a line from (0,0) to (1,0), as I'd expect. Next, I rotate it 90 degrees clockwise and make it half as long:

Code: Select all

startshape CW

rule UnitLine {
  SQUARE { x 0.5 size 1 0.1}
}

rule CW {
  UnitLine { }
  CW2 { x 1 r -90 size 0.5 1 }
}

rule CW2 {
  UnitLine { }
}
That, too, behaves as I'd expect. But if I draw a third line that should be half again as long but the same thickness...

Code: Select all

startshape CW

rule UnitLine {
  SQUARE { x 0.5 size 1 0.1}
}

rule CW {
  UnitLine { }
  CW2 { x 1 r -90 size 0.5 1 }
}

rule CW2 {
  UnitLine { }
  CW3 { x 1 r -90 size 0.5 1 }
}

rule CW3 {
  UnitLine { }
}
...I get a curve that's correctly rotated and correctly translated but is equally long and half as thick as the previous line. In this case I can correct the size with

Code: Select all

CW3 { x 1 r -90 size 0.25 2 }
but my intention is to draw this sort of pattern (and others) recursively so I don't want to have to specify unique scaling for each line.

Can someone please explain to me (a) why scaling doesn't seem to be relative to the current coordinate system and (b) how I can draw lines with fixed widths in a recursive pattern?

Thanks,
-- Scott

P.S. This is with cfdg - 1.2 experimental(v5) on Linux (from ContextFreeSource2.0.tgz).

Post Reply