陰影文字實現
private void Form1_Paint(object sender, PaintEventArgs e)
{
//陰影文字
string text = "博客園";
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);
}
六.紋理效果
程序運行效果截圖:
程序代碼實現如下:
線理效果實現
private void Form1_Paint(object sender, PaintEventArgs e)
{
//使用圖像填充文字線條
TextureBrush brush = new TextureBrush(Image.FromFile(Application.StartupPath + "\\myPicture.jpg"));
Graphics g = e.Graphics;
g.DrawString("博客園", new Font("隸書", 60), brush, new PointF(0, 0));
}
七. 傾斜效果
程序運行效果截圖: