소스 검색

finish script tool attributes

johann 5 년 전
부모
커밋
e638488eb4
4개의 변경된 파일446개의 추가작업 그리고 36개의 파일을 삭제
  1. 25 24
      lazpaint/maintoolbar.inc
  2. 332 10
      lazpaint/tools/utool.pas
  3. 1 1
      lazpaint/tools/utooldeformationgrid.pas
  4. 88 1
      scripts/lazpaint/tools.py

+ 25 - 24
lazpaint/maintoolbar.inc

@@ -101,21 +101,21 @@ begin
   SpinEdit_Tolerance.OnChange := @SpinEdit_ToleranceChange;
 
   SpinEdit_PenWidth.MinValue := 1;
-  SpinEdit_PenWidth.MaxValue := round(MaxPenWidth*10);
+  SpinEdit_PenWidth.MaxValue := round(MaxPenWidth*PenWidthFactor);
   SpinEdit_PenWidth.Increment := 10;
   SpinEdit_PenWidth.OnChange := @SpinEdit_PenWidthChange;
   SpinEdit_PenWidth.OnMouseMove := @SpinEdit_PenWidthMouseMove;
   SpinEdit_PenWidth.OnExit:= @SpinEdit_PenWidthExit;
   SpinEdit_PenWidth.BarExponent := 3;
 
-  SpinEdit_ArrowSizeX.MinValue := 10;
-  SpinEdit_ArrowSizeX.MaxValue := 99;
+  SpinEdit_ArrowSizeX.MinValue := round(MinArrowSize*PenWidthFactor);
+  SpinEdit_ArrowSizeX.MaxValue := round(MaxArrowSize*PenWidthFactor);
   SpinEdit_ArrowSizeX.Value := 20;
   SpinEdit_ArrowSizeX.Increment := 5;
   SpinEdit_ArrowSizeX.OnChange := @SpinEdit_ArrowSizeChange;
 
-  SpinEdit_ArrowSizeY.MinValue := 10;
-  SpinEdit_ArrowSizeY.MaxValue := 99;
+  SpinEdit_ArrowSizeY.MinValue := round(MinArrowSize*PenWidthFactor);
+  SpinEdit_ArrowSizeY.MaxValue := round(MaxArrowSize*PenWidthFactor);
   SpinEdit_ArrowSizeY.Value := 20;
   SpinEdit_ArrowSizeY.Increment := 5;
   SpinEdit_ArrowSizeY.OnChange := @SpinEdit_ArrowSizeChange;
@@ -154,28 +154,28 @@ begin
   SpinEdit_TextBlur.BarExponent:= 3;
   SpinEdit_TextBlur.OnChange := @SpinEdit_TextBlurChange;
 
-  SpinEdit_GridNbX.MinValue := 1;
+  SpinEdit_GridNbX.MinValue := MinDeformationGridSize-1;
   SpinEdit_GridNbX.MaxValue := 100;
   SpinEdit_GridNbX.Value := 10;
   SpinEdit_GridNbX.Increment := 1;
   SpinEdit_GridNbX.OnChange := @GridNb_SpinEditChange;
   SpinEdit_GridNbX.OnExit := @SpinEdit_GridNbExit;
 
-  SpinEdit_GridNbY.MinValue := 1;
+  SpinEdit_GridNbY.MinValue := MinDeformationGridSize-1;
   SpinEdit_GridNbY.MaxValue := 100;
   SpinEdit_GridNbY.Value := 10;
   SpinEdit_GridNbY.Increment := 1;
   SpinEdit_GridNbY.OnChange := @GridNb_SpinEditChange;
   SpinEdit_GridNbY.OnExit := @SpinEdit_GridNbExit;
 
-  SpinEdit_PhongBorderSize.MinValue := 1;
-  SpinEdit_PhongBorderSize.MaxValue := 100;
+  SpinEdit_PhongBorderSize.MinValue := MinPhongBorderSize;
+  SpinEdit_PhongBorderSize.MaxValue := MaxPhongBorderSize;
   SpinEdit_PhongBorderSize.Value := 10;
   SpinEdit_PhongBorderSize.Increment := 3;
   SpinEdit_PhongBorderSize.OnChange := @SpinEdit_PhongBorderSizeChange;
 
-  SpinEdit_ShapeAltitude.MinValue := 1;
-  SpinEdit_ShapeAltitude.MaxValue := 100;
+  SpinEdit_ShapeAltitude.MinValue := MinPhongShapeAltitude;
+  SpinEdit_ShapeAltitude.MaxValue := MaxPhongShapeAltitude;
   SpinEdit_ShapeAltitude.Value := 10;
   SpinEdit_ShapeAltitude.Increment := 1;
   SpinEdit_ShapeAltitude.BarExponent:= 3;
@@ -362,7 +362,7 @@ begin
   if FInGridNb then exit;
   SpinEdit_GridNbX.Value := ToolManager.DeformationGridNbX-1;
   SpinEdit_GridNbY.Value := ToolManager.DeformationGridNbY-1;
-  Tool_GridMoveWithoutDeformation.Down := ToolManager.DeformationGridMoveWithoutDeformation;
+  Tool_GridMoveWithoutDeformation.Down := (ToolManager.DeformationGridMode = gmMovePointWithoutDeformation);
 end;
 
 procedure TFMain.UpdateFloodfillToolbar;
