Пример #1
0
        /// <summary>
        /// This methods draws a trapezoid whose 90° angle is in the left side.
        /// </summary>
        /// <param name="position">The topLeft point of the trapezoid</param>
        /// <param name="size">The <b>whole size</b> of the trapezoid</param>
        /// <param name="triangleWidth">The extra width of the greater base side</param>
        /// <param name="isTriangleUpside">If the triangle part is to be drawn upside</param>
        /// <param name="isShaded">If shading is to be applied to the trapezoid polygons</param>
        /// <param name="color">Color of the trapezoid's inner area. The specified ShadeVertices
        /// delegate will then proceed to create a shaded version.</param>
        /// <param name="shadeMode">ShadeVertices delegate used.</param>
        /// <returns>A Trapezoidal ShapeDescriptor object.</returns>
        public static ShapeDescriptor DrawLeftTrapezoid(Vector2 position, Size size,
                                                        int triangleWidth, bool isTriangleUpside,
                                                        Color color, int borderSize,
                                                        Graphics.ShadingMode shadeMode)
        {
            CustomVertex.TransformedColored[] vertices = new CustomVertex.TransformedColored[5];
            int[]   indices = new int[9];
            Vector2 topLeft = new Vector2(position.X + triangleWidth, position.Y);

            Size innerSize = new Size(size.Width - borderSize, size.Height - borderSize);

            ShapeDescriptor sTrapezoid;

            int width  = innerSize.Width;
            int height = innerSize.Height;

            int[] colors = shadeMode(color);

            int colorTopLeft     = colors[0];
            int colorTopRight    = colors[1];
            int colorBottomleft  = colors[2];
            int colorBottomRight = colors[3];

            vertices[0] = new CustomVertex.TransformedColored(topLeft.X + innerSize.Width, topLeft.Y, 0, 1, colorTopRight);
            vertices[1] = new CustomVertex.TransformedColored(topLeft.X + innerSize.Width, topLeft.Y + innerSize.Height, 0, 1, colorBottomRight);
            vertices[2] = new CustomVertex.TransformedColored(topLeft.X, topLeft.Y + innerSize.Height, 0, 1, colorBottomleft);
            vertices[4] = new CustomVertex.TransformedColored(topLeft.X, topLeft.Y, 0, 1, colorTopLeft);


            if (isTriangleUpside)
            {
                vertices[3] = new CustomVertex.TransformedColored(topLeft.X - triangleWidth, topLeft.Y + innerSize.Height, 0, 1, colorBottomleft);
            }
            else
            {
                vertices[3] = new CustomVertex.TransformedColored(topLeft.X - triangleWidth, topLeft.Y, 0, 1, colorTopLeft);
            }

            indices[0] = 0;
            indices[1] = 2;
            indices[2] = 4;
            indices[3] = 0;
            indices[4] = 1;
            indices[5] = 2;
            indices[6] = 3;
            indices[7] = 4;
            indices[8] = 2;


            sTrapezoid = new ShapeDescriptor(3, vertices, indices);
            return(sTrapezoid);
        }
Пример #2
0
        /// <summary>
        /// This methods draws a trapezoid whose 90° angle is in the right side.
        /// </summary>
        /// <param name="position">The topLeft point of the trapezoid</param>
        /// <param name="size">The <b>whole size</b> of the trapezoid</param>
        /// <param name="triangleWidth">The extra width of the greater base side</param>
        /// <param name="isTriangleUpside">If the triangle part is to be drawn upside</param>
        /// <param name="isShaded">If shading is to be applied to the trapezoid polygons</param>
        /// <param name="color">Color of the trapezoid's inner area. The specified ShadeVertices
        /// delegate will then proceed to create a shaded version.</param>
        /// <param name="borderSize">Size in pixels of the border.</param>
        /// <param name="borderColor">Average color of the border.</param>
        /// <param name="rectangleBorders">Which borders of the rectangular part of the outline to draw.</param>
        /// <param name="triangleBorders">Which borders of the triangular part of the outline to draw.</param>
        /// <param name="shadeMode">ShadeVertices delegate used.</param>
        /// <returns>A Trapezoidal ShapeDescriptor object.</returns>
        public static ShapeDescriptor DrawFullRightTrapezoid(Vector2 position, Size size,
                                                             int triangleWidth, bool isTriangleUpside,
                                                             Color color,
                                                             int borderSize, Color borderColor,
                                                             BorderStyle style, Border rectangleBorders, Border triangleBorders,
                                                             Graphics.ShadingMode shadeMode)
        {
            ShapeDescriptor sTrapezoid = DrawRightTrapezoid(position, size, triangleWidth, isTriangleUpside,
                                                            color, borderSize, shadeMode);
            ShapeDescriptor sOutline = DrawRightTrapezoidalOutline(position, size, triangleWidth, isTriangleUpside,
                                                                   color, borderSize, borderColor, style, rectangleBorders, triangleBorders);

            return(ShapeDescriptor.Join(sTrapezoid, sOutline));
        }