Link to home
Start Free TrialLog in
Avatar of melodiesoflife
melodiesoflife

asked on

Draw a character in two colors

Hi all

I want to draw a character in two colors. For example: After display, character "X" has upper part in red and lower part in blue.
How can I do this?

Thanks.
Avatar of armoghan
armoghan
Flag of Pakistan image

quite a difficult question :)
The only solution I can think of is to create an image of the charactor and display it on runtime
Ok another way is to create a custom control whcih has two labels on top of other both should have same text and different color
Now place one label over the other. The label which is on top should have less size so that it becomes half and comes over the other label exectly
I made these two labels and set there positions manually

Lower part is blue and the upper part is Black

//
                  // label1
                  //
                  this.label1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
                  this.label1.Location = new System.Drawing.Point(104, 176);
                  this.label1.Name = "label1";
                  this.label1.Size = new System.Drawing.Size(100, 16);
                  this.label1.TabIndex = 2;
                  this.label1.Text = "label1";
                  //
                  // label2
                  //
                  this.label2.Location = new System.Drawing.Point(104, 176);
                  this.label2.Name = "label2";
                  this.label2.Size = new System.Drawing.Size(100, 8);
                  this.label2.TabIndex = 3;
                  this.label2.Text = "label1";
Avatar of melodiesoflife
melodiesoflife

ASKER

Hi armoghan
Thanks for your response but do you have any other solution? I hope I can do it by used Graphics, Pen ... classes.

Thanks
see if you can use PathGradientBrush or LinearGradientBrush in g.DrawString

http://www.c-sharpcorner.com/2/gdi_plus.asp

I have not done it so do tell me if it works
ASKER CERTIFIED SOLUTION
Avatar of God_Ares
God_Ares

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
pb is an imagebox ,, uses system.drawing,drawing2d;