tecircle.pas

来自「delphi2007界面效果控件源码」· PAS 代码 · 共 858 行 · 第 1/2 页

PAS
858
字号
  if Draw then
    MaskBmp.Canvas.Ellipse(Data.UpdateRect.Left, Data.UpdateRect.Top,
      Data.UpdateRect.Right, Data.UpdateRect.Bottom);
  Data.UnUpdateRect := CalcRect(Data.Width, CurrentFrame - Step, True);
end;

procedure TCircleTransition.Style2_5Frame(MaskBmp: TBitmap;
  Data: TTETransitionData; CurrentFrame, Step: Longint; Draw: Boolean);

  function CalcRect(Frame: Integer;
    ForUpdateRect, ForUnUpdateRect: Boolean): TRect;
  var
    R, D: Integer;
    c1, c2, c3, c4: Integer;
  begin
    R := Data.Frames - Frame;

    c1 := -R;
    c2 := -R;
    c3 := R;
    c4 := R;

    Result := Rect(c1, c2, c3, c4);

    if ForUpdateRect then
      InflateRect(Result, Step, Step);

    if ForUnUpdateRect then
    begin
      D := 1 + R - Round(Sqrt(Sqr(R) div 2));
      InflateRect(Result, -D, -D);
    end;
  end;

begin
  Data.UpdateRect :=
    CalcRect(CurrentFrame - Step, True, False);
  Data.UnUpdateRect := CalcRect(CurrentFrame, False, True);
  if Draw then
    with CalcRect(CurrentFrame, False, False) do
      MaskBmp.Canvas.Ellipse(Left, Top, Right, Bottom);
end;

procedure TCircleTransition.Style2_6Frame(MaskBmp: TBitmap;
  Data: TTETransitionData; CurrentFrame, Step: Longint; Draw: Boolean);

  function CalcRect(W, H, Frame: Integer;
    ForUpdateRect, ForUnUpdateRect: Boolean): TRect;
  var
    R, D: Integer;
    c1, c2, c3, c4: Integer;
  begin
    R := Data.Frames - Frame;

    c1 := W - R;
    c2 := H - R;
    c3 := W + R;
    c4 := H + R;

    Result := Rect(c1, c2, c3, c4);

    if ForUpdateRect then
      InflateRect(Result, Step, Step);

    if ForUnUpdateRect then
    begin
      D := 1 + R - Round(Sqrt(Sqr(R) div 2));
      InflateRect(Result, -D, -D);
    end;
  end;

begin
  Data.UpdateRect :=
    CalcRect(Data.Width, Data.Height, CurrentFrame - Step, True, False);
  Data.UnUpdateRect := CalcRect(Data.Width, Data.Height, CurrentFrame, False, True);
  if Draw then
    with CalcRect(Data.Width, Data.Height, CurrentFrame, False, False) do
      MaskBmp.Canvas.Ellipse(Left, Top, Right, Bottom);
end;

procedure TCircleTransition.Style2_7Frame(MaskBmp: TBitmap;
  Data: TTETransitionData; CurrentFrame, Step: Longint; Draw: Boolean);

  function CalcRect(H, Frame: Integer;
    ForUpdateRect, ForUnUpdateRect: Boolean): TRect;
  var
    R, D: Integer;
    c1, c2, c3, c4: Integer;
  begin
    R := Data.Frames - Frame;

    c1 := - R;
    c2 := H - R;
    c3 := R;
    c4 := H + R;

    Result := Rect(c1, c2, c3, c4);

    if ForUpdateRect then
      InflateRect(Result, Step, Step);

    if ForUnUpdateRect then
    begin
      D := 1 + R - Round(Sqrt(Sqr(R) div 2));
      InflateRect(Result, -D, -D);
    end;
  end;

begin
  Data.UpdateRect :=
    CalcRect(Data.Height, CurrentFrame - Step, True, False);
  Data.UnUpdateRect := CalcRect(Data.Height, CurrentFrame, False, True);
  if Draw then
    with CalcRect(Data.Height, CurrentFrame, False, False) do
      MaskBmp.Canvas.Ellipse(Left, Top, Right, Bottom);
end;

procedure TCircleTransition.Style2_8Frame(MaskBmp: TBitmap;
  Data: TTETransitionData; CurrentFrame, Step: Longint; Draw: Boolean);

  function CalcRect(W, Frame: Integer;
    ForUpdateRect, ForUnUpdateRect: Boolean): TRect;
  var
    R, D: Integer;
    c1, c2, c3, c4: Integer;
  begin
    R := Data.Frames - Frame;

    c1 := W - R;
    c2 := - R;
    c3 := W + R;
    c4 := R;

    Result := Rect(c1, c2, c3, c4);

    if ForUpdateRect then
      InflateRect(Result, Step, Step);

    if ForUnUpdateRect then
    begin
      D := 1 + R - Round(Sqrt(Sqr(R) div 2));
      InflateRect(Result, -D, -D);
    end;
  end;

