public void DrawTimeBar(CairoContextEx gr, double x, double y, double percentage) { double width = 0.04, height = 0.6; const double w = 0.003, h = 0.003; gr.DrawTextCentered(x + (width / 2), y + height + 0.05, Translations.GetString("Time left")); gr.Stroke(); gr.Save(); gr.SetSourceColor(new Color(0, 0, 0)); gr.MoveTo(x, y); gr.LineTo(x, y + height); gr.LineTo(x + width, y + height); gr.LineTo(x + width, y); gr.LineTo(x, y); gr.Stroke(); x += w; y += h; width -= w * 2; height -= h * 2; y += height * (100 - percentage) / 100; height *= percentage / 100; if (gradient == null) { gradient = new LinearGradient(x, y, x + width, y + height); gradient.AddColorStop(0, new Color(1, 0, 0, 1)); gradient.AddColorStop(1, new Color(0.2, 0, 0, 1)); } gr.SetSource(gradient); gr.MoveTo(x, y); gr.LineTo(x, y + height); gr.LineTo(x + width, y + height); gr.LineTo(x + width, y); gr.LineTo(x, y); gr.FillPreserve(); gr.Stroke(); gr.Restore(); }