Example #1
0
        public static bool PlotTileTale(Vector2 start, Vector2 end, float width, Utils.PerLinePoint plot)
        {
            float   halfWidth  = width / 2f;
            Vector2 vector2_1  = end - start;
            Vector2 vector2_2  = vector2_1 / vector2_1.Length();
            Vector2 perpOffset = new Vector2(-vector2_2.Y, vector2_2.X);
            Point   pointStart = Utils.ToTileCoordinates(start);
            Point   point1     = Utils.ToTileCoordinates(end);
            int     length     = 0;

            Utils.PlotLine(pointStart.X, pointStart.Y, point1.X, point1.Y, (Utils.PerLinePoint)((x, y) =>
            {
                ++length;
                return(true);
            }), true);
            --length;
            int curLength = 0;

            return(Utils.PlotLine(pointStart.X, pointStart.Y, point1.X, point1.Y, (Utils.PerLinePoint)((x, y) =>
            {
                float num = (float)(1.0 - (double)curLength / (double)length);
                ++curLength;
                Point point2 = Utils.ToTileCoordinates(start - perpOffset * halfWidth * num);
                Point point3 = Utils.ToTileCoordinates(start + perpOffset * halfWidth * num);
                Point point4 = new Point(point2.X - pointStart.X, point2.Y - pointStart.Y);
                Point point5 = new Point(point3.X - pointStart.X, point3.Y - pointStart.Y);
                return Utils.PlotLine(x + point4.X, y + point4.Y, x + point5.X, y + point5.Y, plot, false);
            }), true));
        }
Example #2
0
        public static bool PlotTileLine(Vector2 start, Vector2 end, float width, Utils.PerLinePoint plot)
        {
            float   num           = width / 2f;
            Vector2 vector2_1     = end - start;
            Vector2 vector2_2     = vector2_1 / vector2_1.Length();
            Vector2 vector2_3     = new Vector2(-vector2_2.Y, vector2_2.X) * num;
            Point   point1        = Utils.ToTileCoordinates(start - vector2_3);
            Point   point2        = Utils.ToTileCoordinates(start + vector2_3);
            Point   point3        = Utils.ToTileCoordinates(start);
            Point   point4        = Utils.ToTileCoordinates(end);
            Point   lineMinOffset = new Point(point1.X - point3.X, point1.Y - point3.Y);
            Point   lineMaxOffset = new Point(point2.X - point3.X, point2.Y - point3.Y);

            return(Utils.PlotLine(point3.X, point3.Y, point4.X, point4.Y, (Utils.PerLinePoint)((x, y) => Utils.PlotLine(x + lineMinOffset.X, y + lineMinOffset.Y, x + lineMaxOffset.X, y + lineMaxOffset.Y, plot, false)), true));
        }