2018-01-08 23:33:13 +03:00
|
|
|
namespace CairoChart {
|
|
|
|
|
2018-01-19 20:34:08 +03:00
|
|
|
/**
|
2018-01-20 13:11:17 +03:00
|
|
|
* Line Style.
|
2018-01-19 20:34:08 +03:00
|
|
|
*/
|
2018-01-20 13:11:17 +03:00
|
|
|
public struct LineStyle {
|
2018-01-08 23:33:13 +03:00
|
|
|
|
2018-01-19 20:34:08 +03:00
|
|
|
/**
|
2018-01-20 13:11:17 +03:00
|
|
|
* Line color.
|
2018-01-19 20:34:08 +03:00
|
|
|
*/
|
2018-01-20 13:11:17 +03:00
|
|
|
Color color;
|
2018-01-08 23:33:13 +03:00
|
|
|
|
2018-01-20 13:11:17 +03:00
|
|
|
/**
|
|
|
|
* A line width.
|
|
|
|
*/
|
|
|
|
double width;
|
2018-01-19 20:34:08 +03:00
|
|
|
|
2018-01-20 13:11:17 +03:00
|
|
|
/**
|
|
|
|
* An array specifying alternate lengths of on and off stroke portions.
|
|
|
|
*/
|
|
|
|
double[]? dashes;
|
2018-01-08 23:33:13 +03:00
|
|
|
|
2018-01-20 13:11:17 +03:00
|
|
|
/**
|
|
|
|
* An offset into the dash pattern at which the stroke should start.
|
|
|
|
*/
|
|
|
|
double dash_offset;
|
|
|
|
/**
|
|
|
|
* A line join style.
|
|
|
|
*/
|
|
|
|
Cairo.LineJoin join;
|
2018-01-19 20:34:08 +03:00
|
|
|
|
2018-01-20 13:11:17 +03:00
|
|
|
/**
|
|
|
|
* A line cap style.
|
|
|
|
*/
|
|
|
|
Cairo.LineCap cap;
|
2018-01-10 11:19:33 +03:00
|
|
|
|
2018-01-20 13:11:17 +03:00
|
|
|
/**
|
|
|
|
* Constructs a new ``LineStyle``.
|
|
|
|
* @param color line color.
|
|
|
|
* @param width a line width.
|
|
|
|
* @param dashes an array specifying alternate lengths of on and off stroke portions.
|
|
|
|
* @param dash_offset an offset into the dash pattern at which the stroke should start.
|
|
|
|
* @param join a line join style.
|
|
|
|
* @param cap a line cap style.
|
|
|
|
*/
|
|
|
|
public LineStyle (Color color = Color(),
|
|
|
|
double width = 1,
|
|
|
|
double[]? dashes = null,
|
|
|
|
double dash_offset = 0,
|
|
|
|
Cairo.LineJoin join = Cairo.LineJoin.MITER,
|
|
|
|
Cairo.LineCap cap = Cairo.LineCap.ROUND
|
|
|
|
) {
|
|
|
|
this.color = color;
|
|
|
|
this.width = width;
|
|
|
|
this.dashes = dashes;
|
|
|
|
this.dash_offset = dash_offset;
|
|
|
|
this.join = join;
|
|
|
|
this.cap = cap;
|
2018-01-08 23:33:13 +03:00
|
|
|
}
|
2018-01-19 20:34:08 +03:00
|
|
|
|
2018-01-20 13:11:17 +03:00
|
|
|
/**
|
|
|
|
* Applies current style to the {@link Chart} ``Context``.
|
|
|
|
*/
|
|
|
|
public void apply (Chart chart) {
|
|
|
|
chart.color = color;
|
|
|
|
chart.ctx.set_line_width(width);
|
|
|
|
chart.ctx.set_dash(dashes, dash_offset);
|
|
|
|
chart.ctx.set_line_join(join);
|
|
|
|
chart.ctx.set_line_cap(cap);
|
|
|
|
}
|
2018-01-08 23:33:13 +03:00
|
|
|
}
|
|
|
|
}
|