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)文章
Unity實現(xiàn)移動物體到鼠標(biāo)點擊位置
這篇文章主要為大家詳細介紹了Unity實現(xiàn)移動物體到鼠標(biāo)點擊位置,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2020-08-08C#中判斷本地系統(tǒng)的網(wǎng)絡(luò)連接狀態(tài)的方法
C#中一般通過InternetGetConnectedState函數(shù)返回本地系統(tǒng)的網(wǎng)絡(luò)連接狀態(tài),下面簡單介紹下,需要的朋友可以參考下2013-10-10