begin
  Data.UpdateRect :=
    CalcRect(Data.Width, CurrentFrame - Step, True, False);
  Data.UnUpdateRect := CalcRect(Data.Width, CurrentFrame, False, True);
  if Draw then
    with CalcRect(Data.Width, CurrentFrame, False, False) do
      MaskBmp.Canvas.Ellipse(Left, Top, Right, Bottom);
end;

procedure TCircleTransition.Style3_1Frame(MaskBmp: TBitmap;
  Data: TTETransitionData; CurrentFrame, Step: Longint; Draw: Boolean);

  function CalcRect(H, Frame: Integer; ForUnUpdateRect: Boolean): TRect;
  var
    D: Integer;
    c1, c2, c3, c4: Integer;
  begin
    c1 := -Frame;
    c2 := (H div 2) - Frame;
    c3 := Frame;
    c4 := (H div 2) + Frame;

    Result := Rect(c1, c2, c3, c4);

    if ForUnUpdateRect then
    begin
      D := -(Frame - Round(Sqrt(Sqr(Frame) div 2)));
      InflateRect(Result, D-1, D-1);
    end;
  end;

begin
  Data.UpdateRect := CalcRect(Data.Height, CurrentFrame, False);
  if Draw then
    MaskBmp.Canvas.Ellipse(Data.UpdateRect.Left, Data.UpdateRect.Top,
      Data.UpdateRect.Right, Data.UpdateRect.Bottom);
  Data.UnUpdateRect := CalcRect(Data.Height, CurrentFrame - Step, True);
end;

procedure TCircleTransition.Style3_2Frame(MaskBmp: TBitmap;
  Data: TTETransitionData; CurrentFrame, Step: Longint; Draw: Boolean);

  function CalcRect(W, H, Frame: Integer; ForUnUpdateRect: Boolean): TRect;
  var
    D: Integer;
    c1, c2, c3, c4: Integer;
  begin
    c1 := W - Frame;
    c2 := (H div 2) - Frame;
    c3 := W + Frame;
    c4 := (H div 2) + Frame;

    Result := Rect(c1, c2, c3, c4);

    if ForUnUpdateRect then
    begin
      D := -(Frame - Round(Sqrt(Sqr(Frame) div 2)));
      InflateRect(Result, D-1, D-1);
    end;
  end;

begin
  Data.UpdateRect := CalcRect(Data.Width, Data.Height, CurrentFrame, False);
  if Draw then
    MaskBmp.Canvas.Ellipse(Data.UpdateRect.Left, Data.UpdateRect.Top,
      Data.UpdateRect.Right, Data.UpdateRect.Bottom);
  Data.UnUpdateRect := CalcRect(Data.Width, Data.Height, CurrentFrame - Step, True);
end;

procedure TCircleTransition.Style3_3Frame(MaskBmp: TBitmap;
  Data: TTETransitionData; CurrentFrame, Step: Longint; Draw: Boolean);

  function CalcRect(W, Frame: Integer; ForUnUpdateRect: Boolean): TRect;
  var
    D: Integer;
    c1, c2, c3, c4: Integer;
  begin
    c1 := (W div 2) - Frame;
    c2 := -Frame;
    c3 := (W div 2) + Frame;
    c4 := Frame;

    Result := Rect(c1, c2, c3, c4);

    if ForUnUpdateRect then
    begin
      D := -(Frame - Round(Sqrt(Sqr(Frame) div 2)));
      InflateRect(Result, D-1, D-1);
    end;
  end;

begin
  Data.UpdateRect := CalcRect(Data.Width, CurrentFrame, False);
  if Draw then
    MaskBmp.Canvas.Ellipse(Data.UpdateRect.Left, Data.UpdateRect.Top,
      Data.UpdateRect.Right, Data.UpdateRect.Bottom);
  Data.UnUpdateRect := CalcRect(Data.Width, CurrentFrame - Step, True);
end;

procedure TCircleTransition.Style3_4Frame(MaskBmp: TBitmap;
  Data: TTETransitionData; CurrentFrame, Step: Longint; Draw: Boolean);

  function CalcRect(W, H, Frame: Integer; ForUnUpdateRect: Boolean): TRect;
  var
    D: Integer;
    c1, c2, c3, c4: Integer;
  begin
    c1 := (W div 2) - Frame;
    c2 := H - Frame;
    c3 := (W div 2) + Frame;
    c4 := H + Frame;

    Result := Rect(c1, c2, c3, c4);

    if ForUnUpdateRect then
    begin
      D := -(Frame - Round(Sqrt(Sqr(Frame) div 2)));
      InflateRect(Result, D-1, D-1);
    end;
  end;

begin
  Data.UpdateRect := CalcRect(Data.Width, Data.Height, CurrentFrame, False);
  if Draw then
    MaskBmp.Canvas.Ellipse(Data.UpdateRect.Left, Data.UpdateRect.Top,
      Data.UpdateRect.Right, Data.UpdateRect.Bottom);
  Data.UnUpdateRect := CalcRect(Data.Width, Data.Height, CurrentFrame - Step, True);
end;

