Esempio n. 1
0
 public static void DrawCircleQuarters
 (
     this SpriteBatch spriteBatch,
     Point2 center,
     float radius,
     DiagonalDirections2D directions,
     Color color,
     float stretch_x = 1f,
     float stretch_y = 1f,
     float thickness = 1f
 )
 {
     if (directions.BottomRight)
     {
         _DrawCircleQuarter(spriteBatch, center, radius, color, stretch_x, stretch_y, thickness);
     }
     if (directions.BottomLeft)
     {
         _DrawCircleQuarter(spriteBatch, center, radius, color, -stretch_x, stretch_y, thickness);
     }
     if (directions.TopRight)
     {
         _DrawCircleQuarter(spriteBatch, center, radius, color, stretch_x, -stretch_y, thickness);
     }
     if (directions.TopLeft)
     {
         _DrawCircleQuarter(spriteBatch, center, radius, color, -stretch_x, -stretch_y, thickness);
     }
 }
Esempio n. 2
0
        protected override void Initialize()
        {
            Parent.SendToContainer();
            Parent.ParentWidget.Insert(0, NewWidget);

            _new_widget_snapping_policy_prev = NewWidget.SnappingPolicy;
            NewWidget.SnappingPolicy         = DiagonalDirections2D.None;

            var new_widget_target_area = NewWidget.Area;

            NewWidget.Area = NewWidgetStart.GetLocation(Parent, NewWidget);

            _old_widget_area = new PropertyTransitionAction <RectangleF>(nameof(Widget.Area), OldWidgetEnd.GetLocation(Parent, Parent), OldWidgetMovement);
            _new_widget_area = new PropertyTransitionAction <RectangleF>(nameof(Widget.Area), new_widget_target_area, NewWidgetMovement);

            Parent.Actions.Add(_old_widget_area);
            NewWidget.Actions.Add(_new_widget_area);
        }
Esempio n. 3
0
        public static RectangleF BorderingInside(
            this RectangleF inner,
            RectangleF outer,
            DiagonalDirections2D sides
            )
        {
            inner.Position = outer.Position.WithOffset(inner.Position);

            var snapping = sides.ToPerpendicular();

            if (snapping.Left && !snapping.Right)
            {
                inner.X = outer.X; // left
            }
            if (!snapping.Left && snapping.Right)
            {
                inner.X = outer.X + outer.Width - inner.Width; // right
            }
            if (snapping.Left && snapping.Right)               // left and right
            {
                inner.X     = outer.X;
                inner.Width = outer.Width;
            }

            if (snapping.Up && !snapping.Down)
            {
                inner.Y = outer.Y; // up
            }
            if (!snapping.Up && snapping.Down)
            {
                inner.Y = outer.Y + outer.Height - inner.Height; // down
            }
            if (snapping.Up && snapping.Down)                    // up and down
            {
                inner.Y      = outer.Y;
                inner.Height = outer.Height;
            }

            return(inner);
        }