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(); } public override void Draw(Smoll.Layer.DrawMode drawMode) { ownerTransform ??= owner.GetComponent(); 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 ); } } }