Skip to content

Commit

Permalink
Tile can draw to the canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
iconstudio committed Oct 3, 2023
1 parent c0853a0 commit e871c6c
Showing 1 changed file with 64 additions and 1 deletion.
65 changes: 64 additions & 1 deletion Editor/TestEditor/Contents/Tile.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System.Diagnostics.Contracts;
using System.Numerics;

using Microsoft.Graphics.Canvas;

using Windows.Foundation;

namespace TestEditor.Contents
{
[Serializable]
Expand All @@ -10,7 +13,7 @@ internal readonly struct Tile
{
public readonly string ImageFile { get; }
public readonly CanvasBitmap Source { get; }

public readonly Rect Bounds => Source?.Bounds ?? Rect.Empty;
public bool IsDeserializable => false;

public Tile(string filepath, CanvasBitmap source)
Expand All @@ -19,6 +22,66 @@ public Tile(string filepath, CanvasBitmap source)
Source = source;
}

[Pure]
public readonly void Draw(CanvasDrawingSession context)
{
context.DrawImage(Source);
}
[Pure]
public readonly void Draw(CanvasDrawingSession context, in Vector2 position)
{
context.DrawImage(Source, position);
}
[Pure]
public readonly void Draw(CanvasDrawingSession context, in float x, in float y)
{
context.DrawImage(Source, x, y);
}
[Pure]
public readonly void Draw(CanvasDrawingSession context, in Vector2 position, in float opacity)
{
context.DrawImage(Source, position, Bounds, opacity);
}
[Pure]
public readonly void Draw(CanvasDrawingSession context, in float x, in float y, in float opacity)
{
context.DrawImage(Source, x, y, Bounds, opacity);
}
[Pure]
public readonly void DrawPart(CanvasDrawingSession context, in Rect bound)
{
context.DrawImage(Source, bound);
}
[Pure]
public readonly void DrawPart(CanvasDrawingSession context, in Vector2 position, in Rect bound)
{
context.DrawImage(Source, position, bound);
}
[Pure]
public readonly void DrawPart(CanvasDrawingSession context, in float x, in float y, in Rect bound)
{
context.DrawImage(Source, x, y, bound);
}
[Pure]
public readonly void DrawPart(CanvasDrawingSession context, in Vector2 position, in Rect bound, in float opacity)
{
context.DrawImage(Source, position, bound, opacity);
}
[Pure]
public readonly void DrawPart(CanvasDrawingSession context, in float x, in float y, in Rect bound, in float opacity)
{
context.DrawImage(Source, x, y, bound, opacity);
}
[Pure]
public readonly void DrawInterpolated(CanvasDrawingSession context, in Vector2 position, in float opacity, in CanvasImageInterpolation interpolation)
{
context.DrawImage(Source, position, Bounds, opacity, interpolation);
}
[Pure]
public readonly void DrawInterpolated(CanvasDrawingSession context, in float x, in float y, in float opacity, in CanvasImageInterpolation interpolation)
{
context.DrawImage(Source, x, y, Bounds, opacity, interpolation);
}
[Pure]
public readonly SerializedTile Serialize(int id)
{
Expand Down

0 comments on commit e871c6c

Please sign in to comment.