@@ -537,14 +537,11 @@ begin
 end;
 
 procedure TFMain.UpdateToolbar;
-var maxGridNbX,maxGridNbY: integer;
+var maxGridNb: TSize;
 begin
-  maxGridNbX := Max(2,Min(image.Width div 2,50));
-  maxGridNbY := Max(2,Min(image.Height div 2,50));
-  if SpinEdit_GridNbX.MaxValue <> maxGridNbX then
-    SpinEdit_GridNbX.MaxValue := maxGridNbX;
-  if SpinEdit_GridNbY.MaxValue <> maxGridNbY then
-    SpinEdit_GridNbY.MaxValue := maxGridNbY;
+  maxGridNb := ToolManager.MaxDeformationGridSize;
+  SpinEdit_GridNbX.MaxValue := maxGridNb.cx-1;
+  SpinEdit_GridNbY.MaxValue := maxGridNb.cy-1;
 
   UpdateCurveModeToolbar;
 end;
@@ -735,8 +732,8 @@ end;
 
 procedure TFMain.SpinEdit_GridNbExit(Sender: TObject);
 begin
-  if SpinEdit_GridNbX.Value < 2 then SpinEdit_GridNbX.Value := 2;
-  if SpinEdit_GridNbY.Value < 2 then SpinEdit_GridNbY.Value := 2;
+  if SpinEdit_GridNbX.Value < MinDeformationGridSize-1 then SpinEdit_GridNbX.Value := MinDeformationGridSize-1;
+  if SpinEdit_GridNbY.Value < MinDeformationGridSize-1 then SpinEdit_GridNbY.Value := MinDeformationGridSize-1;
 end;
 
 procedure TFMain.ViewWorkspaceColorExecute(Sender: TObject);
@@ -1152,9 +1149,13 @@ end;
 
 procedure TFMain.Tool_GridMoveWithoutDeformationClick(Sender: TObject);
 begin
-    if initialized then
-      ToolManager.DeformationGridMoveWithoutDeformation :=
-        Tool_GridMoveWithoutDeformation.Down;
+  if initialized then
+  begin
+    if Tool_GridMoveWithoutDeformation.Down then
+      ToolManager.DeformationGridMode := gmMovePointWithoutDeformation
+    else
+      ToolManager.DeformationGridMode := gmDeform;
+  end;
 end;
 
 procedure TFMain.SetCurveMode(AMode: TToolSplineMode);

+ 332 - 10
lazpaint/tools/utool.pas

@@ -48,10 +48,19 @@ type
     tcAlignLeft, tcCenterHorizontally, tcAlignRight, tcAlignTop, tcCenterVertically, tcAlignBottom,
     tcShapeToSpline);
 
+  TDeformationGridMode = (gmDeform, gmMovePointWithoutDeformation);
+
 const
   MaxPenWidth = 999.9;
   MinPenWidth = 1;
+  MaxArrowSize = 9.9;
+  MinArrowSize = 1;
   MaxBrushSpacing = 99;
+  MinPhongShapeAltitude = 1;
+  MaxPhongShapeAltitude = 100;
+  MinPhongBorderSize = 1;
+  MaxPhongBorderSize = 100;
+  MinDeformationGridSize = 3;
 
 function GradientColorSpaceToDisplay(AValue: TBGRAColorInterpolation): string;
 function DisplayToGradientColorSpace(AValue: string): TBGRAColorInterpolation;
@@ -201,7 +210,7 @@ type
     FPhongShapeBorderSize: integer;
     FPhongShapeKind: TPhongShapeKind;
     FDeformationGridNbX,FDeformationGridNbY: integer;
-    FDeformationGridMoveWithoutDeformation: boolean;
+    FDeformationGridMode: TDeformationGridMode;
     FTolerance: byte;
     FFloodFillOptions: TFloodFillOptions;
     FPerspectiveOptions: TPerspectiveOptions;
@@ -234,6 +243,7 @@ type
     function GetBrushCount: integer;
     function GetBrushInfo: TLazPaintBrush;
     function GetForeColor: TBGRAPixel;
+    function GetMaxDeformationGridSize: TSize;
     function GetShapeOptionAliasing: boolean;
     function GetShapeOptionDraw: boolean;
     function GetShapeOptionFill: boolean;
@@ -251,19 +261,30 @@ type
     function ScriptGetBrushCount(AVars: TVariableSet): TScriptResult;
     function ScriptGetBrushIndex(AVars: TVariableSet): TScriptResult;
     function ScriptGetBrushSpacing(AVars: TVariableSet): TScriptResult;
+    function ScriptGetDeformationGridMode(AVars: TVariableSet): TScriptResult;
+    function ScriptGetDeformationGridSize(AVars: TVariableSet): TScriptResult;
     function ScriptGetEraserAlpha(AVars: TVariableSet): TScriptResult;
     function ScriptGetEraserMode(AVars: TVariableSet): TScriptResult;
+    function ScriptGetFloodFillOptions(AVars: TVariableSet): TScriptResult;
     function ScriptGetFontName(AVars: TVariableSet): TScriptResult;
     function ScriptGetFontSize(AVars: TVariableSet): TScriptResult;
     function ScriptGetFontStyle(AVars: TVariableSet): TScriptResult;
