예제 #1
0
        public void CreateBorder(BorderType type, Borderstyles borderStyle = Borderstyles.Thin, EWColor color = null)
        {
            if (color == null)
            {
                color = new EWColor(System.Drawing.Color.Black);
            }

            if (type.HasFlag(BorderType.Left))
            {
                AddBorder <LeftBorder>(borderStyle, color);
            }

            if (type.HasFlag(BorderType.Right))
            {
                AddBorder <RightBorder>(borderStyle, color);
            }

            if (type.HasFlag(BorderType.Top))
            {
                AddBorder <TopBorder>(borderStyle, color);
            }

            if (type.HasFlag(BorderType.Bottom))
            {
                AddBorder <BottomBorder>(borderStyle, color);
            }
        }
예제 #2
0
 public static bool HasRight(this BorderType tileType)
 {
     return(tileType.HasFlag(BorderType.Right));
 }
예제 #3
0
 public static bool HasLeft(this BorderType tileType)
 {
     return(tileType.HasFlag(BorderType.Left));
 }
예제 #4
0
 public static bool HasBottom(this BorderType tileType)
 {
     return(tileType.HasFlag(BorderType.Bottom));
 }
예제 #5
0
 public static bool HasTop(this BorderType tileType)
 {
     return(tileType.HasFlag(BorderType.Top));
 }
        private void generateHeights(float[,] border = null, BorderType borders = BorderType.None)
        {
            int step = size - 1;
            int halfStep = step / 2;
            while (halfStep != 0)
            {
                //diamond step
                for (int y = 0; y < size - 1; y += step)
                    for (int x = 0; x < size - 1; x += step)
                    {
                        float a = this.heights[x, y];
                        float b = this.heights[x + step, y];
                        float c = this.heights[x, y + step];
                        float d = this.heights[x + step, y + step];

                        this.heights[x + halfStep, y + halfStep] = (a + b + c + d) / 4.0f + randd(this.d);
                    }

                //square step
                int o = 0;
                for (int y = 0; y < size; y += halfStep, o++)
                    for (int x = (o % 2 == 0 ? halfStep : 0); x < size; x += step)
                    {
                        float a = (x - halfStep >= 0) ? heights[x - halfStep, y] : heights[x + halfStep, y];
                        float b = (y - halfStep >= 0) ? heights[x, y - halfStep] : heights[x, y + halfStep];
                        float c = (x + halfStep < this.size) ? heights[x + halfStep, y] : heights[x - halfStep, y];
                        float d = (y + halfStep < this.size) ? heights[x, y + halfStep] : heights[x, y - halfStep];

                        heights[x, y] = (a + b + d + c) / 4.0f + randd(this.d);

                        if (borders.HasFlag(BorderType.Left) && x == 0)
                            heights[x, y] = border[0, y];
                        if (borders.HasFlag(BorderType.Top) && y == 0)
                            heights[x, y] = border[1, x];
                        if (borders.HasFlag(BorderType.Right) && x == this.size - 1)
                            heights[x, y] = border[2, y];
                        if (borders.HasFlag(BorderType.Bottom) && y == this.size - 1)
                            heights[x, y] = border[3, x];
                    }

                step /= 2;
                halfStep = step/2;
                this.d *= (float)Math.Pow(2, -r);
            }
        }