Graphics.DrawString

bpayne111

Well-known member
Joined
Feb 28, 2003
Messages
326
Location
BFE
Im creating a user control to represent my logo
im using the Graphics.DrawString method to draw some text on the logo.
I have a System.Drawing.Brush declared to contain the color of the string to draw.
Id like this Brush object to cycle through the different colors sequentially back and forth.
Can someone post a block of code that would demonstrate this technique.
I have provided a method here with an example

C#:
private Brush _brush = Color.Blue;
private void ChangeColr()
{
       _brush = what? //make the brushs color just slightly different
}

thanks
brandon
 
What exactly do you mean "cycle sequentially" because theres no Array in the code you provided

But if there is an array:
C#:
		private Color[] cols = {Color.Red, Color.Yellow, Color.Green};
		private int curcol = 0;
		private bool goforward = true;

		private void Form1_Paint(object sender, PaintEventArgs e)
		{
			e.Graphics.FillEllipse(new SolidBrush(cols[curcol]),0,0,100,100);

			if(goforward) //Count up
			{
				curcol+=1;
				if(curcol==cols.GetUpperBound(0))
					goforward=false; //At the UpperBound go down
			}
			else //Count down
			{
				curcol-=1;
				if(curcol==0)
					goforward=true; //At 0 start going up again
			}
This code draws an ellipse on the form in a different color every pass. The SolidBrush class is what the Brushes class gives you but its been cast to Brush which is the base class of all Brushes
 
Back
Top