A Smoll game engine
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 

40 líneas
1.3 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.Real),
(float)(size.Imaginary*tr.scale.Imaginary)
),
new Vector2(
(float)(tr.anchor.Real - tr.position.Real),
(float)(tr.anchor.Imaginary - tr.position.Imaginary)
),
tr.angle,
color
);
}
}
}