+    function ScriptGetGradientColorspace(AVars: TVariableSet): TScriptResult;
+    function ScriptGetGradientSine(AVars: TVariableSet): TScriptResult;
+    function ScriptGetGradientType(AVars: TVariableSet): TScriptResult;
     function ScriptGetJoinStyle(AVars: TVariableSet): TScriptResult;
     function ScriptGetLightPosition(AVars: TVariableSet): TScriptResult;
     function ScriptGetLineCap(AVars: TVariableSet): TScriptResult;
     function ScriptGetPenColor(AVars: TVariableSet): TScriptResult;
     function ScriptGetPenStyle(AVars: TVariableSet): TScriptResult;
     function ScriptGetPenWidth(AVars: TVariableSet): TScriptResult;
+    function ScriptGetPerspectiveOptions(AVars: TVariableSet): TScriptResult;
+    function ScriptGetPhongShapeAltitude(AVars: TVariableSet): TScriptResult;
+    function ScriptGetPhongShapeBorderSize(AVars: TVariableSet): TScriptResult;
+    function ScriptGetPhongShapeKind(AVars: TVariableSet): TScriptResult;
     function ScriptGetShapeOptions(AVars: TVariableSet): TScriptResult;
     function ScriptGetShapeRatio(AVars: TVariableSet): TScriptResult;
+    function ScriptGetSplineStyle(AVars: TVariableSet): TScriptResult;
     function ScriptGetTextAlign(AVars: TVariableSet): TScriptResult;
     function ScriptGetTextOutline(AVars: TVariableSet): TScriptResult;
     function ScriptGetTextPhong(AVars: TVariableSet): TScriptResult;
@@ -275,19 +296,30 @@ type
     function ScriptSetBackColor(AVars: TVariableSet): TScriptResult;
     function ScriptSetBrushIndex(AVars: TVariableSet): TScriptResult;
     function ScriptSetBrushSpacing(AVars: TVariableSet): TScriptResult;
+    function ScriptSetDeformationGridMode(AVars: TVariableSet): TScriptResult;
+    function ScriptSetDeformationGridSize(AVars: TVariableSet): TScriptResult;
     function ScriptSetEraserAlpha(AVars: TVariableSet): TScriptResult;
     function ScriptSetEraserMode(AVars: TVariableSet): TScriptResult;
+    function ScriptSetFloodFillOptions(AVars: TVariableSet): TScriptResult;
     function ScriptSetFontName(AVars: TVariableSet): TScriptResult;
     function ScriptSetFontSize(AVars: TVariableSet): TScriptResult;
     function ScriptSetFontStyle(AVars: TVariableSet): TScriptResult;
+    function ScriptSetGradientColorspace(AVars: TVariableSet): TScriptResult;
+    function ScriptSetGradientSine(AVars: TVariableSet): TScriptResult;
+    function ScriptSetGradientType(AVars: TVariableSet): TScriptResult;
     function ScriptSetJoinStyle(AVars: TVariableSet): TScriptResult;
     function ScriptSetLightPosition(AVars: TVariableSet): TScriptResult;
     function ScriptSetLineCap(AVars: TVariableSet): TScriptResult;
     function ScriptSetPenColor(AVars: TVariableSet): TScriptResult;
     function ScriptSetPenStyle(AVars: TVariableSet): TScriptResult;
     function ScriptSetPenWidth(AVars: TVariableSet): TScriptResult;
+    function ScriptSetPerspectiveOptions(AVars: TVariableSet): TScriptResult;
+    function ScriptSetPhongShapeAltitude(AVars: TVariableSet): TScriptResult;
+    function ScriptSetPhongShapeBorderSize(AVars: TVariableSet): TScriptResult;
+    function ScriptSetPhongShapeKind(AVars: TVariableSet): TScriptResult;
     function ScriptSetShapeOptions(AVars: TVariableSet): TScriptResult;
     function ScriptSetShapeRatio(AVars: TVariableSet): TScriptResult;
+    function ScriptSetSplineStyle(AVars: TVariableSet): TScriptResult;
     function ScriptSetTextAlign(AVars: TVariableSet): TScriptResult;
     function ScriptSetTextOutline(AVars: TVariableSet): TScriptResult;
     function ScriptSetTextPhong(AVars: TVariableSet): TScriptResult;
@@ -299,7 +331,7 @@ type
     procedure SetArrowSize(AValue: TPointF);
     procedure SetArrowStart(AValue: TArrowKind);
     procedure SetBackColor(AValue: TBGRAPixel);
-    procedure SetDeformationGridMoveWithoutDeformation(AValue: boolean);
+    procedure SetDeformationGridMode(AValue: TDeformationGridMode);
     procedure SetEraserAlpha(AValue: byte);
     procedure SetEraserMode(AValue: TEraserMode);
     procedure SetFloodFillOptions(AValue: TFloodFillOptions);
@@ -455,7 +487,8 @@ type
     property DeformationGridNbX: integer read FDeformationGridNbX;
     property DeformationGridNbY: integer read FDeformationGridNbY;
     property DeformationGridSize: TSize read GetDeformationGridSize write SetDeformationGridSize;
