public virtual void Render(Context cr, Gdk.Rectangle area, Color color, bool showEmptyStars, bool isHovering,
int hoverValue, double fillOpacity, double hoverFillOpacity, double strokeOpacity)
{
if (Value == MinRating && !isHovering && !showEmptyStars) {
return;
}
cr.Save ();
Cairo.Color fill_color = color;
fill_color.A = fillOpacity;
Cairo.Color stroke_color = fill_color;
stroke_color.A = strokeOpacity;
Cairo.Color hover_fill_color = fill_color;
hover_fill_color.A = hoverFillOpacity;
double x, y;
ComputePosition (area, out x, out y);
cr.LineWidth = 1.0;
cr.Translate (0.5, 0.5);
for (int i = MinRating + 1, s = isHovering || showEmptyStars ? MaxRating : Value; i <= s; i++, x += Size) {
bool fill = i <= Value && Value > MinRating;
bool hover_fill = i <= hoverValue && hoverValue > MinRating;
double scale = fill || hover_fill ? Size : Size - 2;
double ofs = fill || hover_fill ? 0 : 1;
for (int p = 0, n = star_plot.GetLength (0); p < n; p++) {
double px = x + ofs + star_plot[p, 0] * scale;
double py = y + ofs + star_plot[p, 1] * scale;
if (p == 0) {
cr.MoveTo (px, py);
} else {
cr.LineTo (px, py);
}
}
cr.ClosePath ();
if (fill || hover_fill) {
if (!isHovering || hoverValue >= Value) {
cr.SetSourceColor (fill ? fill_color : hover_fill_color);
} else {
cr.SetSourceColor (hover_fill ? fill_color : hover_fill_color);
}
cr.Fill ();
} else {
cr.SetSourceColor (stroke_color);
cr.Stroke ();
}
}
cr.Restore ();
}