本文将介绍如何使用 System.Drawing 命名空间中的 Graphics Brush 类别来制作带有向量效果的文字。 

程序范例 

Visual C# 2005 - 如何制作多变化字体之向量字 

图表1 

Visual C# 2005 - 如何制作多变化字体之向量字 

图表2 

图表 1 2 的程序范例示范如何利用 Graphics 类别的 ShearTransformTranslateTransform 以及 DrawString 方法,来根据用户所选取的刻度去调整绘图字号,以便产生带有向量效果的文字,程序代码如下所示: 

SizeF textSize;
Graphics g;
Brush myForeBrush = Brushes.Blue;
Font myFont = new Font("Times New Roman",
  (float)this.nudFontSize.Value, FontStyle.Regular);
Matrix myTransform;
float xLocation, yLocation;

g = picDemoArea.CreateGraphics();
g.Clear(Color.White);

textSize = g.MeasureString(this.txtShortText.Text, myFont);

xLocation = (picDemoArea.Width - textSize.Width) / 2;
yLocation = (picDemoArea.Height - textSize.Height) / 2;

g.TranslateTransform(xLocation, yLocation);

myTransform = g.Transform;
myTransform.Shear((float)nudSkew.Value, 0);
g.Transform = myTransform;

g.DrawString(txtShortText.Text, myFont, myForeBrush, 0, 0);

相关文章:

  • 2021-11-17
  • 2022-03-06
  • 2021-05-12
  • 2021-11-18
  • 2021-06-20
  • 2021-12-24
  • 2022-02-17
猜你喜欢
  • 2021-05-22
  • 2021-12-16
  • 2021-11-11
  • 2021-11-22
  • 2021-10-06
  • 2023-03-19
相关资源
相似解决方案