DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Thu, 05 Jul 2007 06:55:24 -0700,    posted on: microsoft.public.dotnet.framework.drawing        back       

Thread Index
  1    TD
          2    Bob Powell [MVP]


Green to Yellow to Red Gradient   
New to use of Drawing Class....

I'm trying to create an asp.net page/control that will display a green
to yellow to red gradient bar.

Not seeing where I could create a 3 color gradient, I create a green
to yellow rectangle and then a yellow to red rectangle and join them
in one bitmap.

The code below works but has a red line where my two gradient brushes
meet.

I played with the width x and width settings but the line remained.

Thoughts?

Thanks in advance


using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

private void Page_Load(object sender, System.EventArgs e)
{
	// Put user code to initialize the page here




	Bmp = new Bitmap(150,10);

	Gfx = Graphics.FromImage(Bmp);

	LinearGradientBrush brGY=new LinearGradientBrush(
		new Rectangle(0,0,75,10),
		Color.Green,
		Color.Yellow,
		0,
		false);

	LinearGradientBrush brYR=new LinearGradientBrush(
		new Rectangle(75,0,75,10),
		Color.Yellow,
		Color.Red,
		0,
		false);

	Gfx.FillRectangle(brGY,new Rectangle(0,0,75,10));
	Gfx.FillRectangle(brYR,new Rectangle(75,0,75,10));

	Bmp.Save(Response.OutputStream, ImageFormat.Jpeg);


}
Date:Thu, 05 Jul 2007 06:55:24 -0700   Author:  

Re: Green to Yellow to Red Gradient   
You can create gradients with multiple colours using a ColorBlend see 
the Beginners Guide to GDI+ from my web-site for an example.

http://www.bobpowell.net/linear.htm

-- 
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





TD wrote:

> New to use of Drawing Class....
> 
> I'm trying to create an asp.net page/control that will display a green
> to yellow to red gradient bar.
> 
> Not seeing where I could create a 3 color gradient, I create a green
> to yellow rectangle and then a yellow to red rectangle and join them
> in one bitmap.
> 
> The code below works but has a red line where my two gradient brushes
> meet.
> 
> I played with the width x and width settings but the line remained.
> 
> Thoughts?
> 
> Thanks in advance
> 
> 
> using System.Drawing;
> using System.Drawing.Drawing2D;
> using System.Drawing.Imaging;
> 
> private void Page_Load(object sender, System.EventArgs e)
> {
> 	// Put user code to initialize the page here
> 
> 
> 
> 
> 	Bmp = new Bitmap(150,10);
> 
> 	Gfx = Graphics.FromImage(Bmp);
> 
> 	LinearGradientBrush brGY=new LinearGradientBrush(
> 		new Rectangle(0,0,75,10),
> 		Color.Green,
> 		Color.Yellow,
> 		0,
> 		false);
> 
> 	LinearGradientBrush brYR=new LinearGradientBrush(
> 		new Rectangle(75,0,75,10),
> 		Color.Yellow,
> 		Color.Red,
> 		0,
> 		false);
> 
> 	Gfx.FillRectangle(brGY,new Rectangle(0,0,75,10));
> 	Gfx.FillRectangle(brYR,new Rectangle(75,0,75,10));
> 
> 	Bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
> 
> 
> }
> 
Date:Thu, 05 Jul 2007 21:24:46 +0200   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us