2026-01-11 02:15:55 +11:00
|
|
|
|
using Jint;
|
|
|
|
|
|
using Jint.Native;
|
|
|
|
|
|
using SkiaSharp;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Progrart.Core.Graphics
|
|
|
|
|
|
{
|
2026-01-11 03:54:14 +11:00
|
|
|
|
public class Path : BaseElement
|
2026-01-11 02:15:55 +11:00
|
|
|
|
{
|
|
|
|
|
|
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));
|
2026-01-11 03:54:14 +11:00
|
|
|
|
__object.Set("quad_to", JsValue.FromObject(engine, (object)quad_to));
|
2026-01-11 02:15:55 +11:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
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));
|
2026-01-11 03:54:14 +11:00
|
|
|
|
void quad_to(float x0, float y0, float x1, float y1) => Commands.Add(new QuadToCmd(x0, y0, x1, y1));
|
2026-01-11 02:15:55 +11:00
|
|
|
|
|
|
|
|
|
|
public override void Render(RenderContext context)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Render(context);
|
|
|
|
|
|
foreach (var item in Commands)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.ApplyCommand(context, this.path);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|