Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9537

cscの作法 その56

$
0
0
概要 cscの作法、調べてみた。 練習問題やってみた。 練習問題 タイマー使って、いろんなsin波、見せて。 写真 サンプルコード using System; using System.Windows.Forms; using System.Drawing; class form1: Form { form1() { ClientSize = new Size(800, 300); Timer timer = new Timer(); timer.Interval = 10000; timer.Tick += new EventHandler(timerTick); timer.Start(); } protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; Bitmap p = new Bitmap(800, 300); Brush red = new SolidBrush(Color.Red); int j; double angle; Random r = new Random(); double d = r.NextDouble(); for (j = 0; j < 720; j++) { angle = ((double) j) / 360 * 2 * Math.PI / d; p.SetPixel(j, (int)(100 * Math.Sin(angle) + 150), Color.Red); } g.DrawImageUnscaled(p, 0, 0); base.OnPaint(e); } void timerTick(object sender, EventArgs e) { Text = DateTime.Now.ToString("HH:mm:ss"); this.Invalidate(); } [STAThread] public static void Main() { Application.Run(new form1()); } } 以上。

Viewing all articles
Browse latest Browse all 9537

Trending Articles