procedure TCircleTransition.Style3_5Frame(MaskBmp: TBitmap;
  Data: TTETransitionData; CurrentFrame, Step: Longint; Draw: Boolean);

  function CalcRect(H, Frame: Integer;
    ForUpdateRect, ForUnUpdateRect: Boolean): TRect;
  var
    R, D: Integer;
    c1, c2, c3, c4: Integer;
  begin
    R := Data.Frames - Frame;

    c1 := -R;
    c2 := (H div 2) - R;
    c3 := R;
    c4 := (H div 2) + R;

    Result := Rect(c1, c2, c3, c4);

    if ForUpdateRect then
      InflateRect(Result, Step, Step);

    if ForUnUpdateRect then
    begin
      D := 1 + R - Round(Sqrt(Sqr(R) div 2));
      InflateRect(Result, -D, -D);
    end;
  end;

begin
  Data.UpdateRect :=
    CalcRect(Data.Height, CurrentFrame - Step, True, False);
  Data.UnUpdateRect := CalcRect(Data.Height, CurrentFrame, False, True);
  if Draw then
    with CalcRect(Data.Height, CurrentFrame, False, False) do
      MaskBmp.Canvas.Ellipse(Left, Top, Right, Bottom);
end;

procedure TCircleTransition.Style3_6Frame(MaskBmp: TBitmap;
  Data: TTETransitionData; CurrentFrame, Step: Longint; Draw: Boolean);

  function CalcRect(W, H, Frame: Integer;
    ForUpdateRect, ForUnUpdateRect: Boolean): TRect;
  var
    R, D: Integer;
    c1, c2, c3, c4: Integer;
  begin
    R := Data.Frames - Frame;

    c1 := W - R;
    c2 := (H div 2) - R;
    c3 := W + R;
    c4 := (H div 2) + R;

    Result := Rect(c1, c2, c3, c4);

    if ForUpdateRect then
      InflateRect(Result, Step, Step);

    if ForUnUpdateRect then
    begin
      D := 1 + R - Round(Sqrt(Sqr(R) div 2));
      InflateRect(Result, -D, -D);
    end;
  end;

begin
  Data.UpdateRect :=
    CalcRect(Data.Width, Data.Height, CurrentFrame - Step, True, False);
  Data.UnUpdateRect := CalcRect(Data.Width, Data.Height, CurrentFrame, False, True);
  if Draw then
    with CalcRect(Data.Width, Data.Height, CurrentFrame, False, False) do
      MaskBmp.Canvas.Ellipse(Left, Top, Right, Bottom);
end;

procedure TCircleTransition.Style3_7Frame(MaskBmp: TBitmap;
  Data: TTETransitionData; CurrentFrame, Step: Longint; Draw: Boolean);

  function CalcRect(W, Frame: Integer;
    ForUpdateRect, ForUnUpdateRect: Boolean): TRect;
  var
    R, D: Integer;
    c1, c2, c3, c4: Integer;
  begin
    R := Data.Frames - Frame;

    c1 := (W div 2) - R;
    c2 := -R;
    c3 := (W div 2) + R;
    c4 := R;

    Result := Rect(c1, c2, c3, c4);

    if ForUpdateRect then
      InflateRect(Result, Step, Step);

    if ForUnUpdateRect then
    begin
      D := 1 + R - Round(Sqrt(Sqr(R) div 2));
      InflateRect(Result, -D, -D);
    end;
  end;

begin
  Data.UpdateRect :=
    CalcRect(Data.Width, CurrentFrame - Step, True, False);
  Data.UnUpdateRect := CalcRect(Data.Width, CurrentFrame, False, True);
  if Draw then
    with CalcRect(Data.Width, CurrentFrame, False, False) do
      MaskBmp.Canvas.Ellipse(Left, Top, Right, Bottom);
end;

procedure TCircleTransition.Style3_8Frame(MaskBmp: TBitmap;
  Data: TTETransitionData; CurrentFrame, Step: Longint; Draw: Boolean);

  function CalcRect(W, H, Frame: Integer;
    ForUpdateRect, ForUnUpdateRect: Boolean): TRect;
  var
    R, D: Integer;
    c1, c2, c3, c4: Integer;
  begin
    R := Data.Frames - Frame;

    c1 := (W div 2) - R;
    c2 := H - R;
    c3 := (W div 2) + R;
    c4 := H + R;

    Result := Rect(c1, c2, c3, c4);

    if ForUpdateRect then
      InflateRect(Result, Step, Step);

    if ForUnUpdateRect then
    begin
      D := 1 + R - Round(Sqrt(Sqr(R) div 2));
      InflateRect(Result, -D, -D);
    end;
  end;

begin
  Data.UpdateRect :=
    CalcRect(Data.Width, Data.Height, CurrentFrame - Step, True, False);
  Data.UnUpdateRect := CalcRect(Data.Width, Data.Height, CurrentFrame, False, True);
  if Draw then
    with CalcRect(Data.Width, Data.Height, CurrentFrame, False, False) do
      MaskBmp.Canvas.Ellipse(Left, Top, Right, Bottom);
end;

initialization

  TERegisterTransition(TCircleTransition);

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?