|
@@ -18,6 +18,7 @@ namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
|
|
public class VectorLayerNode : LayerNode, ITransformableObject, IReadOnlyVectorNode, IRasterizable
|
|
public class VectorLayerNode : LayerNode, ITransformableObject, IReadOnlyVectorNode, IRasterizable
|
|
{
|
|
{
|
|
public OutputProperty<ShapeVectorData> Shape { get; }
|
|
public OutputProperty<ShapeVectorData> Shape { get; }
|
|
|
|
+
|
|
public Matrix3X3 TransformationMatrix
|
|
public Matrix3X3 TransformationMatrix
|
|
{
|
|
{
|
|
get => ShapeData?.TransformationMatrix ?? Matrix3X3.Identity;
|
|
get => ShapeData?.TransformationMatrix ?? Matrix3X3.Identity;
|
|
@@ -37,6 +38,7 @@ public class VectorLayerNode : LayerNode, ITransformableObject, IReadOnlyVectorN
|
|
get => Shape.Value;
|
|
get => Shape.Value;
|
|
set => Shape.Value = value;
|
|
set => Shape.Value = value;
|
|
}
|
|
}
|
|
|
|
+
|
|
IReadOnlyShapeVectorData IReadOnlyVectorNode.ShapeData => ShapeData;
|
|
IReadOnlyShapeVectorData IReadOnlyVectorNode.ShapeData => ShapeData;
|
|
|
|
|
|
|
|
|
|
@@ -48,7 +50,7 @@ public class VectorLayerNode : LayerNode, ITransformableObject, IReadOnlyVectorN
|
|
AllowHighDpiRendering = true;
|
|
AllowHighDpiRendering = true;
|
|
Shape = CreateOutput<ShapeVectorData>("Shape", "SHAPE", null);
|
|
Shape = CreateOutput<ShapeVectorData>("Shape", "SHAPE", null);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
protected override VecI GetTargetSize(RenderContext ctx)
|
|
protected override VecI GetTargetSize(RenderContext ctx)
|
|
{
|
|
{
|
|
return ctx.DocumentSize;
|
|
return ctx.DocumentSize;
|
|
@@ -61,7 +63,7 @@ public class VectorLayerNode : LayerNode, ITransformableObject, IReadOnlyVectorN
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
Rasterize(workingSurface, paint);
|
|
Rasterize(workingSurface, paint);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -71,7 +73,7 @@ public class VectorLayerNode : LayerNode, ITransformableObject, IReadOnlyVectorN
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
Rasterize(workingSurface, paint);
|
|
Rasterize(workingSurface, paint);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -85,13 +87,18 @@ public class VectorLayerNode : LayerNode, ITransformableObject, IReadOnlyVectorN
|
|
{
|
|
{
|
|
return ShapeData?.TransformedVisualAABB;
|
|
return ShapeData?.TransformedVisualAABB;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
public override bool RenderPreview(DrawingSurface renderOn, RenderContext context,
|
|
public override bool RenderPreview(DrawingSurface renderOn, RenderContext context,
|
|
string elementToRenderName)
|
|
string elementToRenderName)
|
|
{
|
|
{
|
|
|
|
+ if (elementToRenderName == nameof(EmbeddedMask))
|
|
|
|
+ {
|
|
|
|
+ return base.RenderPreview(renderOn, context, elementToRenderName);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (ShapeData == null)
|
|
if (ShapeData == null)
|
|
{
|
|
{
|
|
return false;
|
|
return false;
|
|
@@ -104,9 +111,9 @@ public class VectorLayerNode : LayerNode, ITransformableObject, IReadOnlyVectorN
|
|
VecI translation = new VecI(
|
|
VecI translation = new VecI(
|
|
(int)Math.Max(ShapeData.TransformedAABB.TopLeft.X, 0),
|
|
(int)Math.Max(ShapeData.TransformedAABB.TopLeft.X, 0),
|
|
(int)Math.Max(ShapeData.TransformedAABB.TopLeft.Y, 0));
|
|
(int)Math.Max(ShapeData.TransformedAABB.TopLeft.Y, 0));
|
|
-
|
|
|
|
|
|
+
|
|
VecI size = tightBoundsSize + translation;
|
|
VecI size = tightBoundsSize + translation;
|
|
-
|
|
|
|
|
|
+
|
|
if (size.X == 0 || size.Y == 0)
|
|
if (size.X == 0 || size.Y == 0)
|
|
{
|
|
{
|
|
return false;
|
|
return false;
|
|
@@ -159,7 +166,7 @@ public class VectorLayerNode : LayerNode, ITransformableObject, IReadOnlyVectorN
|
|
{
|
|
{
|
|
int layer = surface.Canvas.SaveLayer(paint);
|
|
int layer = surface.Canvas.SaveLayer(paint);
|
|
ShapeData?.RasterizeTransformed(surface.Canvas);
|
|
ShapeData?.RasterizeTransformed(surface.Canvas);
|
|
-
|
|
|
|
|
|
+
|
|
surface.Canvas.RestoreToCount(layer);
|
|
surface.Canvas.RestoreToCount(layer);
|
|
}
|
|
}
|
|
|
|
|