//draw bar with specific (w)idth, (h)eight, grayscale (c)olor and fill level
public void drawbar(Cairo.Context context, int w, int h, int c, double fill)
{
context.Save();
context.LineWidth = 0.75;
//Fill the area
double gray_value = ColorChan(c);
context.SetSourceRGB(gray_value, gray_value, gray_value);
context.Rectangle(0, 0, w, h);
context.Fill();
//White color
context.SetSourceRGB(1, 1, 1);
//Updated coordinates with offset
int h0 = 10, x0 = 10, w0 = w - x0, y0 = (h - 10) / 2, w1 = w0 - x0;
context.Rectangle(x0, y0, w1, h0);
context.Fill();
//Fill the bar
double r = ColorChan(255), g = ColorChan(186), b = ColorChan(0);
context.SetSourceRGB(r, g, b);
context.Rectangle(x0, y0, w1 * fill, h0);
context.Fill();
//Draw shadow of the bar
gray_value = 0.2;
for (int i = 0; i < 3; ++i)
{
context.SetSourceRGB(gray_value, gray_value, gray_value);
drawshadow(context, x0 + i, y0 + i, w0 + i, h0 + i);
context.LineWidth -= 0.2;
gray_value += 0.3;
}
context.Restore();
}