Exemplo n.º 1
0
        public void Inflate_AllMethods()
        {
            Rect2 rect = new Rect2(10, 20, 50, 30);

            Rect2 inflated = new Rect2(0, 0, 70, 70);

            Assert.Equal(inflated, rect.Inflate(10, 20));
            Assert.Equal(inflated, rect.Inflate(new Vector2(10, 20)));
            Assert.Equal(inflated, Rect2.Inflate(rect, 10, 20));
            Assert.Equal(inflated, Rect2.Inflate(rect, new Vector2(10, 20)));
        }
Exemplo n.º 2
0
        public void Arrange(Vector2 center, float radius)
        {
            renderRadius = radius;
            renderCenter = center;

            renderBounds = Rect2.Inflate(new Rect2(center, Vector2.Zero), radius, radius);
        }
Exemplo n.º 3
0
        public static CanvasGeometry ComputeHullGeometry(ICanvasResourceCreator resourceCreator, Win2DScene scene, Win2DRenderNode renderNode)
        {
            Guard.NotNull(scene, nameof(scene));
            Guard.NotNull(renderNode, nameof(renderNode));
            Guard.NotNull(resourceCreator, nameof(resourceCreator));

            var node = renderNode.Node;

            if (!node.HasChildren || node.IsCollapsed)
            {
                return(null);
            }

            IList <Rect2> childBounds =
                node.AllChildren()
                .Select(x => (Win2DRenderNode)scene.FindRenderNode(x)).Union(new[] { renderNode }).Where(x => x.IsVisible)
                .Select(x => Rect2.Inflate(new Rect2(x.TargetLayoutPosition, x.RenderSize), new Vector2(Padding, Padding)))
                .ToList();

            if (childBounds.Count <= 0)
            {
                return(null);
            }

            var hull = ConvexHull.Compute(childBounds);

            var points = RoundCorners(hull);

            return(BuildGeometry(resourceCreator, points));
        }
Exemplo n.º 4
0
        private void UpdateBounds()
        {
            renderBounds = new Rect2(renderPosition, renderSize);

            occlusionBounds = renderBounds.Inflate(renderBounds.Size * 0.5f);
        }