Added Oval and Path. Currently Path only have move_to and line_to commands.

This commit is contained in:
Creeper Lv
2026-01-11 02:15:55 +11:00
parent b032249942
commit 609e51d375
8 changed files with 225 additions and 5 deletions

View File

@@ -0,0 +1,33 @@
using Jint;
using Jint.Native;
using SkiaSharp;
namespace Progrart.Core.Graphics
{
public class Path : BaseElement
{
SKPath path = new SKPath();
public SKPath RealPath => path;
internal List<PathCmd> Commands = new List<PathCmd>();
public override void SetupProperties(Engine engine)
{
base.SetupProperties(engine);
if (__object != null)
{
__object.Set("line_to", JsValue.FromObject(engine, (object)line_to));
__object.Set("move_to", JsValue.FromObject(engine, (object)move_to));
}
}
void line_to(float x, float y) => Commands.Add(new LineToCmd(x, y));
void move_to(float x, float y) => Commands.Add(new MoveToCmd(x, y));
public override void Render(RenderContext context)
{
base.Render(context);
foreach (var item in Commands)
{
item.ApplyCommand(context, this.path);
}
}
}
}