Jump to content

Diamond gradient


Recommended Posts

I would sure like to know how you do the diamond gradient. The best I've been able to do is:

public void fillStarDiagGrad(Bitmap src, Color c1, Color c2)

{

int w = src.Width;

int h = src.Height;

Rectangle rect = new Rectangle(0, 0, w, h);

GraphicsPath path = new GraphicsPath();

path.AddRectangle(rect);

PathGradientBrush brush = new PathGradientBrush(path);

brush.CenterColor = c1;

Color[] surroundColors = new Color[] { c2 };

brush.SurroundColors = surroundColors;

Graphics g = Graphics.FromImage(src);

g.FillPath(brush, path);

}

which creates a diamond with the points pointing toward the corners of the rectangle, which is fine, but I also want a diamond with the points pointing vertically and diagonally, regardless of the rectangle. (A 90 degree diamond which I could point in any direction would be even nicer.)

Could anyone point me in the right direction?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...