Visual C# 2005 - 如何制作多变化字体之浮雕字

本文介绍了一种使用C#中的System.Drawing命名空间实现浮雕文字效果的方法。通过Graphics类的DrawString方法结合不同颜色的Brush对象,根据用户选择的刻度调整字号,实现了文字的浮雕效果。

 

本文将示范如何利用 System.Drawing 命名空间中的 Graphics Brush 类别来制作出带有浮雕效果的文字。 

程序范例 

 

图表1 

 

图表2 

图表 1 2 是我们所撰写之程序范例的执行结果。我们主要使用 Graphics 类别的 DrawString 方法,并根据用户所选取的刻度去调整绘图字号,以便制作出带有浮雕效果的文字。程序代码列示如下: 

SizeF textSize;
Graphics g;
Brush myBackBrush = Brushes.Blue;
Brush myForeBrush = Brushes.White;
Font myFont = new Font("Times New Roman",
  (float)this.nudFontSize.Value, FontStyle.Regular);
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.DrawString(txtShortText.Text, myFont, myBackBrush,
  xLocation + (float)this.nudEmbossDepth.Value,
  yLocation + (float)this.nudEmbossDepth.Value);

g.DrawString(txtShortText.Text, myFont, myForeBrush, xLocation,
  yLocation);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值