c#:畫圓(整理)


  • Random random = new Random();

  •   

  • Color getRandomColor()

  • {

  •     return Color.FromArgb(

  •          random.Next(256) ,

  •          random.Next(256) ,

  •          random.Next(256) );

  • }

  •   

  • private void button1_Click(object sender, System.EventArgs e)

  • {

  •     Graphics g = this.CreateGraphics();

  •   

  •     int x0 = this.Width /2;

  •     int y0 = this.Height /2;

  •   

  •     forint r=0 ; r<this.Height/2; r++ )

  •     {

  •         g.DrawEllipse(

  •             new Pen( getRandomColor(),1), 

  •             x0-r,y0-r, r*2, r*2 

  •             );

  •     

  •     g.Dispose();        

  • }


  • 免責聲明!

    本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



     
    粵ICP備18138465號   © 2018-2025 CODEPRJ.COM