A Smoll game engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

using System.Numerics;
using Raylib_cs;
namespace Smoll.Ex1 {
class RectangleGizmoComponent : Smoll.Component {
Complex size;
Color color;
Transform2DComponent? ownerTransform;
public RectangleGizmoComponent(int width, int height, Color color)
{
this.size = width + Complex.ImaginaryOne*height;
this.color = color;
}
public override void OnAttached() {
ownerTransform = owner.GetComponent<Transform2DComponent>();
}
public override void Draw(Smoll.Layer.DrawMode drawMode) {
ownerTransform ??= owner.GetComponent<Transform2DComponent>();
ownerTransform ??= new Transform2DComponent();
var tr = ownerTransform.AbsoluteTransform();
Raylib.DrawRectanglePro(
new Rectangle(
(float)tr.position.Real,
(float)tr.position.Imaginary,
(float)(size.Real*tr.scale),
(float)(size.Imaginary*tr.scale)
),
new Vector2(
(float)(0),
(float)(0)
),
tr.angle*180f/MathF.PI,
color
);
}
}
}