Make my draw graph looks better I have simple code, that draw graph of my histogram. But code looks ugly, do you have idea, how can I make it looks better ?

            for (int i = 0; i &lt; hueCount - 2; ++i)
            {
                if( i % 6 == 0)
                g.DrawLine(borderPen,
                   margin+ (width - 2 * margin) * ((float)i / (float)hueCount), 
                   height - margin,
                   margin+ (width - 2 * margin) * ((float)i / (float)hueCount),
                   height - margin - 5);

                g.DrawLine(redPen,
                    margin + ((float)i / (float)hueCount) * (width - 2 * margin),
                    (-(float)reds[i] / (float)maxRed) * (height - 2 * margin) - margin + height,
                    margin + ((float)(i + 1) / (float)hueCount) * (width - 2 * margin),
                    (-(float)reds[i + 1] / (float)maxRed) * (height - 2 * margin) - margin + height);

                g.DrawLine(greenPen,
                    margin + ((float)i / (float)hueCount) * (width - 2 * margin),
                    (-(float)greens[i] / (float)maxGreen) * (height - 2 * margin) - margin + height,
                    margin + ((float)(i + 1) / (float)hueCount) * (width - 2 * margin),
                    (-(float)greens[i + 1] / (float)maxGreen) * (height - 2 * margin) - margin + height);

                g.DrawLine(bluePen,
                    margin + ((float)i / (float)hueCount) * (width - 2 * margin),
                    (-(float)blues[i] / (float)maxBlue) * (height - 2 * margin) - margin + height,
                    margin + ((float)(i + 1) / (float)hueCount) * (width - 2 * margin),
                    (-(float)blues[i + 1] / (float)maxBlue) * (height - 2 * margin) - margin + height);
            }
Here's what I came up with using a helper class:

            Draw draw = new Draw(g, borderPen, hueCount, margin, width, height);

            for (int i = 0; i &lt; hueCount - 2; ++i)
            {
                draw.DrawBorder(i);
                draw.DrawLine(redPen, i, reds, maxRed);
                draw.DrawLine(greenPen, i, greens, maxGreen);
                draw.DrawLine(bluePen, i, blues, maxBlue);
            }


...

internal sealed class Draw
{
    private readonly Graphics g;

    private readonly Pen borderPen;

    private readonly int hueCount;

    private readonly int margin;

    private readonly int doubleMargin;

    private readonly int width;

    private readonly int height;

    internal Draw(Graphics g, Pen borderPen, int hueCount, int margin, int width, int height)
    {
        this.g = g;
        this.borderPen = borderPen;
        this.hueCount = hueCount;
        this.margin = margin;
        this.doubleMargin = 2 * this.margin;
        this.width = width;
        this.height = height;
    }

    internal void DrawBorder(int i)
    {
        if (i % 6 == 0)
        {
            float x = margin + (width - doubleMargin) * (float)i / hueCount;
            float y = height - margin;

            g.DrawLine(borderPen, x, y, x, y - 5);
        }
    }

    internal void DrawLine(Pen pen, int i, int[] colors, int maxColor)
    {
        float wm = width - doubleMargin;
        float hm = height - doubleMargin;
        float mh = margin - height;

        g.DrawLine(
            pen,
            margin + ((float)i / hueCount) * wm,
            (-(float)colors[i] / maxColor) * hm - mh,
            margin + ((float)(i + 1) / hueCount) * wm,
            (-(float)colors[i + 1] / maxColor) * hm - mh);
    }
}