procedure TBSelector.Redraw;
const
pi15 = pi * 1.5;
var
textBmp: TBGRABitmap;
textStr: string;
EffectiveSize: integer;
EffectiveLineWidth: single;
r: single;
RMinAngle, RMaxAngle, RMinTicksAngle, RMaxTicksAngle, RAngle: single;
blur: TBGRABitmap;
mask: TBGRABitmap;
phong: TPhongShading;
procedure DoDrawArc(a, b: single; c: TColor);
begin
FBitmap.Canvas2D.strokeStyle(c);
FBitmap.Canvas2D.beginPath;
FBitmap.Canvas2D.arc(0, 0, r, a, b, False);
FBitmap.Canvas2D.stroke;
end;
procedure DoDrawTicks(a, b: single; c: TColor);
begin
//ToDo
end;
begin
FBitmap.SetSize(Width, Height);
FBitmap.Fill(FBkgColor);
if Width < Height then
EffectiveSize := Width
else
EffectiveSize := Height;
if EffectiveSize < 2 then exit;
FBitmap.Canvas2D.resetTransform;
FBitmap.Canvas2D.translate(FBitmap.Width / 2, FBitmap.Height / 2);
FBitmap.Canvas2D.rotate(pi15);
if FLineWidth = 0 then
EffectiveLineWidth := EffectiveSize / 12
else
EffectiveLineWidth := FLineWidth;
r := (EffectiveSize - EffectiveLineWidth) / 2;
FBitmap.Canvas2D.lineWidth := EffectiveLineWidth;
RMinAngle := (180 + FMinAngle) * pi / 180;
RMaxAngle := ((180 + FMaxAngle) * pi / 180) - RMinAngle;
RMinTicksAngle := (180 + FMinTicksAngle) * pi / 180;
RMaxTicksAngle := ((180 + FMaxTicksAngle) * pi / 180) - RMinTicksAngle;
FBitmap.Canvas2D.lineCapLCL := pecRound;
// background line
if FLineBkgColor <> clNone then
DoDrawArc(RMinAngle, (RMaxAngle + RMinAngle), FLineBkgColor);
RAngle := (RMaxTicksAngle / (FTicksCount + FOffset)) * ((FValue + FOffset) - ((FTicksCount + FOffset) / 2));
if Enabled then
begin
if FValue >= 0 then
DoDrawArc(RAngle - FPointerSize / 100, RAngle + FPointerSize / 100, FLineColor);
end
else
DoDrawArc(RAngle - FPointerSize / 100, RAngle + FPointerSize / 100, clGray);
if FDrawText then
begin
if FItems.Count >= FValue then
textStr := FItems[FValue]
else
textStr := 'NaN';
textBmp := TextShadow(Width, Height, textStr, Font.Height,
Font.Color, FontShadowColor, FontShadowOFfsetX,
FontShadowOffsetY, FontShadowRadius, Font.Style, Font.Name) as TBGRABitmap;
FBitmap.PutImage(0, 0, textBmp, dmDrawWithTransparency);
textBmp.Free;
end;
if FDrawTicks then
DoDrawTicks(-(FBitmap.Width / 2 - 5), 0, clBlack);
if FDrawPhong then
begin
mask := FBitmap.FilterGrayscale as TBGRABitmap;
mask.Negative;
blur := Mask.FilterBlurRadial(5, 5, rbFast) as TBGRABitmap;
blur.FillMask(0, 0, mask, BGRAPixelTransparent, dmSet);
phong := TPhongShading.Create;
phong.Draw(FBitmap, blur, 2, 0, 0, FBitmap);
phong.Free;
blur.Free;
Mask.Free;
end;
FBitmap.Draw(Canvas, 0, 0, True);
end;