瀏覽代碼

update fill except geometry, fix assign

johann 5 年之前
父節點
當前提交
940818264a

+ 7 - 2
lazpaintcontrols/lcvectorialfill.pas

@@ -687,11 +687,16 @@ begin
     case other.FillType of
     vftSolid: SetSolid(other.SolidColor);
     vftGradient: begin
-        tempGrad := self.Gradient.Duplicate as TBGRALayerGradientOriginal;
+        if self.FillType = vftGradient then
+          tempGrad := self.Gradient.Duplicate as TBGRALayerGradientOriginal
+        else
+          tempGrad := TBGRALayerGradientOriginal.Create;
         tempGrad.AssignExceptGeometry(other.Gradient);
         SetGradient(tempGrad, true);
       end;
-    vftTexture: SetTexture(other.Texture, self.TextureMatrix, other.TextureOpacity, other.TextureRepetition);
+    vftTexture: if self.FillType = vftTexture then
+        SetTexture(other.Texture, self.TextureMatrix, other.TextureOpacity, other.TextureRepetition)
+        else SetTexture(other.Texture, AffineMatrixIdentity, other.TextureOpacity, other.TextureRepetition);
     else Clear;
     end;
   end else

+ 6 - 0
lazpaintcontrols/lcvectorialfillcontrol.pas

@@ -75,6 +75,7 @@ type
     procedure AssignFill(AFill: TVectorialFill);
     function CreateShapeFill(AShape: TVectorShape): TVectorialFill;
     procedure UpdateShapeFill(AShape: TVectorShape; ATarget: TLCFillTarget);
+    procedure UpdateFillExceptGeometry(ATargetFill: TVectorialFill);
     property FillType: TVectorialFillType read GetFillType write SetFillType;
     property AverageColor: TBGRAPixel read GetAverageColor;
     property SolidColor: TBGRAPixel read GetSolidColor write SetSolidColor;
@@ -357,5 +358,10 @@ begin
   FInterface.UpdateShapeFill(AShape, ATarget);
 end;
 
+procedure TLCVectorialFillControl.UpdateFillExceptGeometry(ATargetFill: TVectorialFill);
+begin
+  FInterface.UpdateFillExceptGeometry(ATargetFill);
+end;
+
 end.
 

+ 13 - 1
lazpaintcontrols/lcvectorialfillinterface.pas

@@ -141,6 +141,7 @@ type
     procedure ContainerSizeChanged;
     function GetTextureThumbnail(AWidth, AHeight: integer; ABackColor: TColor): TBitmap;
     procedure AssignFill(AFill: TVectorialFill);
+    procedure UpdateFillExceptGeometry(ATargetFill: TVectorialFill);
     function CreateShapeFill(AShape: TVectorShape): TVectorialFill;
     procedure UpdateShapeFill(AShape: TVectorShape; ATarget: TLCFillTarget);
     property FillType: TVectorialFillType read FFillType write SetFillType;
@@ -962,6 +963,16 @@ begin
   end;
 end;
 
+procedure TVectorialFillInterface.UpdateFillExceptGeometry(ATargetFill: TVectorialFill);
+var
+  f: TVectorialFill;
+begin
+  f := CreateShapeFill(nil);
+  if Assigned(ATargetFill) then
+    ATargetFill.AssignExceptGeometry(f);
+  f.Free;
+end;
+
 function TVectorialFillInterface.CreateShapeFill(AShape: TVectorShape): TVectorialFill;
 var
   grad: TBGRALayerGradientOriginal;
@@ -985,7 +996,8 @@ begin
   end
   else exit(nil); //none
 
-  result.FitGeometry(AShape.SuggestGradientBox(AffineMatrixIdentity));
+  if Assigned(AShape) then
+    result.FitGeometry(AShape.SuggestGradientBox(AffineMatrixIdentity));
 end;
 
 procedure TVectorialFillInterface.UpdateShapeFill(AShape: TVectorShape;