-    property DeformationGridMoveWithoutDeformation: boolean read FDeformationGridMoveWithoutDeformation write SetDeformationGridMoveWithoutDeformation;
+    property MaxDeformationGridSize: TSize read GetMaxDeformationGridSize;
+    property DeformationGridMode: TDeformationGridMode read FDeformationGridMode write SetDeformationGridMode;
     property Tolerance: byte read FTolerance write SetTolerance;
     property FloodFillOptions: TFloodFillOptions read FFloodFillOptions write SetFloodFillOptions;
     property PerspectiveOptions: TPerspectiveOptions read FPerspectiveOptions write SetPerspectiveOptions;
@@ -495,7 +528,7 @@ function ToolPopupMessageToStr(AMessage :TToolPopupMessage; AKey: Word = 0): str
 implementation
 
 uses UGraph, LCScaleDPI, LazPaintType, UCursors, BGRATextFX, ULoading, UResourceStrings,
-  BGRATransform, LCVectorOriginal, BGRAGradientOriginal, BGRASVGOriginal;
+  BGRATransform, LCVectorOriginal, BGRAGradientOriginal, BGRASVGOriginal, math;
 
 function StrToPaintToolType(const s: ansistring): TPaintToolType;
 var pt: TPaintToolType;
@@ -974,6 +1007,10 @@ end;
 
 procedure TToolManager.SetArrowSize(AValue: TPointF);
 begin
+  if AValue.x < MinArrowSize then AValue.x := MinArrowSize;
+  if AValue.x > MaxArrowSize then AValue.x := MaxArrowSize;
+  if AValue.y < MinArrowSize then AValue.y := MinArrowSize;
+  if AValue.y > MaxArrowSize then AValue.y := MaxArrowSize;
   if FArrowSize=AValue then Exit;
   FArrowSize:=AValue;
   ToolUpdate;
@@ -999,10 +1036,10 @@ begin
   if Assigned(FOnColorChanged) then FOnColorChanged(self);
 end;
 
-procedure TToolManager.SetDeformationGridMoveWithoutDeformation(AValue: boolean);
+procedure TToolManager.SetDeformationGridMode(AValue: TDeformationGridMode);
 begin
-  if FDeformationGridMoveWithoutDeformation=AValue then Exit;
-  FDeformationGridMoveWithoutDeformation:=AValue;
+  if FDeformationGridMode=AValue then Exit;
+  FDeformationGridMode:=AValue;
   ToolUpdate;
   if Assigned(FOnDeformationGridChanged) then FOnDeformationGridChanged(self);
 end;
@@ -1108,6 +1145,8 @@ end;
 
 procedure TToolManager.SetPhongShapeAltitude(AValue: integer);
 begin
+  if AValue < MinPhongShapeAltitude then AValue := MinPhongShapeAltitude;
+  if AValue > MaxPhongShapeAltitude then AValue := MaxPhongShapeAltitude;
   if FPhongShapeAltitude=AValue then Exit;
   FPhongShapeAltitude:=AValue;
   ToolUpdate;
@@ -1116,6 +1155,8 @@ end;
 
 procedure TToolManager.SetPhongShapeBorderSize(AValue: integer);
 begin
+  if AValue < MinPhongBorderSize then AValue := MinPhongBorderSize;
+  if AValue > MaxPhongBorderSize then AValue := MaxPhongBorderSize;
   if FPhongShapeBorderSize=AValue then Exit;
   FPhongShapeBorderSize:=AValue;
   ToolUpdate;
@@ -1343,6 +1384,12 @@ begin
     result := FForeColor;
 end;
 
+function TToolManager.GetMaxDeformationGridSize: TSize;
+begin
+  result.cx := Max(MinDeformationGridSize,Min(image.Width div 2,50)+1);
+  result.cy := Max(MinDeformationGridSize,Min(image.Height div 2,50)+1);
+end;
+
 function TToolManager.GetShapeOptionAliasing: boolean;
 begin
   result := toAliasing in FShapeOptions;
@@ -1437,6 +1484,23 @@ begin
   result := srOk;
 end;
 
+function TToolManager.ScriptGetDeformationGridMode(AVars: TVariableSet): TScriptResult;
+begin
+  result := srOk;
+  case DeformationGridMode of
+  gmDeform: AVars.Strings['Result'] := 'Deform';
+  gmMovePointWithoutDeformation: AVars.Strings['Result'] := 'MovePointWithoutDeformation';
+  else result := srException;
+  end;
+end;
+
+function TToolManager.ScriptGetDeformationGridSize(AVars: TVariableSet): TScriptResult;
+begin
+  result := srOk;
+  with DeformationGridSize do
+    AVars.Points2D['Result'] := PointF(cx,cy);
+end;
+
 function TToolManager.ScriptGetEraserAlpha(AVars: TVariableSet): TScriptResult;
 begin
   AVars.Integers['Result'] := EraserAlpha;
@@ -1453,6 +1517,21 @@ begin
   end;
 end;
 
