Beispiel #1
0
        private void SetPoint(RenderedPolygon renderedPolygon, Vector2F point, float size, Color color)
        {
            Span <Vector2F> points = stackalloc Vector2F[4];

            points[0] = point + new Vector2F(-1f, -1f) * size / 2f;
            points[1] = point + new Vector2F(1f, -1f) * size / 2f;
            points[2] = point + new Vector2F(1f, 1f) * size / 2f;
            points[3] = point + new Vector2F(-1f, 1f) * size / 2f;

            Engine.Vector2FArrayCache.FromSpan(points);
            renderedPolygon.CreateVertexesByVector2F(Engine.Vector2FArrayCache);
            renderedPolygon.OverwriteVertexesColor(color);
            renderedPolygon.SetDefaultIndexBuffer();
        }
        private void SetPoint(RenderedPolygon renderedPolygon, Vector2F point, float size, Color color)
        {
            Span <Vector2F> points = stackalloc Vector2F[4];

            points[0] = point + new Vector2F(-1f, -1f) * size / 2f;
            points[1] = point + new Vector2F(1f, -1f) * size / 2f;
            points[2] = point + new Vector2F(1f, 1f) * size / 2f;
            points[3] = point + new Vector2F(-1f, 1f) * size / 2f;

            var array = Vector2FArray.Create(points);

            renderedPolygon.CreateVertexesByVector2F(array);
            renderedPolygon.OverwriteVertexesColor(color);
        }
Beispiel #3
0
        private void SetLine(RenderedPolygon renderedPolygon, Vector2F point1, Vector2F point2, Color color)
        {
            Span <Vector2F> positions = stackalloc Vector2F[4];
            var             vec       = point2 - point1;

            var side = new Vector2F(vec.Y, -vec.X).Normal;

            positions[0] = point1 - side;
            positions[1] = point1 + side;
            positions[2] = point2 + side;
            positions[3] = point2 - side;

            Engine.Vector2FArrayCache.FromSpan(positions);
            renderedPolygon.CreateVertexesByVector2F(Engine.Vector2FArrayCache);
            renderedPolygon.OverwriteVertexesColor(color);
            renderedPolygon.SetDefaultIndexBuffer();
        }
        //internal void Update()
        //{
        //    var origin = _TransformNode.Position;

        //    UpdateSizeBox(origin);
        //    UpdatePivot();
        //    UpdateMargin(origin);
        //    UpdateAnchors();
        //}

        //private void UpdateSizeBox(Vector2F origin)
        //{
        //    var points = new Vector2F[4];

        //    points[0] = origin + new Vector2F();
        //    points[1] = origin + new Vector2F(_TransformNode.Size.X, 0);
        //    points[2] = origin + _TransformNode.Size;
        //    points[3] = origin + new Vector2F(0, _TransformNode.Size.Y);

        //    for (int i = 0; i < points.Length; i++)
        //    {
        //        var point1 = points[i];
        //        var point2 = points[(i + 1) % points.Length];

        //        SetLine(_SizeBoxLines[i], point1, point2, new Color(255, 128, 0));
        //    }
        //}

        //private void UpdatePivot()
        //{
        //    SetPoint(_PivotBox, _TransformNode.Position, 5f, new Color(255, 128, 0));
        //}

        //private void UpdateMargin(Vector2F origin)
        //{
        //    var ancestorSize = GetAncestorSize();

        //    SetLine(_LeftTop,
        //        ancestorSize * _TransformNode.AnchorMin,
        //        origin, new Color(255, 100, 100));
        //    SetLine(_RightBottom,
        //        ancestorSize * _TransformNode.AnchorMax,
        //        origin + _TransformNode.Size, new Color(100, 100, 255));
        //}

        //private void UpdateAnchors()
        //{
        //    var ancestorSize = GetAncestorSize();

        //    SetPoint(_AnchorMin, ancestorSize * _TransformNode.AnchorMin, 4, new Color(255, 0, 0));
        //    SetPoint(_AnchorMax, ancestorSize * _TransformNode.AnchorMax, 4, new Color(0, 0, 255));
        //}

        private void SetLine(RenderedPolygon renderedPolygon, Vector2F point1, Vector2F point2, Color color)
        {
            Span <Vector2F> positions = stackalloc Vector2F[4];
            var             vec       = point2 - point1;

            var side = new Vector2F(vec.Y, -vec.X).Normal;

            positions[0] = point1 - side;
            positions[1] = point1 + side;
            positions[2] = point2 + side;
            positions[3] = point2 - side;

            var array = Vector2FArray.Create(positions);

            renderedPolygon.CreateVertexesByVector2F(array);
            renderedPolygon.OverwriteVertexesColor(color);
        }