1 Stroke and fill paths at the same time
3 In order to stroke and fill a path, you could call the `fill` and `stroke`
4 methods of a canvas instance one after the other. However, such a solution is
5 not optimal since the path would be written into the output file twice.
6 Instead, you can use the `filled` decorator within a `stroke` method call as an
7 additional attribute. ...
9 In the example code, the filled decorator is called to pass additional
10 styles, which will then only be used for the fill operation. Other styles
11 passed in the second argument of the `stroke` method are used for both, the
12 stroke and the fill operation. Here we set a linewidth, which only affects the
15 A complementary functionality exists as well: you can use a `deco.stroked`
16 instance to add a stroke operation within a `fill` method call.
18 ! The `filled` and `stroked` are pre-defined instances, but they accept a
19 ''modify by call'' operation. This is a common feature of decorators and other
22 !! Internally, the `stroke` and the `fill` methods are implemented by adding either
23 `deco.stroked` or `deco.filled` to the list passed as the second parameter to the
24 `stroke` or `fill` method of a canvas. This whole construction is then evaluated by
25 the `draw` method of the canvas instance. The draw method is really the basic
26 operation to output a path. It transforms a path into a so-called decorated
27 path. The mere path itself is a pure mathematical object without any information
28 about how it should be drawn and which styles should be applied.
29 Output-specific properties like dashing or the linewidth are not attached to
30 the path at all. In contrast, the decorated path attaches styles and the two output
31 operations stroke and fill to the mathematical path object. A symmetric stroke
32 and fill operation therefore looks like
34 c.draw(p, l1 + [deco.stroked(l2), deco.filled(l3)])
36 where `c` is the canvas instance, `p` is the path to be stroked and filled, `l1` is
37 a list of styles used for both stroking and filling, `l2` are additional styles
38 used for stroking, and `l3` are additional styles used for filling.