輕松實(shí)現(xiàn)旋轉(zhuǎn)顯示文本
2024-07-21 02:18:31
供稿:網(wǎng)友
//本程序顯示如何旋轉(zhuǎn)顯示文本,代碼很簡單,不過個(gè)人覺得做學(xué)習(xí)用還是不錯(cuò)的!
//作者: i.posei(ipqn)
//歡迎訪問 www.kunwsoft.com
using system;
using system.drawing;
using system.collections;
using system.componentmodel;
using system.windows.forms;
using system.data;
using system.drawing.drawing2d;
using system.drawing.text;
namespace eddy
{
public class form1:system.windows.forms.form
{
/// 必需的設(shè)計(jì)器變量。
private system.componentmodel.container components = null;
public form1()
{
initializecomponent();
}
protected override void dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.dispose();
}
}
base.dispose( disposing );
}
private void initializecomponent()
{
this.autoscalebasesize = new system.drawing.size(6, 14);
this.clientsize = new system.drawing.size(520, 520);
this.name = "form1";
this.text = "旋轉(zhuǎn)顯示文本";
this.paint += new system.windows.forms.painteventhandler(this.form1_paint);
}
[stathread]
static void main()
{
application.run(new form1());
}
private void form1_paint(object sender,system.windows.forms.painteventargs e)
{
//聲明并且初始化graphics對(duì)象
graphics g=e.graphics;
g.smoothingmode=smoothingmode.antialias;
string str="c#學(xué)習(xí)筆記 kunwsoft.com";
for(int i=0;i<360;i=i+10)
{
g.translatetransform(260,260);
//將指定旋轉(zhuǎn)應(yīng)用于g的變換矩陣
g.rotatetransform(i);
brush mybrush=brushes.red;
font drawfont = new font("宋體", 12);
g.drawstring(str,drawfont,mybrush,60,0);
g.resettransform();
}
}
}
}