Browse Source

Added legacy blending for beta files and adjusted softness

flabbet 8 months ago
parent
commit
b77033b86d

+ 1 - 1
src/PixiEditor.ChangeableDocument/Changes/Drawing/LineBasedPen_UpdateableChange.cs

@@ -151,7 +151,7 @@ internal class LineBasedPen_UpdateableChange : UpdateableChange
         radius = MathF.Max(1, radius);
         srcPaint.Shader = Shader.CreateRadialGradient(
             pos, radius, [color, color.WithAlpha(0)],
-            [Math.Max(hardness + 0.04f, 0), 1f], ShaderTileMode.Clamp);
+            [Math.Max(hardness - 0.05f, 0), 0.95f], ShaderTileMode.Clamp);
     }
 
     public override OneOf<None, IChangeInfo, List<IChangeInfo>> Apply(Document target, bool firstApply,

+ 42 - 30
src/PixiEditor/Models/DocumentModels/Public/DocumentOperationsModule.cs

@@ -424,16 +424,17 @@ internal class DocumentOperationsModule : IDocumentOperations
     /// </summary>
     public void Undo()
     {
-        IMidChangeUndoableExecutor executor = Internals.ChangeController.TryGetExecutorFeature<IMidChangeUndoableExecutor>();
+        IMidChangeUndoableExecutor executor =
+            Internals.ChangeController.TryGetExecutorFeature<IMidChangeUndoableExecutor>();
         if (executor is { CanUndo: true })
         {
             executor.OnMidChangeUndo();
             return;
         }
-        
-        if(Internals.ChangeController.IsBlockingChangeActive)
+
+        if (Internals.ChangeController.IsBlockingChangeActive)
             return;
-        
+
         Internals.ChangeController.TryStopActiveExecutor();
         Internals.ActionAccumulator.AddActions(new Undo_Action());
     }
@@ -443,14 +444,15 @@ internal class DocumentOperationsModule : IDocumentOperations
     /// </summary>
     public void Redo()
     {
-        IMidChangeUndoableExecutor executor = Internals.ChangeController.TryGetExecutorFeature<IMidChangeUndoableExecutor>();
+        IMidChangeUndoableExecutor executor =
+            Internals.ChangeController.TryGetExecutorFeature<IMidChangeUndoableExecutor>();
         if (executor is { CanRedo: true })
         {
             executor.OnMidChangeRedo();
             return;
         }
-        
-        if(Internals.ChangeController.IsBlockingChangeActive)
+
+        if (Internals.ChangeController.IsBlockingChangeActive)
             return;
 
         Internals.ChangeController.TryStopActiveExecutor();
@@ -549,7 +551,7 @@ internal class DocumentOperationsModule : IDocumentOperations
     {
         if (Internals.ChangeController.IsBlockingChangeActive)
             return;
-        
+
         Internals.ChangeController.TryStopActiveExecutor();
 
         Internals.ChangeController.TryStartExecutor(new PasteImageExecutor(image, startPos, memberGuid, drawOnMask));
@@ -597,9 +599,9 @@ internal class DocumentOperationsModule : IDocumentOperations
     {
         if (Internals.ChangeController.IsBlockingChangeActive)
             return;
-        
+
         Internals.ChangeController.TryStopActiveExecutor();
-        
+
         Internals.ActionAccumulator.AddActions(
             new PasteImage_Action(image, corners, memberGuid, ignoreClipSymmetriesEtc, drawOnMask, atFrame, default),
             new EndPasteImage_Action());
@@ -614,9 +616,9 @@ internal class DocumentOperationsModule : IDocumentOperations
     {
         if (Internals.ChangeController.IsBlockingChangeActive)
             return;
-        
+
         Internals.ChangeController.TryStopActiveExecutor();
-        
+
         Internals.ActionAccumulator.AddFinishedActions(
             new ClipCanvas_Action(Document.AnimationHandler.ActiveFrameBindable));
     }
@@ -633,7 +635,7 @@ internal class DocumentOperationsModule : IDocumentOperations
     {
         if (Internals.ChangeController.IsBlockingChangeActive)
             return;
-        
+
         Internals.ChangeController.TryStopActiveExecutor();
 
         Internals.ActionAccumulator.AddFinishedActions(new FlipImage_Action(flipType, frame, membersToFlip));
@@ -655,7 +657,7 @@ internal class DocumentOperationsModule : IDocumentOperations
             return;
 
         Internals.ChangeController.TryStopActiveExecutor();
-        
+
         Internals.ActionAccumulator.AddFinishedActions(new RotateImage_Action(rotation, membersToRotate, frame));
     }
 
@@ -666,7 +668,7 @@ internal class DocumentOperationsModule : IDocumentOperations
     {
         if (Internals.ChangeController.IsBlockingChangeActive)
             return;
-        
+
         Internals.ChangeController.TryStopActiveExecutor();
 
         Internals.ActionAccumulator.AddFinishedActions(new CenterContent_Action(structureMembers.ToList(), frame));
@@ -680,7 +682,7 @@ internal class DocumentOperationsModule : IDocumentOperations
     {
         if (Internals.ChangeController.IsBlockingChangeActive)
             return;
-        
+
         Internals.ChangeController.TryStopActiveExecutor();
 
         RectD referenceImageRect =
@@ -695,7 +697,8 @@ internal class DocumentOperationsModule : IDocumentOperations
     /// </summary>
     public void DeleteReferenceLayer()
     {
-        if (Internals.ChangeController.IsBlockingChangeActive || Document.ReferenceLayerHandler.ReferenceTexture is null)
+        if (Internals.ChangeController.IsBlockingChangeActive ||
+            Document.ReferenceLayerHandler.ReferenceTexture is null)
             return;
 
         Internals.ChangeController.TryStopActiveExecutor();
@@ -708,11 +711,12 @@ internal class DocumentOperationsModule : IDocumentOperations
     /// </summary>
     public void TransformReferenceLayer()
     {
-        if (Document.ReferenceLayerHandler.ReferenceTexture is null || Internals.ChangeController.IsBlockingChangeActive)
+        if (Document.ReferenceLayerHandler.ReferenceTexture is null ||
+            Internals.ChangeController.IsBlockingChangeActive)
             return;
-        
+
         Internals.ChangeController.TryStopActiveExecutor();
-        
+
         Internals.ChangeController.TryStartExecutor(new TransformReferenceLayerExecutor());
     }
 
@@ -721,9 +725,10 @@ internal class DocumentOperationsModule : IDocumentOperations
     /// </summary>
     public void ResetReferenceLayerPosition()
     {
-        if (Document.ReferenceLayerHandler.ReferenceTexture is null || Internals.ChangeController.IsBlockingChangeActive)
+        if (Document.ReferenceLayerHandler.ReferenceTexture is null ||
+            Internals.ChangeController.IsBlockingChangeActive)
             return;
-        
+
         Internals.ChangeController.TryStopActiveExecutor();
 
         VecD size = new(Document.ReferenceLayerHandler.ReferenceTexture.Size.X,
@@ -742,7 +747,7 @@ internal class DocumentOperationsModule : IDocumentOperations
             return;
 
         Internals.ChangeController.TryStopActiveExecutor();
-        
+
         if (Document.SelectedStructureMember is not { } member || Document.SelectionPathBindable.IsEmpty)
             return;
 
@@ -758,9 +763,9 @@ internal class DocumentOperationsModule : IDocumentOperations
     {
         if (Internals.ChangeController.IsBlockingChangeActive)
             return;
-        
+
         Internals.ChangeController.TryStopActiveExecutor();
-        
+
         var bounds = Document.SelectionPathBindable.TightBounds;
         if (Document.SelectionPathBindable.IsEmpty || bounds.Width <= 0 || bounds.Height <= 0)
             return;
@@ -781,9 +786,9 @@ internal class DocumentOperationsModule : IDocumentOperations
     {
         if (Internals.ChangeController.IsBlockingChangeActive)
             return;
-        
+
         Internals.ChangeController.TryStopActiveExecutor();
-        
+
         var selection = Document.SelectionPathBindable;
         var inverse = new VectorPath();
         inverse.AddRect(new RectD(new(0, 0), Document.SizeBindable));
@@ -796,7 +801,7 @@ internal class DocumentOperationsModule : IDocumentOperations
     {
         if (Internals.ChangeController.IsBlockingChangeActive)
             return;
-        
+
         Internals.ChangeController.TryStopActiveExecutor();
 
         Internals.ActionAccumulator.AddFinishedActions(new RasterizeMember_Action(memberId));
@@ -806,7 +811,7 @@ internal class DocumentOperationsModule : IDocumentOperations
     {
         if (Internals.ChangeController.IsBlockingChangeActive)
             return;
-        
+
         Internals.ChangeController.TryStopActiveExecutor();
 
         IAction targetAction = new InvokeAction_PassthroughAction(action);
@@ -816,6 +821,13 @@ internal class DocumentOperationsModule : IDocumentOperations
 
     public void UseLinearSrgbProcessing()
     {
-        Internals.ActionAccumulator.AddFinishedActions(new ChangeProcessingColorSpace_Action(ColorSpace.CreateSrgbLinear()));
+        Internals.ActionAccumulator.AddFinishedActions(
+            new ChangeProcessingColorSpace_Action(ColorSpace.CreateSrgbLinear()));
+    }
+
+    public void UseSrgbProcessing()
+    {
+        Internals.ActionAccumulator.AddFinishedActions(
+            new ChangeProcessingColorSpace_Action(ColorSpace.CreateSrgb()));
     }
 }

+ 1 - 0
src/PixiEditor/Views/Windows/BetaExampleButton.axaml.cs

@@ -71,6 +71,7 @@ public partial class BetaExampleButton : UserControl
         CloseCommand.Execute(null);
         
         ViewModelMain.Current.FileSubViewModel.OpenRecoveredDotPixi(null, bytes);
+        ViewModelMain.Current.DocumentManagerSubViewModel.Documents[^1].Operations.UseSrgbProcessing();
         Analytics.SendOpenExample(FileName);
     }