using Annulus; using Azimuth; using Blacklight.Core; using Blacklight.Core.Drawables; using Prism; namespace Glass.Blacklight { /// /// Draws a flat rectangle the way a SolidColorMaterial does. /// public static class SolidRect { /// /// Draws in , cut down to what /// lets show. /// public static void Draw(Cel context, Color color, Rect rect, in DrawState drawState) { if (rect.Width == 0 || rect.Height == 0) { return; } if (!(drawState.VisibleWithin(rect) is OrientedBox visible)) { return; } var rectangle = new Rectangle { InsideColor = color }; // A tilted visible part is drawn as a tilted rectangle. A rectangle's model space is stretched, so a clip // window tilted inside it would not stay a box. if (!visible.TryGetRect(out Rect upright)) { Vector halfSide = visible.SideOffset * 0.5; Vector halfCross = visible.CrossOffset * 0.5; context.AddEntity(rectangle, drawState.ModelToWorld * new AffineMatrix(halfSide, halfCross, visible.Origin + halfSide + halfCross)); return; } context.AddEntity(rectangle, drawState.ModelToWorld * Rectangle.ModelToWorld( new Vector(upright.Width, upright.Height), position: upright.TopLeft, anchor: Rectangle.TopLeft)); } } }