C# 357, 325 with minor cheating
Yea, C# isn't gonna win many codegolf prizes against other languages. Still, fun!
Cheating (not exactly centre, and only centre with .NET 4.5's default form size of 300x300, Mono may do other funny stuff):
using System.Windows.Forms;using System.Drawing;class P:Form{static void Main(){new P().ShowDialog();}public P(){var l=new Label(){Top=125,Left=120,ForeColor=Color.White};Controls.Add(l);new Timer(){Enabled=true,Interval=1}.Tick+=(s,e)=>{BackColor=ColorTranslator.FromHtml(l.Text=System.DateTime.Now.ToString("#HHmmss"));};}}
Golfed:
using System.Windows.Forms;using System.Drawing;class P:Form{static void Main(){new P().ShowDialog();}public P(){var l=new Label(){Dock=(DockStyle)5,TextAlign=(ContentAlignment)32,ForeColor=Color.White};Controls.Add(l);new Timer(){Enabled=true,Interval=1}.Tick+=(s,e)=>{BackColor=ColorTranslator.FromHtml(l.Text=System.DateTime.Now.ToString("#HHmmss"));};}}
Ungolfed:
using System.Windows.Forms;
using System.Drawing;
class P : Form
{
static void Main()
{
new P().ShowDialog();
}
public P()
{
var l = new Label() { Dock = (DockStyle)5, TextAlign = (ContentAlignment)32, ForeColor = Color.White };
Controls.Add(l);
new Timer() { Enabled = true, Interval = 1 }.Tick += (s, e) =>
{
BackColor = ColorTranslator.FromHtml(l.Text = System.DateTime.Now.ToString("#HHmmss"));
};
}
}
I liked the idea, but it'd be better as a popularity contest imo – William Barbosa – 2014-06-20T21:52:28.627
8@WilliamBarbosa I believe the result is way too simple for a popularity contest to be useful. – qwr – 2014-06-20T22:48:36.357
You may want to point out that the IIB post is an x-post from /r/minimalism. But heh. – cjfaure – 2014-06-22T17:24:50.580