+function TToolManager.ScriptGetFloodFillOptions(AVars: TVariableSet): TScriptResult;
+var
+  optionsVar: TScriptVariableReference;
+  option: TFloodFillOption;
+begin
+  optionsVar := AVars.AddStringList('Result');
+  for option := low(TFloodFillOption) to high(TFloodFillOption) do
+    if option in FloodFillOptions then
+    case option of
+    ffProgressive: AVars.AppendString(optionsVar, 'Progressive');
+    ffFillAll: Avars.AppendString(optionsVar, 'FillAll');
+    end;
+  result := srOk;
+end;
+
 function TToolManager.ScriptGetFontName(AVars: TVariableSet): TScriptResult;
 begin
   AVars.Strings['Name'] := TextFontName;
@@ -1482,6 +1561,39 @@ begin
   result := srOk;
 end;
 
+function TToolManager.ScriptGetGradientColorspace(AVars: TVariableSet): TScriptResult;
+begin
+  result := srOk;
+  case GradientColorspace of
+  ciStdRGB: AVars.Strings['Result'] := 'StdRGB';
+  ciLinearRGB: AVars.Strings['Result'] := 'LinearRGB';
+  ciLinearHSLPositive: AVars.Strings['Result'] := 'LinearHSLPositive';
+  ciLinearHSLNegative: AVars.Strings['Result'] := 'LinearHSLNegative';
+  ciGSBPositive: AVars.Strings['Result'] := 'GSBPositive';
+  ciGSBNegative: AVars.Strings['Result'] := 'GSBNegative';
+  else result := srException;
+  end;
+end;
+
+function TToolManager.ScriptGetGradientSine(AVars: TVariableSet): TScriptResult;
+begin
+  result := srOk;
+  AVars.Booleans['Result'] := GradientSine;
+end;
+
+function TToolManager.ScriptGetGradientType(AVars: TVariableSet): TScriptResult;
+begin
+  result := srOk;
+  case GradientType of
+  gtLinear: AVars.Strings['Result'] := 'Linear';
+  gtReflected: AVars.Strings['Result'] := 'Reflected';
+  gtDiamond: AVars.Strings['Result'] := 'Diamond';
+  gtRadial: AVars.Strings['Result'] := 'Radial';
+  gtAngular: AVars.Strings['Result'] := 'Angular';
+  else result := srException;
+  end;
+end;
+
 function TToolManager.ScriptGetJoinStyle(AVars: TVariableSet): TScriptResult;
 begin
   result := srOk;
@@ -1535,6 +1647,48 @@ begin
   result := srOk;
 end;
 
+function TToolManager.ScriptGetPerspectiveOptions(AVars: TVariableSet): TScriptResult;
+var
+  optionsVar: TScriptVariableReference;
+  option: TPerspectiveOption;
+begin
+  optionsVar := AVars.AddStringList('Result');
+  for option := low(TPerspectiveOption) to high(TPerspectiveOption) do
+    if option in PerspectiveOptions then
+    case option of
+    poRepeat: AVars.AppendString(optionsVar, 'Repeat');
+    poTwoPlanes: Avars.AppendString(optionsVar, 'TwoPlanes');
+    end;
+  result := srOk;
+end;
+
+function TToolManager.ScriptGetPhongShapeAltitude(AVars: TVariableSet): TScriptResult;
+begin
+  result := srOk;
+  AVars.Integers['Result'] := PhongShapeAltitude;
+end;
+
+function TToolManager.ScriptGetPhongShapeBorderSize(AVars: TVariableSet): TScriptResult;
+begin
+  result := srOk;
+  AVars.Integers['Result'] := PhongShapeBorderSize;
+end;
+
+function TToolManager.ScriptGetPhongShapeKind(AVars: TVariableSet): TScriptResult;
+begin
+  result := srOk;
+  case PhongShapeKind of
+  pskRectangle: AVars.Strings['Result'] := 'Rectangle';
+  pskRoundRectangle: AVars.Strings['Result'] := 'RoundRectangle';
+  pskHalfSphere: AVars.Strings['Result'] := 'HalfSphere';
+  pskConeTop: AVars.Strings['Result'] := 'ConeTop';
+  pskConeSide: AVars.Strings['Result'] := 'ConeSide';
+  pskHorizCylinder: AVars.Strings['Result'] := 'HorizCylinder';
+  pskVertCylinder: AVars.Strings['Result'] := 'VertCylinder';
+  else result := srException;
+  end;
+end;
+
 function TToolManager.ScriptGetShapeOptions(AVars: TVariableSet): TScriptResult;
 var
   options: TScriptVariableReference;
@@ -1557,6 +1711,26 @@ begin
   result := srOk;
 end;
 
+function TToolManager.ScriptGetSplineStyle(AVars: TVariableSet): TScriptResult;
+var
+  s: String;
+begin
+  case SplineStyle of
+    ssInside: s := 'Inside';
+    ssInsideWithEnds: s := 'InsideWithEnds';
+    ssCrossing: s := 'Crossing';
+    ssCrossingWithEnds: s := 'CrossingWithEnds';
+    ssOutside: s := 'Outside';
+    ssRoundOutside: s := 'RoundOutside';
+    ssVertexToSide: s := 'VertexToSide';
+    ssEasyBezier: s := 'EasyBezier';
+  else
+    exit(srException);
+  end;
+  AVars.Strings['Result'] := s;
+  result := srOk;
+end;
+
 function TToolManager.ScriptGetTextAlign(AVars: TVariableSet): TScriptResult;
 begin
   case TextAlign of
