LineStyle construtor

LineStyle construtor

Forum member · May 11, 2006
can you give some real example of LineStyle(float[] dashArray, float dashPhase) LineStyle(float[] dashArray) to Let me can know how it works? Thanks

Re: LineStyle construtor

Support · May 12, 2006
Sure, the LineStyle, as it suggests, allow you to create custom patterns for line style (used in Line, Rectangles, Circles objects etc.). The first parameter (the float array) is a series of float values that correspond to the lengths of alternating dashes and gaps. The second float (the dashPhase) corresponds to the distance into the dash pattern at which to start the dash (if the constructor without the dashPhase is used then a dashPhase of 0 is assumed). So an example might be something like this: float[] pattern = { 1, 1, 2, 2, 3, 3 }; LineStyle style = new LineStyle(pattern, 2); page.Elements.Add(new Line(0, 0, 500, 0, 4, Grayscale.Black, style)); And from this example the pattern would be as follows: 1 point on, 1 point off, 2 points on, 2 points off, 3 points on 3 points off, then repeat But keep in mind that because we specified the dashPhase of 2 that the pattern is actually going to start on the "two points on" and go from there. Typically you will want the dashArray to contain an even number of entries. An array of an odd number of values (i.e. { 1, 2, 3 }) would produce a behavior as follows: 1 point on 2 points off, 3 points on 1 point off, 2 points on, 3 points off, then repeat So in other words the pattern always displays dash then gap starting with dash so if your array has an odd number then your first number starts out as your dash but then alternates as you gap. This behavior is not typically desired and you will therefore commonly want an even number of values. Thanks, ceTe Software Support Team