c# Graphics使用方法(畫圓寫字代碼)
更新時間:2014年01月06日 11:00:43 作者:
本文主要介紹了Graphics的使用方法,提供如何畫圓、寫字的代碼,大家參考使用吧
畫填充圓:
復(fù)制代碼 代碼如下:
Graphics gra = this.pictureBox1.CreateGraphics();
gra.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Brush bush = new SolidBrush(Color.Green);//填充的顏色
gra.FillEllipse(bush, 10, 10, 100, 100);//畫填充橢圓的方法,x坐標(biāo)、y坐標(biāo)、寬、高,如果是100,則半徑為50
畫圓圈:
復(fù)制代碼 代碼如下:
Graphics gra = this.pictureBox1.CreateGraphics();
gra.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Pen pen = new Pen(Color.Pink);//畫筆顏色
gra.DrawEllipse(pen, 250, 10, 100, 100);//畫橢圓的方法,x坐標(biāo)、y坐標(biāo)、寬、高,如果是100,則半徑為50
寫字:
復(fù)制代碼 代碼如下:
Graphics gra = this.pictureBox1.CreateGraphics();
Font myFont = new Font("宋體", 60, FontStyle.Bold);
Brush bush = new SolidBrush(Color.Red);//填充的顏色
gra.DrawString("腳本之家!", myFont, bush, 100, 100);
相關(guān)文章
C#如何利用結(jié)構(gòu)體對固定格式數(shù)據(jù)進行解析
這篇文章主要為大家詳細(xì)介紹了C#利用結(jié)構(gòu)體對固定格式數(shù)據(jù)進行解析,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-01-01

