|
@@ -10,9 +10,9 @@ using PixiEditor.Numerics;
|
|
namespace PixiEditor.DrawingApi.Core.Surface
|
|
namespace PixiEditor.DrawingApi.Core.Surface
|
|
{
|
|
{
|
|
public delegate void SurfaceChangedEventHandler(RectD? changedRect);
|
|
public delegate void SurfaceChangedEventHandler(RectD? changedRect);
|
|
|
|
+
|
|
public class Canvas : NativeObject
|
|
public class Canvas : NativeObject
|
|
{
|
|
{
|
|
-
|
|
|
|
public override object Native => DrawingBackendApi.Current.CanvasImplementation.GetNativeCanvas(ObjectPointer);
|
|
public override object Native => DrawingBackendApi.Current.CanvasImplementation.GetNativeCanvas(ObjectPointer);
|
|
public event SurfaceChangedEventHandler? Changed;
|
|
public event SurfaceChangedEventHandler? Changed;
|
|
|
|
|
|
@@ -21,6 +21,7 @@ namespace PixiEditor.DrawingApi.Core.Surface
|
|
}
|
|
}
|
|
|
|
|
|
public void DrawPixel(VecI position, Paint drawingPaint) => DrawPixel(position.X, position.Y, drawingPaint);
|
|
public void DrawPixel(VecI position, Paint drawingPaint) => DrawPixel(position.X, position.Y, drawingPaint);
|
|
|
|
+
|
|
public void DrawPixel(int posX, int posY, Paint drawingPaint)
|
|
public void DrawPixel(int posX, int posY, Paint drawingPaint)
|
|
{
|
|
{
|
|
DrawingBackendApi.Current.CanvasImplementation.DrawPixel(ObjectPointer, posX, posY, drawingPaint);
|
|
DrawingBackendApi.Current.CanvasImplementation.DrawPixel(ObjectPointer, posX, posY, drawingPaint);
|
|
@@ -34,15 +35,16 @@ namespace PixiEditor.DrawingApi.Core.Surface
|
|
}
|
|
}
|
|
|
|
|
|
public void DrawSurface(DrawingSurface original, int x, int y) => DrawSurface(original, x, y, null);
|
|
public void DrawSurface(DrawingSurface original, int x, int y) => DrawSurface(original, x, y, null);
|
|
-
|
|
|
|
|
|
+
|
|
public void DrawSurface(DrawingSurface surfaceToDraw, VecI size, Paint paint)
|
|
public void DrawSurface(DrawingSurface surfaceToDraw, VecI size, Paint paint)
|
|
{
|
|
{
|
|
DrawSurface(surfaceToDraw, size.X, size.Y, paint);
|
|
DrawSurface(surfaceToDraw, size.X, size.Y, paint);
|
|
}
|
|
}
|
|
|
|
|
|
- public void DrawImage(Image image, int x, int y) => DrawingBackendApi.Current.CanvasImplementation.DrawImage(ObjectPointer, image, x, y);
|
|
|
|
-
|
|
|
|
- public void DrawImage(Image image, RectD rect, Paint paint) =>
|
|
|
|
|
|
+ public void DrawImage(Image image, int x, int y) =>
|
|
|
|
+ DrawingBackendApi.Current.CanvasImplementation.DrawImage(ObjectPointer, image, x, y);
|
|
|
|
+
|
|
|
|
+ public void DrawImage(Image image, RectD rect, Paint paint) =>
|
|
DrawingBackendApi.Current.CanvasImplementation.DrawImage(ObjectPointer, image, rect, paint);
|
|
DrawingBackendApi.Current.CanvasImplementation.DrawImage(ObjectPointer, image, rect, paint);
|
|
|
|
|
|
public int Save()
|
|
public int Save()
|
|
@@ -54,7 +56,7 @@ namespace PixiEditor.DrawingApi.Core.Surface
|
|
{
|
|
{
|
|
DrawingBackendApi.Current.CanvasImplementation.Restore(ObjectPointer);
|
|
DrawingBackendApi.Current.CanvasImplementation.Restore(ObjectPointer);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void Scale(float s) => Scale(s, s);
|
|
public void Scale(float s) => Scale(s, s);
|
|
|
|
|
|
/// <param name="size">The amount to scale.</param>
|
|
/// <param name="size">The amount to scale.</param>
|
|
@@ -93,7 +95,7 @@ namespace PixiEditor.DrawingApi.Core.Surface
|
|
DrawingBackendApi.Current.CanvasImplementation.DrawPath(ObjectPointer, path, paint);
|
|
DrawingBackendApi.Current.CanvasImplementation.DrawPath(ObjectPointer, path, paint);
|
|
Changed?.Invoke(path.Bounds);
|
|
Changed?.Invoke(path.Bounds);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void DrawPoint(VecI pos, Paint paint)
|
|
public void DrawPoint(VecI pos, Paint paint)
|
|
{
|
|
{
|
|
DrawingBackendApi.Current.CanvasImplementation.DrawPoint(ObjectPointer, pos, paint);
|
|
DrawingBackendApi.Current.CanvasImplementation.DrawPoint(ObjectPointer, pos, paint);
|
|
@@ -111,20 +113,20 @@ namespace PixiEditor.DrawingApi.Core.Surface
|
|
DrawingBackendApi.Current.CanvasImplementation.DrawRect(ObjectPointer, x, y, width, height, paint);
|
|
DrawingBackendApi.Current.CanvasImplementation.DrawRect(ObjectPointer, x, y, width, height, paint);
|
|
Changed?.Invoke(new RectD(x, y, width, height));
|
|
Changed?.Invoke(new RectD(x, y, width, height));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void DrawCircle(int x, int y, int radius, Paint paint)
|
|
public void DrawCircle(int x, int y, int radius, Paint paint)
|
|
{
|
|
{
|
|
DrawingBackendApi.Current.CanvasImplementation.DrawCircle(ObjectPointer, x, y, radius, paint);
|
|
DrawingBackendApi.Current.CanvasImplementation.DrawCircle(ObjectPointer, x, y, radius, paint);
|
|
Changed?.Invoke(new RectD(x - radius, y - radius, radius * 2, radius * 2));
|
|
Changed?.Invoke(new RectD(x - radius, y - radius, radius * 2, radius * 2));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void DrawRect(RectI rect, Paint paint) => DrawRect(rect.X, rect.Y, rect.Width, rect.Height, paint);
|
|
public void DrawRect(RectI rect, Paint paint) => DrawRect(rect.X, rect.Y, rect.Width, rect.Height, paint);
|
|
|
|
|
|
public void ClipPath(VectorPath clipPath) => ClipPath(clipPath, ClipOperation.Intersect);
|
|
public void ClipPath(VectorPath clipPath) => ClipPath(clipPath, ClipOperation.Intersect);
|
|
|
|
|
|
public void ClipPath(VectorPath clipPath, ClipOperation clipOperation) =>
|
|
public void ClipPath(VectorPath clipPath, ClipOperation clipOperation) =>
|
|
ClipPath(clipPath, clipOperation, false);
|
|
ClipPath(clipPath, clipOperation, false);
|
|
-
|
|
|
|
|
|
+
|
|
public void ClipPath(VectorPath clipPath, ClipOperation clipOperation, bool antialias)
|
|
public void ClipPath(VectorPath clipPath, ClipOperation clipOperation, bool antialias)
|
|
{
|
|
{
|
|
DrawingBackendApi.Current.CanvasImplementation.ClipPath(ObjectPointer, clipPath, clipOperation, antialias);
|
|
DrawingBackendApi.Current.CanvasImplementation.ClipPath(ObjectPointer, clipPath, clipOperation, antialias);
|
|
@@ -140,7 +142,7 @@ namespace PixiEditor.DrawingApi.Core.Surface
|
|
DrawingBackendApi.Current.CanvasImplementation.Clear(ObjectPointer);
|
|
DrawingBackendApi.Current.CanvasImplementation.Clear(ObjectPointer);
|
|
Changed?.Invoke(null);
|
|
Changed?.Invoke(null);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void Clear(Color color)
|
|
public void Clear(Color color)
|
|
{
|
|
{
|
|
DrawingBackendApi.Current.CanvasImplementation.Clear(ObjectPointer, color);
|
|
DrawingBackendApi.Current.CanvasImplementation.Clear(ObjectPointer, color);
|
|
@@ -190,6 +192,12 @@ namespace PixiEditor.DrawingApi.Core.Surface
|
|
Changed?.Invoke(null);
|
|
Changed?.Invoke(null);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void DrawPaint(Paint paint)
|
|
|
|
+ {
|
|
|
|
+ DrawingBackendApi.Current.CanvasImplementation.DrawPaint(ObjectPointer, paint);
|
|
|
|
+ Changed?.Invoke(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
public override void Dispose()
|
|
public override void Dispose()
|
|
{
|
|
{
|
|
DrawingBackendApi.Current.CanvasImplementation.Dispose(ObjectPointer);
|
|
DrawingBackendApi.Current.CanvasImplementation.Dispose(ObjectPointer);
|