C # design and production of artistic words
I believe that the word art function is familiar to everyone. The word above is what it does.
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 = 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 = 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 ")
So far...
Hope to help you.
From: http://www.cnblogs.com/ziyiFly/archive/2008/09/22/1296218.html