Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

Look into the System.Drawing.Drawing2D.LinearGradientbrush class. Here is an example:

Graphics gr = this.CreateGraphics();
LinearGradientBrush br = new LinearGradientBrush(new Rectangle(0,0,100,100), Color.NavajoWhite, Color.Red, LinearGradientMode.Vertical);
gr.FillRectangle(br, br.Rectangle);
gr.Dispose();

Posted

Yes, I believed that drawing rectangle is maybe my only choice. But I have to draw a line. So I could draw very thin rectangle - I'll have some trouble with rotation, but I can firuge it out. brrrrrr....

 

 

I'll have to take a pen and paper into my hands and do some mathematics...

 

 

 

Look into the System.Drawing.Drawing2D.LinearGradientbrush class. Here is an example:

Graphics gr = this.CreateGraphics();
LinearGradientBrush br = new LinearGradientBrush(new Rectangle(0,0,100,100), Color.NavajoWhite, Color.Red, LinearGradientMode.Vertical);
gr.FillRectangle(br, br.Rectangle);
gr.Dispose();

  • *Experts*
Posted

Oh, im sorry, for some reason I didn't think about you needing a line when i wrote the code :D. You can create a Pen object used to draw the line from the brush so that is not a problem.

Graphics gr = this.CreateGraphics();

LinearGradientBrush br = new LinearGradientBrush(new Rectangle(0,0,100,100), Color.NavajoWhite, Color.Red, LinearGradientMode.Vertical);
Pen lpen = new Pen(br, 1);

gr.DrawLine(lpen,0,0,100,200);

gr.Dispose();

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...