Rectangle now have a IsStoke property.
Added math functions to ExecutionEngine.
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Progrart.Core.Graphics
|
||||
SKPoint Start;
|
||||
SKPoint Size;
|
||||
SKColorF Color;
|
||||
bool IsStroke;
|
||||
SKShader? shader = null;
|
||||
public override void SetupProperties(Engine engine)
|
||||
{
|
||||
@@ -26,6 +27,7 @@ namespace Progrart.Core.Graphics
|
||||
__object.Set("Position", point);
|
||||
}
|
||||
__object.Set("StrokeWidth", 1);
|
||||
__object.Set("IsStroke", true);
|
||||
__object.Set("Color", ProgrartFunctions.color(engine, 1, 1, 1, 1));
|
||||
{
|
||||
JsObject point = new JsObject(engine);
|
||||
@@ -42,6 +44,7 @@ namespace Progrart.Core.Graphics
|
||||
if (__object is not null)
|
||||
{
|
||||
StrokeWidth = (float)__object.Get("StrokeWidth").AsNumber();
|
||||
IsStroke = (bool)__object.Get("IsStroke").AsBoolean();
|
||||
{
|
||||
if (__object.Get("Position") is JsObject Start)
|
||||
{
|
||||
@@ -79,7 +82,8 @@ namespace Progrart.Core.Graphics
|
||||
{
|
||||
ColorF = Color,
|
||||
StrokeWidth = context.TranslateSize(StrokeWidth),
|
||||
Shader = shader
|
||||
Shader = shader,
|
||||
IsStroke = true
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Jint;
|
||||
using Jint.Native;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Progrart.Core.Graphics
|
||||
{
|
||||
@@ -24,6 +25,7 @@ namespace Progrart.Core.Graphics
|
||||
float rotate;
|
||||
void Transform(RenderContext context)
|
||||
{
|
||||
Trace.WriteLine($"Visual Root: Rotation:{rotate}");
|
||||
context.canvas.Translate(tx, ty);
|
||||
context.canvas.RotateDegrees(rotate, context.DrawingCore.Width / 2, context.DrawingCore.Height / 2);
|
||||
if (scale != 1)
|
||||
@@ -33,7 +35,7 @@ namespace Progrart.Core.Graphics
|
||||
{
|
||||
if (scale != 1)
|
||||
context.canvas.Scale(1 / scale, 1 / scale, context.DrawingCore.Width / 2, context.DrawingCore.Height / 2);
|
||||
context.canvas.RotateDegrees(rotate, context.DrawingCore.Width / 2, context.DrawingCore.Height / 2);
|
||||
context.canvas.RotateDegrees(-rotate, context.DrawingCore.Width / 2, context.DrawingCore.Height / 2);
|
||||
context.canvas.Translate(-tx, -ty);
|
||||
}
|
||||
public override void LoadProperties()
|
||||
@@ -41,20 +43,20 @@ namespace Progrart.Core.Graphics
|
||||
base.LoadProperties();
|
||||
if (__object is null) return;
|
||||
{
|
||||
if (__object.Get("translate") is JsObject translate)
|
||||
if (__object.Get("Translate") is JsObject translate)
|
||||
{
|
||||
tx = (float)translate.Get("x").AsNumber();
|
||||
ty = (float)translate.Get("y").AsNumber();
|
||||
}
|
||||
}
|
||||
{
|
||||
scale = (float)__object.Get("scale").AsNumber();
|
||||
scale = (float)__object.Get("Scale").AsNumber();
|
||||
}
|
||||
{
|
||||
rotate = (float)__object.Get("rotation").AsNumber();
|
||||
rotate = (float)__object.Get("Rotation").AsNumber();
|
||||
}
|
||||
w = (float)__object.Get("width").AsNumber();
|
||||
h = (float)__object.Get("height").AsNumber();
|
||||
w = (float)__object.Get("Width").AsNumber();
|
||||
h = (float)__object.Get("Height").AsNumber();
|
||||
}
|
||||
public override void Render(RenderContext context)
|
||||
{
|
||||
@@ -76,16 +78,16 @@ namespace Progrart.Core.Graphics
|
||||
JsObject point = new JsObject(engine);
|
||||
point.Set("x", 0);
|
||||
point.Set("y", 0);
|
||||
__object.Set("translate", point);
|
||||
__object.Set("Translate", point);
|
||||
}
|
||||
{
|
||||
__object.Set("scale", 1);
|
||||
__object.Set("Scale", 1);
|
||||
}
|
||||
{
|
||||
__object.Set("rotation", 0);
|
||||
__object.Set("Rotation", 0);
|
||||
}
|
||||
__object.Set("width", 1);
|
||||
__object.Set("height", 1);
|
||||
__object.Set("Width", 1);
|
||||
__object.Set("Height", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user