Asp.net creates text effects and asp.net text effects
I believe that the word art function in word is familiar to everyone. Today, we will use C # To make several artistic words of our own. It may be helpful for us to understand how font images are made. As for the value of their use, I will remain silent.
I. Projection Effect
Program running effect:
The program code is implemented as follows:
Projection effect code
Private void Form1_Paint (object sender, PaintEventArgs e)
{
// Projection text
Graphics g = this. CreateGraphics ();
// Set the text output quality
G. TextRenderingHint = TextRenderingHint. ClearTypeGridFit;
G. SmoothingMode = SmoothingMode. AntiAlias;
Font newFont = new Font ("Times New Roman", 48 );
Matrix matrix = new Matrix ();
// Projection
Matrix. Shear (-1.5f, 0.0f );
// Zoom
Matrix. Scale (1, 0.5f );
// Translation
Matrix. Translate (130, 88 );
// Perform coordinate transformation ,,
G. Transform = matrix;
SolidBrush grayBrush = new SolidBrush (Color. Gray );
SolidBrush colorBrush = new SolidBrush (Color. BlueViolet );
String text = "blog Garden ";
// Draw the shadow
G. DrawString (text, newFont, grayBrush, new PointF (0, 30 ));
G. ResetTransform ();
// Draw the foreground
G. DrawString (text, newFont, colorBrush, new PointF (0, 30 ));
}
Ii. Embossed Effect
Program running effect:
The program code is implemented as follows:
Embossed text implementation
Private void Form1_Paint (object sender, PaintEventArgs e)
{
// Embossed text
Brush backBrush = Brushes. Black;
Brush foreBrush = Brushes. White;
Font font = new Font ("", Convert. ToInt16 (40), FontStyle. Regular );
Graphics g = this. CreateGraphics ();
String text = "blog Garden ";
SizeF size = g. MeasureString (text, font );
Single posX = (this. Width-Convert. ToInt16 (size. Width)/2;
Single posY = (this. Height-Convert. ToInt16 (size. Height)/2;
G. DrawString (text, font, backBrush, posX + 1, posY + 1 );
G. DrawString (text, font, foreBrush, posX, posY );
}
Iii. Printing Plate Effect
Program running effect:
The program code is implemented as follows:
Implementation of printed text
Private void Form1_Paint (object sender, PaintEventArgs e)
{
// Printed text
Int I = 0;
Brush backBrush = Brushes. Black;
Brush foreBrush = Brushes. Violet;
Font font = new Font ("Times New Roman", System. Convert. ToInt16 (40), FontStyle. Regular );
Graphics g = this. CreateGraphics ();
G. Clear (Color. White );
String text = "blog Garden ";
SizeF size = g. MeasureString (text, font );
Single posX = (this. Width-Convert. ToInt16 (size. Width)/2;
Single posY = (this. Height-Convert. ToInt16 (size. Height)/3;
While (I <Convert. ToInt16 (20 ))
{
G. DrawString (text, font, backBrush, posX-I, posY + I );
I = I + 1;
}
G. DrawString (text, font, foreBrush, posX, posY );
}
Iv. reflection effect
Program running effect:
The program code is implemented as follows:
Reflected text implementation
Private void Form1_Paint (object sender, PaintEventArgs e)
{
// Reflected text
Brush backBrush = Brushes. Gray;
Brush foreBrush = Brushes. Black;
Font font = new Font ("", Convert. ToInt16 (40), FontStyle. Regular );
Graphics g = this. CreateGraphics ();
String text = "blog Garden ";
SizeF size = g. MeasureString (text, font );
Int posX = (this. Width-Convert. ToInt16 (size. Width)/2;
Int posY = (this. Height-Convert. ToInt16 (size. Height)/2;
G. TranslateTransform (posX, posY );
Int ascent = font. FontFamily. GetCellAscent (font. Style );
Int spacing = font. FontFamily. GetLineSpacing (font. Style );
Int lineHeight = System. Convert. ToInt16 (font. GetHeight (g ));
Int height = lineHeight * ascent/spacing;
GraphicsState state = g. Save ();
G. ScaleTransform (1,-1.0F );
G. DrawString (text, font, backBrush, 0,-height );
G. Restore (state );
G. DrawString (text, font, foreBrush, 0,-height );
}
5. Shadow Effect
Program running effect:
Shadow text implementation
Private void Form1_Paint (object sender, PaintEventArgs e)
{
// Shadow text
String text = "blog Garden ";
Brush shadowBrush = Brushes. Gray;
Brush foreBrush = Brushes. Black;
Font font = new Font ("", Convert. ToInt16 (40), FontStyle. Regular );
Graphics g = this. CreateGraphics ();
SizeF size = g. MeasureString (text, font );
Single posX = (this. Width-Convert. ToInt16 (size. Width)/4;
Single posY = (this. Height-Convert. ToInt16 (size. Height)/3;
G. DrawString (text, font, shadowBrush, posX + Convert. ToInt16 (20), posY + Convert. ToInt16 (20 ));
G. DrawString (text, font, foreBrush, posX, posY );
}
6. Texture Effect
Program running effect:
The program code is implemented as follows:
Line management effect implementation
Private void Form1_Paint (object sender, PaintEventArgs e)
{
// Fill text lines with images
TextureBrush brush = new TextureBrush (Image. FromFile (Application. StartupPath + "\ myPicture.jpg "));
Graphics g = e. Graphics;
G. DrawString ("", new Font ("", 60), brush, new PointF (0, 0 ));
}
7. Tilt Effect
Program running effect:
The program code is implemented as follows:
Tilt effect implementation
Private void Form1_Paint (object sender, PaintEventArgs e)
{
Brush foreBrush = Brushes. Blue;
Font font = new Font ("", Convert. ToInt16 (40), FontStyle. Regular );
Graphics g = this. CreateGraphics ();
String text = "blog Garden ";
SizeF size = g. MeasureString (text, font );
Single posX = (this. Width-Convert. ToInt16 (size. Width)/2;
Single posY = (this. Height-Convert. ToInt16 (size. Height)/2;
G. TranslateTransform (posX, posY );
Matrix transform = g. Transform;
// Right-skewed text
// Float shearX =-0.230F;
// Skewed text on the left
Float shearX = 0.550F;
Float shearY = 0.10F;
Transform. Shear (shearX, shearY );
G. Transform = transform;
G. DrawString (text, font, foreBrush, 0, 0 );
}
8. gradient effect
The program code is implemented as follows:
Gradient effect
Private void Form1_Paint (object sender, PaintEventArgs e)
{
// Gradient text
String text = "blog Garden ";
Brush ShadowBrush = Brushes. Gray;
Brush ForeBrush = Brushes. Black;
Font font = new Font ("", System. Convert. ToInt16 (40), FontStyle. Regular );
Graphics g = this. CreateGraphics ();
// G. Clear (Color. White );
PointF point = new PointF (0, 0 );
SizeF size = g. MeasureString (text, font );
RectangleF rectangle = new RectangleF (point, size );
Brush brush = new LinearGradientBrush (rectangle, Color. Red, Color. Green, LinearGradientMode. Horizontal );
Int width = (this. Width-Convert. ToInt16 (size. Width)/2;
Int height = (this. Height-Convert. ToInt16 (size. Height)/2;
G. DrawString (text, font, brush, width, height );
}
9. Rotating effect
Program running effect:
The program code is implemented as follows:
Rotating effect implementation
Private void Form1_Paint (object sender, PaintEventArgs e)
{
// Rotate the displayed text
Graphics g = e. Graphics;
G. SmoothingMode = System. Drawing. Drawing2D. SmoothingMode. AntiAlias;
For (int I = 0; I <= 360; I + = 10)
{
// Translate the Graphics object to the center of the form
G. TranslateTransform (this. Width/2, this. Height/2 );
// Set the output angle of the Graphics object
G. RotateTransform (I );
// Set the text fill color
Brush brush = Brushes. DarkViolet;
// Rotate the displayed text
G. DrawString (". bo ke yuan", new Font ("Lucida Console", 11f), brush, 0, 0 );
// Restore the global transformation matrix
G. ResetTransform ();
}
}
10 ...........
Postscript:
There are many other ways to draw a font chart. The principle is quite simple. You must be familiar with three commonly used drawing classes.
Brush, Font, Graphics; the main method used here is the DrowString of the Graphics class.
This method has six versions. The version used here is
G. DrawString ("text", "font", "paint brush", "X start coordinate", "Y start coordinate ")
How can I obtain the font, color, and other effects of the input text like word in the TextBox of ASP NET webpage?
I have already answered the answer upstairs. However, I don't know whether the landlord needs to develop it by myself or just use it. If you only want to use it, I 'd like to see the use of FCKeditor, multi-language support, and strong customization,
If you want to develop a small website, you can see the following questions:
Zhidao.baidu.com/question/13743397.html
ASPNET creates folders and html files
// Create a folder:
If (! Directory. Exists (path ))
Directory. CreateDirectory (path );
// Create a file
String fileName = path + string. Format ("test.html ");
StreamWriter sw = new StreamWriter (fileName );
Sw. Write ("html content ");
Sw. Close ();