How to gradient-wise fill a bitmap programmatically

I’ll be using this for GUI purposes, to allow the user customization of colors of the GUI, the HP bars and other gauges are Gradients. using Set pixels a millions times in a loop is far too slow. I want the Player to define two colors using RGB sliders, with normal GUI i can just tint the color setting but this will not work with gradients.

is there any efficient way i could achieve this? Its similar to the FFVII window background color customization but an overlay of what already there.

This seems to do the trick.

 Texture2D a = new Texture2D(2,1);
                a.SetPixel(1, 1, color1);
                a.SetPixel(2, 1, color2);
                a.filterMode = FilterMode.Bilinear;
                a.wrapMode = TextureWrapMode.Clamp;
                GUI.DrawTexture(new Rect(x, gague_y, width, 16), a);