# Undocumented syntax of FilledCurve [duplicate]

Possible Duplicate:
Undocumented form for FilledCurve[]

A nice trick to get the outline paths of letters is to use the PDF exporter/importer

el=
First[
First[
ImportString[
ExportString[
Style["L", Italic, FontSize -> 24, FontFamily -> "Arial"],
"PDF"
],
"PDF",
"TextMode" -> "Outlines"
]
]
];

Graphics[{EdgeForm[Black], LightBlue, el}];


The outline paths are given in a FilledCurve construction (new in MMA8):

el

(*
===>
{Thickness[0.07507507507507508],
Style[
{FilledCurve[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}},
{{{12.887695983062486, 5.160000000000004},
{1.8237311169604027, 5.160000000000004},
{5.496094644083314, 22.410000000000004},
{7.823731116960403, 22.410000000000004},
{4.5834973678187225, 7.222500000000004},
{13.319824330510414, 7.222500000000004}
}}
]
},
Thickness -> 0.07507507507507508
]}
*)


This syntax variant is not given in the FilledCurve help page:

with segments defined as:

(The doc page doesn't give a formal definition of components, BTW)

While the second argument of FilledCurve in the undocumented output above is pretty obvious (the coordinates of the outline), the first part is not. My hypothesis is that it has something to do with bezier control points or so. Anyone got an idea about this?

-

## marked as duplicate by rm -rf♦Feb 5 '13 at 1:24

Strongly related thread on community.wolfram.com: "FilledCurve curve specification". –  Alexey Popkov Nov 10 '13 at 8:31

Here's a summary of the answer I gave to a question very similar to this one on stack overflow.

In essence, each triple represents a segment of the curve where the first digit in the triples indicates the type of curve used. Here, 0 indicates a Line, 1 or 2 a BezierCurve, and 3 a BSplineCurve. The difference between 1 and 2 is that with option 2, an extra control point is added to the list to make sure that the segment is tangential to its predecessor. The second digit of the triples indicates how many points to use for the segment, and the last digit the SplineDegree.

-

There is a public, but undocumented, function called GeometricFunctionsDecodeFilledCurve which helps to decode this type of undocumented FilledCurve:

GeometricFunctionsDecodeFilledCurve[
FilledCurve[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}},
{{{12.887695983062486, 5.160000000000004},
{1.8237311169604027, 5.160000000000004},
{5.496094644083314, 22.410000000000004},
{7.823731116960403, 22.410000000000004},
{4.5834973678187225, 7.222500000000004},
{13.319824330510414, 7.222500000000004}}}]]


which gives a documented form of FilledCurve:

FilledCurve[{{Line[{{12.8877, 5.16}, {1.82373, 5.16}}],
Line[{{5.49609, 22.41}}], Line[{{7.82373, 22.41}}],
Line[{{4.5835, 7.2225}}], Line[{{13.3198, 7.2225}}]}}]


The encoding/decoding scheme is and pretty obscure and may change in the future, which probably explains why this internal detail of the code is not documented. I would definitely not write code that depends on the undocumented syntax, and one could argue that Import(String) returning this syntax is a bug.

-
From that example, the middle number seems to tell how many points from the second list to take for each line. If that interpretation is right, the sum of the middle numbers of the first list should always give the length of the second list. –  celtschk Jan 23 '12 at 23:38
Very useful this, Arnoud. About the 'components' part of the syntax of FilledCurve: did I miss its definition or is it really not there? –  Sjoerd C. de Vries Jan 24 '12 at 14:22
I filed a suggestion to improve the documentation. The nearest thing I see under FilledCurve is this statement: FilledCurve[{Subscript[component, 1],Subscript[component, 2],...}] treats each component curve as a separate closed curve, but the filling behavior is determined as if they were part of the same curve. –  Arnoud Buzing Jan 24 '12 at 15:58

As far as I can tell, the only valid specifications for that first argument seem to be permutations of the input you have and similar lists of triplets.

• If the list is one element shorter than the second argument, all points in the second argument are points in the list, and the one corresponding to the element {0,2,0} in the first argument is the starting point for drawing the line.
• If the list is shorter than Length[secondElement]-1, then progressively, different points are "dropped out" of the shape. They are presumably then used as control points.
• If the list is the same length or longer, then you can't have a triplet {0,2,0}, but it works if they are all {0,1,0}.

For example, this creates a trapezoidal shape, dropping out the two points in the interior of the L.

Graphics@{Thickness[0.07507507507507508], Opacity[0.5],
Style[{FilledCurve[{{{0.2, 1, -1}, {0, 1, 0}, {0, 1, 0}, {0, 1,  0}}},
{{{12.887695983062486, 5.160000000000004}, {1.82373111696040271,
5.160000000000004}, {5.496094644083314,
22.410000000000004}, {7.823731116960403,
22.410000000000004}, {4.5834973678187225,
7.222500000000004}, {13.319824330510414,
7.222500000000004}}}]}, Thickness -> 0.02]}
`
-
Choosing Times instead of Arial creates a lot of new points in both the first and the second argument. The reason, of course, is that Times has more curves in its letters. The first arguments now also gets lots of triplets with '3' in them that weren't there before. –  Sjoerd C. de Vries Jan 23 '12 at 22:58
Ah - that would be a Spline (cubic) curve, where as in Arial Oblique, they are all sharp angles using straight lines. –  Verbeia Jan 23 '12 at 23:36