時計の秒針について
Posted: 2012年7月22日(日) 14:25
今時計を作ろうとして秒針を書こうとしています。
しかし僕が書いたのじゃあまりにもしょぼすぎます。
秒針に
http://d.hatena.ne.jp/machi_pon/20090509/1241841494
に紹介されているような感じにしたいのですがどうすればいいですか?
しかし僕が書いたのじゃあまりにもしょぼすぎます。
秒針に
http://d.hatena.ne.jp/machi_pon/20090509/1241841494
に紹介されているような感じにしたいのですがどうすればいいですか?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace clock
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//ペン定義
Pen sec = new Pen(Color.Black, 2); //秒針ペン
Pen W = new Pen(Color.White, 2); //消去ペン
//変数定義
double sK, sX, sY; //秒針角度
int bX, bY, bX0, bY0; //秒針座標
int br = 95; //秒針の長さ
private void timer1_Tick(object sender, EventArgs e)
{
//描画定義
Graphics g = pictureBox1.CreateGraphics();
//現在の時間
DateTime T = DateTime.Now;
label1.Text = T.ToString("T");
//秒針の消去
g.DrawLine(W, 125, 125, bX0, 250 - bY0);
//秒針
sK = T.Second * 6 * 0.01745 - 1.57; //秒針の角度計算
sX = Math.Cos(sK) * br; //終点のX座標
sY = Math.Sin(sK) * br; //始点のY座標
bX = (int)sX; bY = (int)sY; //int型に変換
bX = 125 + bX; bY = 125 - bY; //中心からの終点座標
bX0 = bX; bY0 = bY; //消去変数
g.DrawLine(sec, 125, 125, bX, 250 - bY); //秒針描画
}
}
}