@@ -1654,6 +1828,27 @@ begin
   result := srOk;
 end;
 
+function TToolManager.ScriptSetDeformationGridMode(AVars: TVariableSet): TScriptResult;
+begin
+  result := srOk;
+  case AVars.Strings['Mode'] of
+  'Deform': DeformationGridMode := gmDeform;
+  'MovePointWithoutDeformation': DeformationGridMode := gmMovePointWithoutDeformation;
+  else result := srInvalidParameters;
+  end;
+end;
+
+function TToolManager.ScriptSetDeformationGridSize(AVars: TVariableSet): TScriptResult;
+var
+  s: TPointF;
+begin
+  s := AVars.Points2D['Size'];
+  if s.x < MinDeformationGridSize then exit(srInvalidParameters);
+  if s.y < MinDeformationGridSize then exit(srInvalidParameters);
+  DeformationGridSize := Size(round(s.x),round(s.y));
+  result := srOk;
+end;
+
 function TToolManager.ScriptSetEraserAlpha(AVars: TVariableSet): TScriptResult;
 var
   alpha: Int64;
@@ -1675,6 +1870,27 @@ begin
   end;
 end;
 
+function TToolManager.ScriptSetFloodFillOptions(AVars: TVariableSet): TScriptResult;
+var optionsSet: TFloodFillOptions;
+  optionsVar: TScriptVariableReference;
+  i: Integer;
+  optionStr: string;
+begin
+  optionsSet := [];
+  optionsVar := AVars.GetVariable('Options');
+  for i := 0 to AVars.GetListCount(optionsVar)-1 do
+  begin
+    optionStr := AVars.GetStringAt(optionsVar, i);
+    case optionStr of
+    'Progressive': include(optionsSet, ffProgressive);
+    'FillAll': include(optionsSet, ffFillAll);
+    else exit(srInvalidParameters);
+    end;
+  end;
+  FloodFillOptions:= optionsSet;
+  result := srOk;
+end;
+
 function TToolManager.ScriptSetFontName(AVars: TVariableSet): TScriptResult;
 begin
   SetTextFont(AVars.Strings['Name'], TextFontSize, TextFontStyle);
@@ -1709,6 +1925,40 @@ begin
   SetTextFont(TextFontName, TextFontSize, style);
   result := srOk;
 end;
+
+function TToolManager.ScriptSetGradientColorspace(AVars: TVariableSet): TScriptResult;
+begin
+  result := srOk;
+  case AVars.Strings['Colorspace'] of
+  'StdRGB': GradientColorspace := ciStdRGB;
+  'LinearRGB': GradientColorspace := ciLinearRGB;
+  'LinearHSLPositive': GradientColorspace := ciLinearHSLPositive;
+  'LinearHSLNegative': GradientColorspace := ciLinearHSLNegative;
+  'GSBPositive': GradientColorspace := ciGSBPositive;
+  'GSBNegative': GradientColorspace := ciGSBNegative;
+  else result := srInvalidParameters;
+  end;
+end;
+
+function TToolManager.ScriptSetGradientSine(AVars: TVariableSet): TScriptResult;
+begin
+  result := srOk;
+  GradientSine:= AVars.Booleans['Enabled'];
+end;
+
+function TToolManager.ScriptSetGradientType(AVars: TVariableSet): TScriptResult;
+begin
+  result := srOk;
+  case AVars.Strings['GradientType'] of
+  'Linear': GradientType:= gtLinear;
+  'Reflected': GradientType := gtReflected;
+  'Diamond': GradientType := gtDiamond;
+  'Radial': GradientType := gtRadial;
+  'Angular': GradientType := gtAngular;
+  else result := srInvalidParameters;
+  end;
+end;
+
 function TToolManager.ScriptSetJoinStyle(AVars: TVariableSet): TScriptResult;
 begin
   result := srOk;
@@ -1770,6 +2020,58 @@ begin
   result := srOk;
 end;
 
