Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program ConsoleClock;{$APPTYPE CONSOLE}
- uses windows, SysUtils, graphics;
- procedure DrawClk;
- var b:tbitmap;
- function a2p(const a,r:single):TPoint; //transzforamcio polarbol -> screen-re
- begin
- result.x:=round(cos(a-pi/2)*r*1.3)+40;
- result.y:=round(sin(a-pi/2)*r)+25;
- end;
- procedure text(a,r:single;s:string);
- begin
- //ezt imádni fogod a C#-bol :D
- with b.canvas, textextent(s), a2p(a,r)do TextOut(x-cx shr 1, y-cy shr 1,s);
- end;
- procedure line(a,r0,r1:single);
- begin
- with a2p(a,r0)do b.Canvas.MoveTo(x,y);
- with a2p(a,r1)do b.Canvas.LineTo(x,y);
- end;
- const szamlap:array[1..12]of string=('I','II','III','IV','V','VI','VII','VIII','IX','X','XI','XII');
- var h,m,s,z:word;
- c,i,j,k:integer;
- st:ansistring;
- ch:ansichar;
- a:single;
- begin
- DecodeTime(now,h,m,s,z);
- b:=TBitmap.Create;
- with b, Canvas do begin
- PixelFormat:=pf32bit; Width:=80; Height:=50;
- Font.Name:='Times New Roman';
- Font.Size:=8;
- Brush.Style:=bsClear;
- for i:=1 to 12 do text(i/12*2*pi,22,szamlap[i]); //számozás
- //kismutato
- a:=frac(now)*pi;
- Pen.Color:=clBlack; Pen.Width:=3; line(a,-3,8);
- Pen.Color:=clWhite; Pen.Width:=1; line(a,-3,8);
- //nagymutato
- a:=a*12;
- Pen.Color:=clBlack; Pen.Width:=3; line(a,-3,16);
- Pen.Color:=clWhite; Pen.Width:=1; line(a,-3,16);
- //masodperec
- a:=a*60;
- Pen.Color:=clBlack; Pen.Width:=1; line(a,-3,16);
- i:=0;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),_COORD(i));//cursor home
- st:='';
- for j:=0 to b.Height shr 1-1 do for i:=0 to b.Width-1 do begin
- c:=0;for k:=0 to 1 do c:=c+PIntegerArray(b.ScanLine[j shl 1+k])[i]and $ff;
- if c=$ff*2 then ch:=' ' else if c=0 then ch:='#' else ch:='+';
- st:=st+ch;
- end;
- Delete(st,length(st),1);// ne legyen ujsor a legaljan
- write(st);
- free;//b
- end;
- end;
- begin
- while True do begin DrawClk;Sleep(300);end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment