Files
Progrart/Progrart.Core/RenderContext.cs
T

67 lines
1.7 KiB
C#
Raw Normal View History

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;
}
public SKBitmap? GetBitmap(string sourceFile)
{
return DrawingCore.GetBitmap(sourceFile);
}
2026-01-12 02:37:22 +11:00
public SKTypeface? GetFont(string fontName)
{
return DrawingCore.GetFont(fontName);
}
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
}