Working on the project editor.
Implemented a very basic version of command line tool.
This commit is contained in:
@@ -4,7 +4,7 @@ using SkiaSharp;
|
||||
|
||||
namespace Progrart.Core.Graphics
|
||||
{
|
||||
public class Path : BaseElement
|
||||
public class Path : BaseElement
|
||||
{
|
||||
SKPath path = new SKPath();
|
||||
public SKPath RealPath => path;
|
||||
@@ -16,10 +16,12 @@ namespace Progrart.Core.Graphics
|
||||
{
|
||||
__object.Set("line_to", JsValue.FromObject(engine, (object)line_to));
|
||||
__object.Set("move_to", JsValue.FromObject(engine, (object)move_to));
|
||||
__object.Set("quad_to", JsValue.FromObject(engine, (object)quad_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));
|
||||
void quad_to(float x0, float y0, float x1, float y1) => Commands.Add(new QuadToCmd(x0, y0, x1, y1));
|
||||
|
||||
public override void Render(RenderContext context)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Progrart.Core.Graphics
|
||||
{
|
||||
public class PathCmd
|
||||
public class PathCmd
|
||||
{
|
||||
public virtual void ApplyCommand(RenderContext context, SKPath path) { }
|
||||
}
|
||||
@@ -17,6 +17,21 @@ namespace Progrart.Core.Graphics
|
||||
path.LineTo(pos);
|
||||
}
|
||||
}
|
||||
public class QuadToCmd(float x1, float y1, float x2, float y2) : PathCmd
|
||||
{
|
||||
public readonly float x1 = x1;
|
||||
public readonly float y1 = y1;
|
||||
private readonly float x2 = x2;
|
||||
private readonly float y2 = y2;
|
||||
|
||||
public override void ApplyCommand(RenderContext context, SKPath path)
|
||||
{
|
||||
base.ApplyCommand(context, path);
|
||||
var pos = context.TranslatePoint(x1, y1);
|
||||
var pos2 = context.TranslatePoint(x2, y2);
|
||||
path.QuadTo(pos, pos2);
|
||||
}
|
||||
}
|
||||
public class MoveToCmd(float x, float y) : PathCmd
|
||||
{
|
||||
public readonly float x = x;
|
||||
|
||||
@@ -9,8 +9,6 @@ namespace Progrart.Core.Graphics
|
||||
public class PathElement : BaseElement
|
||||
{
|
||||
float StrokeWidth;
|
||||
SKPoint Start;
|
||||
SKPoint End;
|
||||
SKColorF Color;
|
||||
SKShader? shader = null;
|
||||
public override void SetupProperties(Engine engine)
|
||||
|
||||
Reference in New Issue
Block a user