📄 qisevensegmentcharacter.pas
字号:
end;
end;
//****************************************************************************************************************************************************
procedure TiSevenSegmentCharacter.DrawSegmentE(Canvas: TCanvas; Offset: TPoint; AColor: TColor; AWidth, AHeight: Integer);
begin
with Canvas do
begin
Brush.Color := AColor;
Pen.Color := AColor;
Polygon([Point(Offset.x + FSegmentMargin, Offset.y + (AHeight - 1) div 2 + FSegmentSeperation ),
Point(Offset.x + FSegmentMargin, Offset.y + (AHeight - 1) - FSegmentMargin - FSegmentSeperation ),
Point(Offset.x + FSegmentMargin + FSegmentSize * 2, Offset.y + (AHeight - 1) - FSegmentMargin - FSegmentSeperation - FSegmentSize * 2),
Point(Offset.x + FSegmentMargin + FSegmentSize * 2, Offset.y + (AHeight - 1) div 2 + FSegmentSeperation + FSegmentSize * 2)]);
end;
end;
//****************************************************************************************************************************************************
procedure TiSevenSegmentCharacter.DrawSegmentF(Canvas: TCanvas; Offset: TPoint; AColor: TColor; AWidth, AHeight: Integer);
begin
with Canvas do
begin
Brush.Color := AColor;
Pen.Color := AColor;
Polygon([Point(Offset.x + FSegmentMargin, Offset.y + FSegmentMargin + FSegmentSeperation ),
Point(Offset.x + FSegmentMargin, Offset.y + (AHeight - 1) div 2 - FSegmentSeperation ),
Point(Offset.x + FSegmentMargin + FSegmentSize * 2, Offset.y + (AHeight - 1) div 2 - FSegmentSeperation - FSegmentSize * 2),
Point(Offset.x + FSegmentMargin + FSegmentSize * 2, Offset.y + FSegmentMargin + FSegmentSeperation + FSegmentSize * 2)]);
end;
end;
//****************************************************************************************************************************************************
procedure TiSevenSegmentCharacter.DrawSegmentG(Canvas: TCanvas; Offset: TPoint; AColor: TColor; AWidth, AHeight: Integer);
begin
with Canvas do
begin
Brush.Color := AColor;
Pen.Color := AColor;
Polygon([Point(Offset.x + FSegmentMargin + FSegmentSeperation, Offset.y + (AHeight - 1) div 2 ),
Point(Offset.x + FSegmentMargin + FSegmentSeperation + FSegmentSize, Offset.y + (AHeight - 1) div 2 - FSegmentSize),
Point(Offset.x + AWidth - 1 - FSegmentMargin - FSegmentSeperation - FSegmentSize, Offset.y + (AHeight - 1) div 2 - FSegmentSize),
Point(Offset.x + AWidth - 1 - FSegmentMargin - FSegmentSeperation , Offset.y + (AHeight - 1) div 2 ),
Point(Offset.x + AWidth - 1 - FSegmentMargin - FSegmentSeperation - FSegmentSize, Offset.y + (AHeight - 1) div 2 + FSegmentSize),
Point(Offset.x + FSegmentMargin + FSegmentSeperation + FSegmentSize, Offset.y + (AHeight - 1) div 2 + FSegmentSize)]);
end;
end;
//****************************************************************************************************************************************************
procedure TiSevenSegmentCharacter.DrawSegmentColon(Canvas: TCanvas; Offset: TPoint; AColor: TColor; AWidth, AHeight: Integer);
begin
with Canvas do
begin
Brush.Color := AColor;
Pen.Color := AColor;
Polygon([Point(Offset.x + AWidth div 2 - (FSegmentSize * 1), Offset.y + Round(AHeight * 5/18)),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + Round(AHeight * 5/18)),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + Round(AHeight * 7/18)),
Point(Offset.x + AWidth div 2 - (FSegmentSize * 1), Offset.y + Round(AHeight * 7/18))]);
Polygon([Point(Offset.x + AWidth div 2 - (FSegmentSize * 1), Offset.y + Round(AHeight * 11/18)),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + Round(AHeight * 11/18)),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + Round(AHeight * 13/18)),
Point(Offset.x + AWidth div 2 - (FSegmentSize * 1), Offset.y + Round(AHeight * 13/18))]);
end;
end;
//****************************************************************************************************************************************************
procedure TiSevenSegmentCharacter.DrawSegmentSemiColon(Canvas: TCanvas; Offset: TPoint; AColor: TColor; AWidth, AHeight: Integer);
begin
with Canvas do
begin
Brush.Color := AColor;
Pen.Color := AColor;
Polygon([Point(Offset.x + AWidth div 2 - (FSegmentSize * 1), Offset.y + Round(AHeight * 5/18)),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + Round(AHeight * 5/18)),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + Round(AHeight * 7/18)),
Point(Offset.x + AWidth div 2 - (FSegmentSize * 1), Offset.y + Round(AHeight * 7/18))]);
Polygon([Point(Offset.x + AWidth div 2 - (FSegmentSize * 1), Offset.y + Round(AHeight * 11/18)),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + Round(AHeight * 11/18)),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + Round(AHeight * 13/18)),
Point(Offset.x + AWidth div 2 - (FSegmentSize * 1), Offset.y + Round(AHeight * 13/18))]);
Polygon([Point(Offset.x + AWidth div 2 , Offset.y + Round(AHeight * 13/18)),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + Round(AHeight * 13/18)),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + Round(AHeight * 16/18)),
Point(Offset.x + AWidth div 2 , Offset.y + Round(AHeight * 16/18))]);
end;
end;
//****************************************************************************************************************************************************
procedure TiSevenSegmentCharacter.DrawSegmentPeriod(Canvas: TCanvas; Offset: TPoint; AColor: TColor; AWidth, AHeight: Integer);
begin
with Canvas do
begin
Brush.Color := AColor;
Pen.Color := AColor;
Polygon([Point(Offset.x + AWidth div 2 - (FSegmentSize * 1), Offset.y + AHeight - 2*FSegmentSize),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + AHeight - 2*FSegmentSize),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + AHeight ),
Point(Offset.x + AWidth div 2 - (FSegmentSize * 1), Offset.y + AHeight )]);
end;
end;
//****************************************************************************************************************************************************
procedure TiSevenSegmentCharacter.DrawSegmentComma(Canvas: TCanvas; Offset: TPoint; AColor: TColor; AWidth, AHeight: Integer);
begin
with Canvas do
begin
Brush.Color := AColor;
Pen.Color := AColor;
Polygon([Point(Offset.x + AWidth div 2 - (FSegmentSize * 1), Offset.y + Round(AHeight * 11/18)),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + Round(AHeight * 11/18)),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + Round(AHeight * 13/18)),
Point(Offset.x + AWidth div 2 - (FSegmentSize * 1), Offset.y + Round(AHeight * 13/18))]);
Polygon([Point(Offset.x + AWidth div 2 , Offset.y + Round(AHeight * 13/18)),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + Round(AHeight * 13/18)),
Point(Offset.x + AWidth div 2 + (FSegmentSize * 1), Offset.y + Round(AHeight * 16/18)),
Point(Offset.x + AWidth div 2 , Offset.y + Round(AHeight * 16/18))]);
end;
end;
//****************************************************************************************************************************************************
procedure TiSevenSegmentCharacter.DrawSegmentPlus(Canvas: TCanvas; Offset: TPoint; AColor: TColor; AWidth, AHeight: Integer);
begin
with Canvas do
begin
Brush.Color := AColor;
Pen.Color := AColor;
Polygon([Point(Offset.x + Round(AWidth * 2.5/10), Offset.y + Round(AHeight*4.5/18 - 0.5*FSegmentSize)),
Point(Offset.x + Round(AWidth * 7.5/10), Offset.y + Round(AHeight*4.5/18 - 0.5*FSegmentSize)),
Point(Offset.x + Round(AWidth * 7.5/10), Offset.y + Round(AHeight*4.5/18 + 0.5*FSegmentSize)),
Point(Offset.x + Round(AWidth * 2.5/10), Offset.y + Round(AHeight*4.5/18 + 0.5*FSegmentSize))]);
Polygon([Point(Offset.x + Round(AWidth*0.5 - 0.5*FSegmentSize), Offset.y + Round(AHeight*2.0/18)),
Point(Offset.x + Round(AWidth*0.5 + 0.5*FSegmentSize), Offset.y + Round(AHeight*2.0/18)),
Point(Offset.x + Round(AWidth*0.5 + 0.5*FSegmentSize), Offset.y + Round(AHeight*7.0/18)),
Point(Offset.x + Round(AWidth*0.5 - 0.5*FSegmentSize), Offset.y + Round(AHeight*7.0/18))]);
end;
end;
//****************************************************************************************************************************************************
procedure TiSevenSegmentCharacter.DrawSegmentMinus(Canvas: TCanvas; Offset: TPoint; AColor: TColor; AWidth, AHeight: Integer);
begin
with Canvas do
begin
Brush.Color := AColor;
Pen.Color := AColor;
Polygon([Point(Offset.x + Round(AWidth * 2.5/10), Offset.y + Round(AHeight*13.5/18 - 0.5*FSegmentSize)),
Point(Offset.x + Round(AWidth * 7.5/10), Offset.y + Round(AHeight*13.5/18 - 0.5*FSegmentSize)),
Point(Offset.x + Round(AWidth * 7.5/10), Offset.y + Round(AHeight*13.5/18 + 0.5*FSegmentSize)),
Point(Offset.x + Round(AWidth * 2.5/10), Offset.y + Round(AHeight*13.5/18 + 0.5*FSegmentSize))]);
end;
end;
//****************************************************************************************************************************************************
procedure TiSevenSegmentCharacter.DrawSegmentLine(Canvas: TCanvas; Offset: TPoint; AColor: TColor; AWidth, AHeight: Integer);
begin
with Canvas do
begin
Brush.Color := AColor;
Pen.Color := AColor;
Polygon([Point(Offset.x + FSegmentMargin, Offset.y + (AHeight-1) div 2 - FSegmentSize div 2),
Point(Offset.x + AWidth-1 - FSegmentMargin, Offset.y + (AHeight-1) div 2 - FSegmentSize div 2),
Point(Offset.x + AWidth-1 - FSegmentMargin, Offset.y + (AHeight-1) div 2 + FSegmentSize div 2),
Point(Offset.x + FSegmentMargin, Offset.y + (AHeight-1) div 2 + FSegmentSize div 2)]);
end;
end;
//****************************************************************************************************************************************************
procedure TiSevenSegmentCharacter.DrawSegmentUpArrow(Canvas: TCanvas; Offset: TPoint; AColor: TColor; AWidth, AHeight: Integer);
var
HalfWidth : Integer;
begin
HalfWidth := (AWidth - 1 - 2*FSegmentMargin) div 2;
with Canvas do
begin
Brush.Color := AColor;
Pen.Color := AColor;
if (AHeight div 2 - HalfWidth) > FSegmentMargin then
Polygon([Point(Offset.x + (AWidth-1) div 2 + HalfWidth, Offset.y + AHeight div 2 ),
Point(Offset.x + (AWidth-1) div 2 - HalfWidth, Offset.y + AHeight div 2 ),
Point(Offset.x + (AWidth-1) div 2 , Offset.y + AHeight div 2 - HalfWidth)])
else
Polygon([Point(Offset.x + (AWidth-1) div 2 + HalfWidth, Offset.y + AHeight div 2 ),
Point(Offset.x + (AWidth-1) div 2 - HalfWidth, Offset.y + AHeight div 2 ),
Point(Offset.x + (AWidth-1) div 2 , Offset.y + FSegmentMargin )]);
end;
end;
//****************************************************************************************************************************************************
procedure TiSevenSegmentCharacter.DrawSegmentDownArrow(Canvas: TCanvas; Offset: TPoint; AColor: TColor; AWidth, AHeight: Integer);
var
HalfWidth : Integer;
begin
HalfWidth := (AWidth - 1 - 2*FSegmentMargin) div 2;
with Canvas do
begin
Brush.Color := AColor;
Pen.Color := AColor;
if (AHeight div 2 + HalfWidth) < (AHeight - 1 - FSegmentMargin) then
Polygon([Point(Offset.x + (AWidth-1) div 2 + HalfWidth, Offset.y + AHeight div 2 ),
Point(Offset.x + (AWidth-1) div 2 - HalfWidth, Offset.y + AHeight div 2 ),
Point(Offset.x + (AWidth-1) div 2 , Offset.y + AHeight div 2 + HalfWidth )])
else
Polygon([Point(Offset.x + (AWidth-1) div 2 + HalfWidth, Offset.y + AHeight div 2 ),
Point(Offset.x + (AWidth-1) div 2 - HalfWidth, Offset.y + AHeight div 2 ),
Point(Offset.x + (AWidth-1) div 2 , Offset.y + AHeight - 1 - FSegmentMargin )]);
end;
end;
//****************************************************************************************************************************************************
procedure TiSevenSegmentCharacter.SetSegmentBits(Value: Byte);
begin
FSegAOn := Value and $01 <> 0;
FSegBOn := Value and $02 <> 0;
FSegCOn := Value and $04 <> 0;
FSegDOn := Value and $08 <> 0;
FSegEOn := Value and $10 <> 0;
FSegFOn := Value and $20 <> 0;
FSegGOn := Value and $40 <> 0;
InvalidateChange;
end;
//****************************************************************************************************************************************************
function TiSevenSegmentCharacter.GetSegmentBits: Byte;
begin
Result := 0;
if FSegAOn then Result := Result or $01;
if FSegBOn then Result := Result or $02;
if FSegCOn then Result := Result or $04;
if FSegDOn then Result := Result or $08;
if FSegEOn then Result := Result or $10;
if FSegFOn then Result := Result or $20;
if FSegGOn then Result := Result or $40;
end;
//****************************************************************************************************************************************************
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -