Working on the progrart functions.

This commit is contained in:
Creeper Lv
2025-12-25 23:00:26 +11:00
parent 2d2fec0bed
commit 18b7b00fc3
17 changed files with 400 additions and 96 deletions

View 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) { }
}
}

View 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,
}
);
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Progrart.Core.Graphics
{
public enum ShaderType
{
LinearGradient,
RadialGradient,
Picture,
}
}

View File

@@ -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);
}
}
}
}