On 10-06-2019 16:49, Ron Tarrant wrote:

Hi Mike,

I'm trying to understand the arguments passed into cairo.setDash(), but the only docs are for the C version and it's vastly different from the D implementation.

Can you explain them? All I've managed to work out so far is that the first argument determines the length of the first dash. And (maybe) the second designates the position along the line where the pattern starts to repeat.

The values of the dash array alternately represent the length of the
dash and the skipped part.
offset shifts the pattern if you don't want it to start at the start of
the line.

This example: https://www.cairographics.org/samples/dash/ in D would be:

double[] dashes = [50.0,  /* ink */
                    10.0,  /* skip */
                    10.0,  /* ink */
                    10.0   /* skip*/
                   ];
double offset = -50.0;

cr.setDash (dashes, offset);
cr.setLineWidth (10.0);

cr.moveTo (128.0, 25.6);
cr.lineTo (230.4, 230.4);
cr.relLineTo (-102.4, 0.0);
cr.curveTo (51.2, 230.4, 51.2, 128.0, 128.0, 128.0);

cr.stroke ();