Working on the progrart functions.
This commit is contained in:
24
Progrart.Core/Graphics/BaseElement.cs
Normal file
24
Progrart.Core/Graphics/BaseElement.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Jint;
|
||||
using Jint.Native;
|
||||
|
||||
namespace Progrart.Core.Graphics
|
||||
{
|
||||
public class BaseElement
|
||||
{
|
||||
public List<BaseElement> Children = new List<BaseElement>();
|
||||
public JsObject? __object = null;
|
||||
public virtual void Add(BaseElement element)
|
||||
{
|
||||
Children.Add(element);
|
||||
}
|
||||
public virtual void Remove(BaseElement element)
|
||||
{
|
||||
Children.Remove(element);
|
||||
}
|
||||
public virtual void Render(RenderContext context)
|
||||
{
|
||||
}
|
||||
public virtual void LoadProperties() { }
|
||||
public virtual void SetupProperties(Engine engine) { }
|
||||
}
|
||||
}
|
||||
65
Progrart.Core/Graphics/Line.cs
Normal file
65
Progrart.Core/Graphics/Line.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using Jint;
|
||||
using Jint.Native;
|
||||
using Progrart.Core.JSExecution;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Progrart.Core.Graphics
|
||||
{
|
||||
public class Line : BaseElement
|
||||
{
|
||||
float Size;
|
||||
float StartX;
|
||||
float StartY;
|
||||
float EndX;
|
||||
float EndY;
|
||||
float ColorR;
|
||||
float ColorG;
|
||||
float ColorB;
|
||||
float ColorA;
|
||||
public override void SetupProperties(Engine engine)
|
||||
{
|
||||
base.SetupProperties(engine);
|
||||
if (__object != null)
|
||||
{
|
||||
{
|
||||
JsObject point = new JsObject(engine);
|
||||
point.Set("x", 0);
|
||||
point.Set("y", 0);
|
||||
__object.Set("Start", point);
|
||||
}
|
||||
__object.Set("Size", 1);
|
||||
__object.Set("Color", ProgrartFunctions.color(engine, 1, 1, 1, 1));
|
||||
{
|
||||
JsObject point = new JsObject(engine);
|
||||
point.Set("x", 0);
|
||||
point.Set("y", 0);
|
||||
__object.Set("End", point);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public override void LoadProperties()
|
||||
{
|
||||
if (__object is not null)
|
||||
{
|
||||
Size = (float)__object.Get("Size").AsNumber();
|
||||
}
|
||||
}
|
||||
public override void Render(RenderContext context)
|
||||
{
|
||||
base.Render(context);
|
||||
context.DrawingCore.canvas.DrawLine(
|
||||
context.TranslatePoint((float)StartX, (float)StartY),
|
||||
context.TranslatePoint((float)StartX, (float)StartY),
|
||||
new SkiaSharp.SKPaint()
|
||||
{
|
||||
ColorF = new SkiaSharp.SKColorF(ColorR, ColorG, ColorB, ColorA),
|
||||
StrokeWidth = Size,
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Progrart.Core/Graphics/ShaderType.cs
Normal file
13
Progrart.Core/Graphics/ShaderType.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Progrart.Core.Graphics
|
||||
{
|
||||
public enum ShaderType
|
||||
{
|
||||
LinearGradient,
|
||||
RadialGradient,
|
||||
Picture,
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,44 @@
|
||||
using Jint.Native;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Jint;
|
||||
using Jint.Native;
|
||||
|
||||
namespace Progrart.Core.Graphics
|
||||
{
|
||||
public class BaseElement
|
||||
{
|
||||
public JsObject? __object = null;
|
||||
public virtual void Add(BaseElement element) { }
|
||||
public virtual void Remove(BaseElement element) { }
|
||||
public virtual void Render(RenderContext context)
|
||||
{
|
||||
}
|
||||
public virtual void SetProperty(string key, string value)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
public class ImageRoot : BaseElement
|
||||
{
|
||||
}
|
||||
public class VisualRoot : BaseElement
|
||||
{
|
||||
public override void Render(RenderContext context)
|
||||
{
|
||||
base.Render(context);
|
||||
foreach (var item in Children)
|
||||
{
|
||||
item.Render(context);
|
||||
}
|
||||
}
|
||||
public override void SetupProperties(Engine engine)
|
||||
{
|
||||
base.SetupProperties(engine);
|
||||
if (__object != null)
|
||||
{
|
||||
{
|
||||
JsObject point = new JsObject(engine);
|
||||
point.Set("x", 0);
|
||||
point.Set("y", 0);
|
||||
__object.Set("translate", point);
|
||||
}
|
||||
{
|
||||
JsObject point = new JsObject(engine);
|
||||
point.Set("x", 0);
|
||||
point.Set("y", 0);
|
||||
__object.Set("scale", point);
|
||||
}
|
||||
{
|
||||
__object.Set("rotation", 0);
|
||||
}
|
||||
__object.Set("Width", 1);
|
||||
__object.Set("Height", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user