2026-01-05 03:57:09 +11:00
|
|
|
|
using Progrart.Core.Storage;
|
|
|
|
|
|
using SkiaSharp;
|
2025-12-14 00:25:51 +11:00
|
|
|
|
|
|
|
|
|
|
namespace Progrart.Core
|
|
|
|
|
|
{
|
2025-12-24 22:08:37 +11:00
|
|
|
|
public class RenderContext
|
|
|
|
|
|
{
|
|
|
|
|
|
public PrimitiveDrawingCore DrawingCore { get; }
|
2026-01-05 03:57:09 +11:00
|
|
|
|
public IStorageProvider StorageProvider { get => DrawingCore.StorageProvider; }
|
2025-12-24 22:08:37 +11:00
|
|
|
|
public SKCanvas canvas { get => DrawingCore.canvas; }
|
2026-01-01 23:02:12 +11:00
|
|
|
|
public float LogicalW;
|
|
|
|
|
|
public float LogicalH;
|
2025-12-24 22:08:37 +11:00
|
|
|
|
public RenderContext(PrimitiveDrawingCore core)
|
2025-12-14 00:25:51 +11:00
|
|
|
|
{
|
2025-12-24 22:08:37 +11:00
|
|
|
|
this.DrawingCore = core;
|
|
|
|
|
|
}
|
2025-12-25 23:00:26 +11:00
|
|
|
|
public SKPoint TranslatePoint(float x, float y)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new SKPoint(x * DrawingCore.Width, y * DrawingCore.Height);
|
|
|
|
|
|
}
|
2025-12-28 23:03:33 +11:00
|
|
|
|
public SKPoint TranslatePoint(SKPoint point)
|
|
|
|
|
|
{
|
|
|
|
|
|
return TranslatePoint(point.X, point.Y);
|
|
|
|
|
|
}
|
2026-01-01 23:02:12 +11:00
|
|
|
|
public float TranslateSize(float s)
|
|
|
|
|
|
{
|
2026-01-02 03:24:33 +11:00
|
|
|
|
return (float)(s * Math.Sqrt(DrawingCore.Width * DrawingCore.Width + DrawingCore.Height * DrawingCore.Height) / Math.Sqrt(LogicalH * LogicalH + LogicalW * LogicalW));
|
2026-01-01 23:02:12 +11:00
|
|
|
|
}
|
2026-01-05 03:57:09 +11:00
|
|
|
|
public RenderContext(int W, int H, IStorageProvider StorageProvider)
|
2025-12-24 22:08:37 +11:00
|
|
|
|
{
|
2026-01-05 03:57:09 +11:00
|
|
|
|
DrawingCore = new PrimitiveDrawingCore(W, H, StorageProvider);
|
2026-01-10 03:40:54 +11:00
|
|
|
|
LogicalW=W;
|
|
|
|
|
|
LogicalH=H;
|
2025-12-14 00:25:51 +11:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-01-02 03:24:33 +11:00
|
|
|
|
[Serializable]
|
2025-12-25 23:00:26 +11:00
|
|
|
|
public class ExecuteArguments
|
|
|
|
|
|
{
|
|
|
|
|
|
public Dictionary<string, string> data = new Dictionary<string, string>();
|
2026-01-02 03:24:33 +11:00
|
|
|
|
public ExecuteArguments Clone()
|
|
|
|
|
|
{
|
|
|
|
|
|
ExecuteArguments args = new ExecuteArguments();
|
|
|
|
|
|
foreach (var item in data)
|
|
|
|
|
|
{
|
|
|
|
|
|
args.data.Add(item.Key, item.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
return args;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void MergeFrom(ExecuteArguments args)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var item in args.data)
|
|
|
|
|
|
{
|
|
|
|
|
|
args.data.Add(item.Key, item.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-25 23:00:26 +11:00
|
|
|
|
}
|
2025-12-14 00:25:51 +11:00
|
|
|
|
}
|