Production of karaoke subtitles and karaoke subtitles
Just implement the subtitle Effect of karaoke
* The color of a word changes linearly, that is, the color changes over time rather than by the unit of words.
So sometimes it is a part of the word to change the color
The main code is as follows:
Graphics g = pea. Graphics;
String str = "the signal is too large to be used in our village! ";
Pen myPen = new Pen (Color. Red );
SolidBrush backBr = new SolidBrush (Color. Blue );
Font font = new Font ("ms ui Gothic", 40 );
G. DrawString (str, font, backBr, new Point (10, 10); // background (blue)
SizeF size = g. MeasureString (str, font); // you can use the following picture to describe the short-cut character.
SolidBrush foreBr = new SolidBrush (Color. Red); // foreground text Color (red)
RectangleF rectF = new RectangleF (10, 10, 10, size. Height); // forground text
StringFormat strFmt = new StringFormat ();
StrFmt. FormatFlags = StringFormatFlags. NoWrap; // The returned value is "no ".
StrFmt. Trimming = StringTrimming. None; // The partition is not deleted.
For (int w = 1; w <= size. Width; w + = 1)
{
RectF. Width = w;
Try {
// G. DrawRectangle (Pens. Blue, rectF. Left, rectF. Top, rectF. Right, rectF. Bottom );
G. DrawString (str, font, foreBr, rectF, strFmt); // foreground
Thread. Sleep (5); // speed tuning (Dynamic tuning)
Application. DoEvents ();
} Catch (Exception e)
{
Return;
} // End try
} // End
Adjust Sleep () according to the speed of the specific lyrics. This section can be used to write a class and enter the lyrics to be displayed, speed, and other information. This class draws the lyrics on the CDC.
For reference only