⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmainu.pas

📁 简单的画图软件
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    Width:= 14;
    Left:=  43;
  end;

  With   shpType3 do
  begin
    Show;
    Pen.Color:=   clBlack;
    Brush.Color:= clWhite;
    Brush.Style:= bsSolid;
    Shape:= stSquare;
    Width:= 25;
    Left:=  70;
  end;

  With   shpType4 do
  begin
    Show;
    Pen.Color:=   clBlack;
    Brush.Color:= clWhite;
    Brush.Style:= bsSolid;
    Shape:= stSquare;
    Width:= 33;
    Left:=  110;
  end;

  MoveTypeLabel;

  TShape(FindComponent('shpType'  + IntToStr(EraserTypeIndex))).Pen.Color:=   clRed;

  PenWidth:=   EraserTypeIndex   *  5  -  3;

end;

//*****************************************************

procedure TfrmMain.BrosTypeShow(BrosTypeIndex:  Integer);
begin
   With  shpType1  do
   begin
      Show;
      Pen.Color:= clBlack;
      Brush.Style:=  bsSolid;
      Brush.Color:=  clBlack;
      Shape:=  stCircle;
      Height:= 7;
      Left:=   15;
      Top:= 22;
   end;

   With  shpType2  do
   begin
      Show;
      Pen.Color:= clBlack;
      Brush.Style:=  bsSolid;
      Brush.Color:=  clBlack;
      Shape:=  stCircle;
      Height:= 15;
      Left:=   37;
      Top:= 18;
   end;

   With  shpType3  do
   begin
      Show;
      Pen.Color:= clBlack;
      Brush.Style:=  bsSolid;
      Brush.Color:=  clBlack;
      Shape:=  stCircle;
      Height:= 25;
      Left:=   67;
      Top:= 13;
   end;

   With  shpType4  do
   begin
      Show;
      Pen.Color:= clBlack;
      Brush.Style:=  bsSolid;
      Brush.Color:=  clBlack;
      Shape:=  stCircle;
      Height:= 35;
      Left:=   110;
      Top:= 8;
   end;

   MoveTypeLabel;

   with  TShape(FindComponent('shpType'  + IntToStr(BrosTypeIndex))) do
   begin
      Brush.Color:=  clRed;
      Pen.Color:= clRed;
   end;

   PenWidth:=  BrosTypeIndex  *  9  -  2;

end;

//**************************************************

procedure TfrmMain.ColorMixerWorking(X, Y: Integer; Button: TMouseButton);
var
   PointColor, Color4Change: TColor;
//##################################################
   procedure   ColorMixer( TempPoint:   TPoint);
   var
      X, Y: Integer;

      function   ClPointCheck(X, Y: Integer): Boolean;
      var
         PixelColor: TColor;
      begin
         PixelColor:=   lblWhiteBord.Canvas.Pixels[X, Y];
         if  PixelColor =  PointColor then
         begin
            Result:= True;
         end
         else
            Result:= False;
      end;
//##############################################
   begin
      X:=   TempPoint.X;
      Y:=   TempPoint.Y;

      if ClPointCheck(X,   Y)then
      begin
         lblWhiteBord.Canvas.Pixels[X, Y]:=  Color4Change;
      end;

      if ClPointCheck(X +  1, Y)   then
      begin
         ColorMixer(Point(X +  1,   Y));
      end;

      if ClPointCheck(X -  1, Y)   then
      begin
         ColorMixer(Point(X -  1,   Y));
      end;

      if ClPointCheck(X,   Y   +  1)   then
      begin
         ColorMixer(Point(X,   Y  +1));
      end;

      if ClPointCheck(X,   Y  -  1)   then
      begin
         ColorMixer(Point(X,   Y  -  1));
      end;
   end;
//################################################
begin
   With  lblWhiteBord.Canvas  do
   begin
      Pen.Width:= 1;
      Case  Button   of
         mbLeft:  Color4Change:= pnlClL.Color;
         mbRight: Color4Change:= pnlClR.Color;
      end;

      PointColor:=   Pixels[X,   Y];
   end;
   if PointColor  <> Color4Change   then
   begin
      ColorMixer(Point(X,  Y));
   end;

end;

//*************************************************

procedure TfrmMain.SpTypeShow(SpTypeIndex: Integer);
var
   RandomX, RandomY, I: Integer;
begin
   Randomize;

   shpType1.Hide;
   shpType2.Hide;
   shpType3.Hide;
   shpType4.Hide;

   with  lblType1 do
   begin
      Left:=   15;
      Top:= 21;
      Repaint;

      for   I:=   1  to 30   do
      begin
         CircleRandomInt(RandomX,   RandomY, 5);
         if SpTypeIndex =  1  then
         begin
            Canvas.Pixels[RandomX,  RandomY]:=  clRed;
            PenWidth:=  5;
            LoopCount:= 30;
         end
         else
         begin
            Canvas.Pixels[RandomX,  RandomY]:=  clBlack;
         end;
      end;
   end;

   with  lblType2 do
   begin
      Left:=   44;
      Top:= 17;
      Repaint;

      for   I:=   1  to 60   do
      begin
         CircleRandomInt(RandomX,   RandomY, 8);
         if SpTypeIndex =  2  then
         begin
            Canvas.Pixels[RandomX,  RandomY]:=  clRed;
            PenWidth:=  8;
            LoopCount:= 60;
         end
         else
         begin
            Canvas.Pixels[RandomX,  RandomY]:=  clBlack;
         end;
      end;
   end;

   with  lblType3 do
   begin
      Left:=   80;
      Top:= 13;
      Repaint;

      for   I:=   1  to 110   do
      begin
         CircleRandomInt(RandomX,   RandomY, 12);
         if SpTypeIndex =  3  then
         begin
            Canvas.Pixels[RandomX,  RandomY]:=  clRed;
            PenWidth:=  12;
            LoopCount:= 110;
         end
         else
         begin
            Canvas.Pixels[RandomX,  RandomY]:=  clBlack;
         end;
      end;
   end;

   with  lblType4 do
   begin
      Left:=   118;
      Top:= 9;
      Repaint;

      for   I:=   1  to 200   do
      begin
         CircleRandomInt(RandomX,   RandomY, 15);
         if SpTypeIndex =  4  then
         begin
            Canvas.Pixels[RandomX,  RandomY]:=  clRed;
            PenWidth:=  15;
            LoopCount:= 200;
         end
         else
         begin
            Canvas.Pixels[RandomX,  RandomY]:=  clBlack;
         end;
      end;
   end;

end;

//***************************************************

procedure TfrmMain.MoveTypeLabel;
var
   I: 1..4;
begin
   for   I:=   1  to 4  do
   begin
      TLabel(FindComponent('lblType'   +  IntToStr(I))).Height:= TShape(FindComponent('shpType'   +  IntToStr(I))).Height;
      TLabel(FindComponent('lblType'   +  IntToStr(I))).Width:=  TShape(FindComponent('shpType'   +  IntToStr(I))).Width;
      TLabel(FindComponent('lblType'   +  IntToStr(I))).Left:=   TShape(FindComponent('shpType'   +  IntToStr(I))).Left;
      TLabel(FindComponent('lblType'   +  IntToStr(I))).Top:= TShape(FindComponent('shpType'   +  IntToStr(I))).Top;
   end;

end;

//**************************************************

procedure TfrmMain.Label1Click(Sender: TObject);
var
   TypeIndex: Integer;
begin
   TypeIndex:= StrToInt(RightStr(TLabel(Sender).Name, 1));

   if WhoIsDown   =  'tbtnEraser'   then
   begin
      EraserTypeShow(TypeIndex);
   end;

   if WhoIsDown   =  'tbtnBros'  then
   begin
      BrosTypeShow(TypeIndex);
   end;

   if WhoIsDown   =  'tbtnSp' then
   begin
      SpTypeShow(TypeIndex);
   end;

end;

//*************************************************

procedure TfrmMain.CircleRandomInt(Var X, Y: Integer; r: Integer);

      function DisCalculate(X, Y, r: Integer):   Real;
      begin
         Result:= Sqrt(Sqr(X  -  r)   +  Sqr(Y -  r));

      end;
//########################################################
begin
   repeat
      X:=   Random(2 *  r);
      Y:=   Random(2 *  r);
   Until DisCalculate(X,   Y, r) <  r;

end;

procedure TfrmMain.pnlTempCl2DblClick(Sender: TObject);
begin
   if ColorDialog.Execute  then
   begin
      TPanel(Sender).Color:=  ColorDialog.Color;
   end;
   
end;

end.

⌨️ 快捷键说明

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