Exemplo n.º 1
0
        public static ShapeDescriptor DrawPolyLine(int width, Color color, bool closed, params Vector2[] points)
        {
            CustomVertex.TransformedColored[] vertices = new CustomVertex.TransformedColored[4];
            ShapeDescriptor[] segments;

            int col1 = color.ToArgb();

            if (closed)
            {
                segments = new ShapeDescriptor[points.Length];
                for (int i = 0; i < points.Length - 1; i++)
                {
                    segments[i] = DrawLine(width, color, points[i], points[i + 1]);
                }
                segments[points.Length - 1] = DrawLine(width, color, points[points.Length - 1], points[0]);
            }
            else
            {
                segments = new ShapeDescriptor[points.Length - 1];
                for (int i = 0; i < points.Length - 1; i++)
                {
                    segments[i] = DrawLine(width, color, points[i], points[i + 1]);
                }
            }
            return(ShapeDescriptor.Join(segments));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Draws a circle with an outline.
 /// </summary>
 /// <param name="center">The center.</param>
 /// <param name="radius">The radius.</param>
 /// <param name="outlineRadius">The outline radius.</param>
 /// <param name="slices">The slices.</param>
 /// <param name="borderSize">Size of the border.</param>
 /// <param name="color">The color.</param>
 /// <param name="borderColor">Color of the border.</param>
 /// <returns>A full Circular ShapeDescriptor object.</returns>
 public static ShapeDescriptor DrawFullCircle(Vector2 center, float radius, float outlineRadius,
                                              int slices, int borderSize, Color color, Color borderColor)
 {
     return(ShapeDescriptor.Join(
                DrawCircle(center, radius, slices, color),
                DrawCircularOutline(center, outlineRadius, slices, borderSize, borderColor)));
 }
Exemplo n.º 3
0
 public static ShapeDescriptor DrawFullRectangle(Vector2 position, Size size, Color color, ShadingMode shadeMode,
                                                 int borderSize, Color borderColor, BorderStyle style, Border borders)
 {
     return(ShapeDescriptor.Join(
                DrawRectangle(new Vector2(position.X + borderSize, position.Y + borderSize),
                              new Size(size.Width - borderSize * 2, size.Height - borderSize * 2),
                              color,
                              shadeMode),
                DrawRectangularOutline(position, size, borderSize, borderColor, style, borders)));
 }
Exemplo n.º 4
0
        /// <summary>
        /// Draws a left trapezoidal outline.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="size">The size.</param>
        /// <param name="triangleWidth">Width of the triangle.</param>
        /// <param name="isTriangleUpside">Ff set to <c>true</c> the triangle will be upside.</param>
        /// <param name="color">The color.</param>
        /// <param name="borderSize">Size of the border.</param>
        /// <param name="borderColor">Color of the border.</param>
        /// <param name="style">The style.</param>
        /// <param name="rectangleBorders">The rectangle borders.</param>
        /// <param name="triangleBorders">The triangle borders.</param>
        /// <returns>A left trapezoidal outline ShapeDescriptor object.</returns>
        public static ShapeDescriptor DrawLeftTrapezoidalOutline(Vector2 position, Size size,
                                                                 int triangleWidth, bool isTriangleUpside, Color color, int borderSize, Color borderColor,
                                                                 BorderStyle style, Border rectangleBorders, Border triangleBorders)
        {
            Vector2 topLeft   = new Vector2(position.X + triangleWidth, position.Y);
            Size    innerSize = new Size(size.Width - borderSize, size.Height - borderSize);

            ShapeDescriptor sTriangleSide     = ShapeDescriptor.Empty;
            ShapeDescriptor sTriangleBase     = ShapeDescriptor.Empty;
            ShapeDescriptor sRectangleOutline =
                DrawRectangularOutline(topLeft, size, borderSize, borderColor, style,
                                       rectangleBorders);

            if (isTriangleUpside)
            {
                if ((triangleBorders & Border.Left) == Border.Left)
                {
                    sTriangleSide = DrawLine(borderSize,
                                             Color.FromArgb(255, ColorOperator.Scale(borderColor, lightShadeFactor)),
                                             new Vector2(topLeft.X - triangleWidth, topLeft.Y + size.Height - borderSize),
                                             new Vector2(topLeft.X, topLeft.Y + borderSize));
                }

                if ((triangleBorders & Border.Bottom) == Border.Bottom)
                {
                    sTriangleBase = DrawRectangle(
                        new Vector2(topLeft.X - triangleWidth, topLeft.Y + size.Height - borderSize),
                        new Size(triangleWidth, borderSize),
                        Color.FromArgb(255, ColorOperator.Scale(borderColor, darkShadeFactor)));
                }
            }
            else
            {
                if ((triangleBorders & Border.Left) == Border.Left)
                {
                    sTriangleSide = DrawLine(borderSize,
                                             Color.FromArgb(255, ColorOperator.Scale(borderColor, darkShadeFactor)),
                                             new Vector2(topLeft.X - triangleWidth + borderSize, topLeft.Y + (borderSize / 2)),
                                             new Vector2(topLeft.X + borderSize, topLeft.Y + innerSize.Height + (borderSize / 2)));
                }


                if ((triangleBorders & Border.Top) == Border.Top)
                {
                    sTriangleBase = DrawRectangle(
                        new Vector2(topLeft.X - triangleWidth, topLeft.Y),
                        new Size(triangleWidth, borderSize),
                        Color.FromArgb(255, ColorOperator.Scale(borderColor, lightShadeFactor)));
                }
            }

            return(ShapeDescriptor.Join(sRectangleOutline, sTriangleSide, sTriangleBase));
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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));
        }
Exemplo n.º 7
0
        public static ShapeDescriptor DrawRectangularOutline(Vector2 position,
                                                             Size size, Color borderTopAndLeft, Color borderBottomAndRight, int borderSize,
                                                             Border borders)
        {
            ShapeDescriptor vBorderTop    = ShapeDescriptor.Empty;
            ShapeDescriptor vBorderSideL  = ShapeDescriptor.Empty;
            ShapeDescriptor vBorderSideR  = ShapeDescriptor.Empty;
            ShapeDescriptor vBorderBottom = ShapeDescriptor.Empty;

            Vector2 innerPositionTopLeft = new Vector2(
                position.X + borderSize, position.Y + borderSize);

            Vector2 borderPositionTopRight = new Vector2(
                position.X + size.Width - borderSize, position.Y);

            Vector2 borderPositionBottomLeft = new Vector2(
                position.X, position.Y + size.Height - borderSize);

            Size borderTop  = new Size(size.Width, borderSize);
            Size borderSide = new Size(borderSize, size.Height);

            if ((borders & Border.Top) != 0)
            {
                vBorderTop = Graphics.DrawRectangle(
                    position, borderTop, borderTopAndLeft);
            }
            if ((borders & Border.Left) != 0)
            {
                vBorderSideL = Graphics.DrawRectangle(
                    position, borderSide, borderTopAndLeft);
            }
            if ((borders & Border.Right) != 0)
            {
                vBorderSideR = Graphics.DrawRectangle(
                    borderPositionTopRight, borderSide, borderBottomAndRight);
            }
            if ((borders & Border.Bottom) != 0)
            {
                vBorderBottom = Graphics.DrawRectangle(
                    borderPositionBottomLeft, borderTop, borderBottomAndRight);
            }

            return(ShapeDescriptor.Join(vBorderTop, vBorderSideL, vBorderSideR, vBorderBottom));
        }