+function TToolManager.ScriptSetPerspectiveOptions(AVars: TVariableSet): TScriptResult;
+var optionsSet: TPerspectiveOptions;
+  optionsVar: TScriptVariableReference;
+  i: Integer;
+  optionStr: string;
+begin
+  optionsSet := [];
+  optionsVar := AVars.GetVariable('Options');
+  for i := 0 to AVars.GetListCount(optionsVar)-1 do
+  begin
+    optionStr := AVars.GetStringAt(optionsVar, i);
+    case optionStr of
+    'Repeat': include(optionsSet, poRepeat);
+    'TwoPlanes': include(optionsSet, poTwoPlanes);
+    else exit(srInvalidParameters);
+    end;
+  end;
+  PerspectiveOptions := optionsSet;
+  result := srOk;
+end;
+
+function TToolManager.ScriptSetPhongShapeAltitude(AVars: TVariableSet): TScriptResult;
+begin
+  if (AVars.Floats['Size'] < MinPhongShapeAltitude) or
+     (AVars.Floats['Size'] > MaxPhongShapeAltitude) then exit(srInvalidParameters);
+  result := srOk;
+  PhongShapeAltitude := AVars.Integers['Altitude'];
+end;
+
+function TToolManager.ScriptSetPhongShapeBorderSize(AVars: TVariableSet): TScriptResult;
+begin
+  if (AVars.Floats['Size'] < MinPhongBorderSize) or
+     (AVars.Floats['Size'] > MaxPhongBorderSize) then exit(srInvalidParameters);
+  result := srOk;
+  PhongShapeBorderSize := AVars.Integers['Size'];
+end;
+
+function TToolManager.ScriptSetPhongShapeKind(AVars: TVariableSet): TScriptResult;
+begin
+  result := srOk;
+  case AVars.Strings['Kind'] of
+  'Rectangle': PhongShapeKind := pskRectangle;
+  'RoundRectangle': PhongShapeKind := pskRoundRectangle;
+  'HalfSphere': PhongShapeKind := pskHalfSphere;
+  'ConeTop': PhongShapeKind := pskConeTop;
+  'ConeSide': PhongShapeKind := pskConeSide;
+  'HorizCylinder': PhongShapeKind := pskHorizCylinder;
+  'VertCylinder': PhongShapeKind := pskVertCylinder;
+  else result := srInvalidParameters;
+  end;
+end;
+
 function TToolManager.ScriptSetShapeOptions(AVars: TVariableSet): TScriptResult;
 var so: TShapeOptions;
   options: TScriptVariableReference;
@@ -1807,6 +2109,26 @@ begin
   end;
 end;
 
+function TToolManager.ScriptSetSplineStyle(AVars: TVariableSet): TScriptResult;
+var
+  s: TSplineStyle;
+begin
+  case AVars.Strings['Style'] of
+    'Inside': s := ssInside;
+    'InsideWithEnds': s := ssInsideWithEnds;
+    'Crossing': s := ssCrossing;
+    'CrossingWithEnds': s := ssCrossingWithEnds;
+    'Outside': s := ssOutside;
+    'RoundOutside': s := ssRoundOutside;
+    'VertexToSide': s := ssVertexToSide;
+    'EasyBezier': s := ssEasyBezier;
+  else
+    exit(srInvalidParameters);
+  end;
+  SplineStyle := s;
+  result := srOk;
+end;
+
 function TToolManager.ScriptSetTextAlign(AVars: TVariableSet): TScriptResult;
 begin
   case AVars.Strings['Align'] of
@@ -1916,7 +2238,7 @@ begin
   FPerspectiveOptions:= [poRepeat];
   FDeformationGridNbX := 5;
   FDeformationGridNbY := 5;
-  FDeformationGridMoveWithoutDeformation := false;
+  FDeformationGridMode := gmDeform;
 
   PenWidthControls := TList.Create;
   AliasingControls := TList.Create;
@@ -2274,7 +2596,7 @@ begin
   FScriptContext.RegisterScriptFunction('ToolGetArrowEnd', @ScriptGetArrowEnd, ARegister);
   FScriptContext.RegisterScriptFunction('ToolSetArrowSize', @ScriptSetArrowSize, ARegister);
   FScriptContext.RegisterScriptFunction('ToolGetArrowSize', @ScriptGetArrowSize, ARegister);
-{  FScriptContext.RegisterScriptFunction('ToolSetSplineStyle', @ScriptSetSplineStyle, ARegister);
+  FScriptContext.RegisterScriptFunction('ToolSetSplineStyle', @ScriptSetSplineStyle, ARegister);
   FScriptContext.RegisterScriptFunction('ToolGetSplineStyle', @ScriptGetSplineStyle, ARegister);
   FScriptContext.RegisterScriptFunction('ToolSetGradientType', @ScriptSetGradientType, ARegister);
   FScriptContext.RegisterScriptFunction('ToolGetGradientType', @ScriptGetGradientType, ARegister);
@@ -2297,7 +2619,7 @@ begin
   FScriptContext.RegisterScriptFunction('ToolSetFloodFillOptions', @ScriptSetFloodFillOptions, ARegister);
   FScriptContext.RegisterScriptFunction('ToolGetFloodFillOptions', @ScriptGetFloodFillOptions, ARegister);
   FScriptContext.RegisterScriptFunction('ToolSetPerspectiveOptions', @ScriptSetPerspectiveOptions, ARegister);
-  FScriptContext.RegisterScriptFunction('ToolGetPerspectiveOptions', @ScriptGetPerspectiveOptions, ARegister);}
+  FScriptContext.RegisterScriptFunction('ToolGetPerspectiveOptions', @ScriptGetPerspectiveOptions, ARegister);
 end;
 
 procedure TToolManager.ToolWakeUp;

+ 1 - 1
lazpaint/tools/utooldeformationgrid.pas

@@ -947,7 +947,7 @@ begin
   Manager.HintReturnValidates;
 
   if not deformationGridMoving then exit;
