Updated the to use the phong procedure to achieve rounded look on the outer ring.
Thank you Circular
unit umain;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, BGRAVirtualScreen, Forms, Controls,
Graphics, Dialogs, ExtCtrls,
BGRABitmap, BGRABitmapTypes, bgrasamples, BGRAButton, BGRATextFX, BGRAGradients;
type
{ TForm1 }
TForm1 = class(TForm)
vsClock: TBGRAVirtualScreen;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure vsClockRedraw(Sender: TObject; Bitmap: TBGRABitmap);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.vsClockRedraw(Sender: TObject; Bitmap: TBGRABitmap);
var
txt: TBGRACustomBitmap;
w, h, r, A, Xo, Yo, X, Y, Xt, Yt: integer;
Xs, Ys, Xm, Ym, Xh, Yh: integer;
th, tm, ts, tn: word;
phong: TPhongShading;
begin
w := (Sender as TControl).Width;
h := (Sender as TControl).Height;
{ Set center point }
Xo := w div 2;
Yo := h div 2;
// Determine radius. If canvas is rectangular then r = shortest length w or h
r := yo;
if xo > yo then
r := yo;
if xo < yo then
r := xo;
// Convert current time to integer values
decodetime(Time, th, tm, ts, tn);
{ Set coordinates (length of arm) for seconds }
Xs := Xo + Round(r * 0.78 * Sin(ts * 6 * Pi / 180));
Ys := Yo - Round(r * 0.78 * Cos(ts * 6 * Pi / 180));
{ Set coordinates (length of arm) for minutes }
Xm := Xo + Round(r * 0.68 * Sin(tm * 6 * Pi / 180));
Ym := Yo - Round(r * 0.68 * Cos(tm * 6 * Pi / 180));
{ Set coordinates (length of arm) for hours }
Xh := Xo + Round(r * 0.50 * Sin((th * 30 + tm / 2) * Pi / 180));
Yh := Yo - Round(r * 0.50 * Cos((th * 30 + tm / 2) * Pi / 180));
// Draw Bitmap frame
Bitmap.FillEllipseAntialias(Xo, Yo, r * 0.99, r * 0.99, BGRA(175, 175, 175));
// Draw Rounded/RIng type border using shading
phong := TPhongShading.Create;
phong.LightPosition := point(Xo, Yo);
phong.DrawSphere(Bitmap, rect(round(Xo - r * 0.98), round(Yo - r * 0.98), round(Xo + r * 0.98) + 1, round(Yo + r * 0.98) + 1), 4, BGRA(245, 245, 245));
phong.Free;
Bitmap.FillEllipseLinearColorAntialias(Xo, Yo, r * 0.88, r * 0.88, BGRA(0, 58, 81), BGRA(2, 94, 131));
// Draw Face frame
Bitmap.FillEllipseAntialias(Xo, Yo, r * 0.90, r * 0.90, BGRA(175, 175, 175));
// Draw face background
Bitmap.FillEllipseLinearColorAntialias(Xo, Yo, r * 0.88, r * 0.88, BGRA(0, 58, 81), BGRA(2, 94, 131));
// Draw Bitmap face
for A := 1 to 12 do
begin
X := Xo + Round(r * 0.80 * Sin(30 * A * Pi / 180));
Y := Yo - Round(r * 0.80 * Cos(30 * A * Pi / 180));
Xt := Xo + Round(r * 0.70 * Sin(30 * A * Pi / 180));
Yt := Yo - Round(r * 0.70 * Cos(30 * A * Pi / 180));
Bitmap.EllipseAntialias(x, y, (r * 0.02), (r * 0.02), BGRA(255, 255, 255, 200),
2, BGRA(2, 94, 131));
Bitmap.FontName := 'Calibri';
Bitmap.FontHeight := r div 8;
Bitmap.FontQuality := fqFineAntialiasing;
Bitmap.TextOut(Xt, Yt - (Bitmap.FontHeight / 1.7), IntToStr(A),
BGRA(245, 245, 245), taCenter);
end;
// Draw text
txt := TextShadow(w, h, 'www.Digeotek.com', trunc(r * 0.12),
ColorToBGRA(clWhite), BGRABlack, 4, 4, 10, [], 'Calibri');
Bitmap.BlendImage(0, 0 - (r div 3), txt, boLinearBlend);
txt.Free;
// Draw time hands
Bitmap.DrawLineAntialias(xo, yo, xs, ys, BGRA(255, 0, 0), r * 0.02);
Bitmap.DrawLineAntialias(xo, yo, xm, ym, BGRA(245, 245, 245), r * 0.03);
Bitmap.DrawLineAntialias(xo, yo, xh, yh, BGRA(245, 245, 245), r * 0.07);
Bitmap.DrawLineAntialias(xo, yo, xh, yh, BGRA(2, 94, 131), r * 0.04);
// Draw Bitmap centre dot
Bitmap.EllipseAntialias(Xo, Yo, r * 0.04, r * 0.04, BGRA(245, 245, 245, 255),
r * 0.02, BGRA(210, 210, 210, 255));
Bitmap.BlendImage(0, 0, Bitmap, boLinearBlend);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
vsClock.RedrawBitmap;
end;
end.