-  if Manager.DeformationGridMoveWithoutDeformation then
+  if Manager.DeformationGridMode = gmMovePointWithoutDeformation then
   begin
     ReleaseGrid;
     DeformationGrid[deformationGridY,deformationGridX] := PointF(

+ 88 - 1
scripts/lazpaint/tools.py

@@ -82,6 +82,45 @@ ARROW_HOLLOW_TRIANGLE = 'HollowTriangle'
 ARROW_HOLLOW_TRIANGLE_BACK1 = 'HollowTriangleBack1'
 ARROW_HOLLOW_TRIANGLE_BACK2 = 'HollowTriangleBack2'
 
+SPLINE_STYLE_INSIDE = 'Inside'
+SPLINE_STYLE_INSIDE_WITH_ENDS = 'InsideWithEnds'
+SPLINE_STYLE_CROSSING = 'Crossing'
+SPLINE_STYLE_CROSSING_WITH_ENDS = 'CrossingWithEnds'
+SPLINE_STYLE_OUTSIDE = 'Outside'
+SPLINE_STYLE_ROUND_OUTSIDE = 'RoundOutside'
+SPLINE_STYLE_VERTEX_TO_SIDE = 'VertexToSide'
+SPLINE_STYLE_EASY_BEZIER = 'EasyBezier'
+
+GRADIENT_TYPE_LINEAR = 'Linear'
+GRADIENT_TYPE_REFLECTED = 'Reflected'
+GRADIENT_TYPE_DIAMOND = 'Diamond'
+GRADIENT_TYPE_RADIAL =  'Radial'
+GRADIENT_TYPE_ANGULAR = 'Angular'
+
+GRADIENT_COLORSPACE_STD_RGB = 'StdRGB'
+GRADIENT_COLORSPACE_LINEAR_RGB = 'LinearRGB'
+GRADIENT_COLORSPACE_LINEAR_HSL_POSITIVE = 'LinearHSLPositive'
+GRADIENT_COLORSPACE_LINEAR_HSL_NEGATIVE = 'LinearHSLNegative'
+GRADIENT_COLORSPACE_CORR_HSL_POSITIVE = 'GSBPositive'
+GRADIENT_COLORSPACE_CORR_HSL_NEGATIVE = 'GSBNegative'
+
+SHAPE_KIND_RECTANGLE = 'Rectangle'
+SHAPE_KIND_ROUND_RECTANGLE = 'RoundRectangle'
+SHAPE_KIND_HALF_SPHERE = 'HalfSphere'
+SHAPE_KIND_CONE_TOP = 'ConeTop'
+SHAPE_KIND_CONE_SIDE = 'ConeSide'
+SHAPE_KIND_HORIZ_CYLINDER = 'HorizCylinder'
+SHAPE_KIND_VERT_CYLINDER = 'VertCylinder'
+
+DEFORMATION_MODE_DEFORM = 'Deform'
+DEFORMATION_MODE_MOVE_POINT_WITHOUT_DEFORMATION = 'MovePointWithoutDeformation'
+
+FLOOD_FILL_PROGRESSIVE = 'Progressive'
+FLOOD_FILL_FILL_ALL = 'FillAll' #not implemented
+
+PERSPECTIVE_REPEAT = 'Repeat'
+PERSPECTIVE_TWO_PLANES = 'TwoPlanes'
+
 KEY_UNKNOWN = 'Unknown'
 KEY_BACKSPACE = 'Backspace'
 KEY_TAB = 'Tab'
@@ -278,7 +317,7 @@ def get_font_size() -> float:
 def set_font_style(style: list):
   command.send('ToolSetFontStyle', Style=style)
 
-def get_font_style():
+def get_font_style() -> list:
   return command.send('ToolGetFontStyle?')
 
 def set_text_align(align):
@@ -323,3 +362,51 @@ def set_arrow_size(x, y):
 def get_arrow_size() -> tuple:
   return command.send('ToolGetArrowSize?')
 
+def set_spline_style(style):
+  command.send('ToolSetSplineStyle', Style=style)
+
+def get_spline_style():
+  return command.send('ToolGetSplineStyle?')
+
+def set_gradient_type(gradient_type):
+  command.send('ToolSetGradientType', GradientType=gradient_type)
+
+def get_gradient_type():
+  return command.send('ToolGetGradientType?')
+
+def set_gradient_colorspace(colorspace):
+  command.send('ToolSetGradientColorspace', Colorspace=colorspace)
+
+def get_gradient_colorspace():
+  return command.send('ToolGetGradientColorspace?')
+
+def set_gradient_type(gradient_type):
+  command.send('ToolSetGradientType', GradientType=gradient_type)
+
+def get_gradient_type():
+  return command.send('ToolGetGradientType?')
+
+def set_phong_shape_kind(kind):
+  command.send('ToolSetPhongShapeKind', Kind=kind)
+
+def get_phong_shape_kind():
+  return command.send('ToolGetPhongShapeKind?')
+
+def set_grid_deformation_mode(mode):
+  command.send('ToolSetDeformationGridMode', Mode=mode)
+
+def get_grid_deformation_mode():
+  return command.send('ToolGetDeformationGridMode?')
+
+def set_flood_fill_options(options: list):
+  command.send('ToolSetFloodFillOptions', Options=options)
+
+def get_flood_fill_options() -> list:
+  return command.send('ToolGetFloodFillOptions?')
+
+def set_perspective_options(options: list):
+  command.send('ToolSetPerspectiveOptions', Options=options)
+
+def get_perspective_options() -> list:
+  return command.send('ToolGetPerspectiveOptions?')
+