Пример #1
0
        public static void DrawImageToSurface(this Texture2D texture, CellSurface surface, Point position, Action<int, Cell, Color> cellProcessor)
        {
            Color[] pixels = new Color[texture.Width * texture.Height];
            texture.GetData<Color>(pixels);

            int startX = position.X;
            int widthCounter = 0;

            for (int i = 0; i < pixels.Length; i++)
            {
                if (widthCounter >= texture.Width)
                {
                    widthCounter = 0;
                    position.X = startX;
                    position.Y++;
                }

                if (surface.IsValidCell(position.X, position.Y))
                {
                    int destinationIndex = position.ToIndex(surface.Width);

                    cellProcessor(destinationIndex, surface[destinationIndex], pixels[i]);
                }

                position.X++;
                widthCounter++;
            }
        }
Пример #2
0
        public void Draw(CellSurface surface)
        {
            if (BorderAppearance == null)
                BorderAppearance = new CellAppearance(Color.Blue, Color.Black, 4);

            Algorithms.Circle(Center.X, Center.Y, Radius, (x, y) => { if (surface.IsValidCell(x, y)) surface.SetCellAppearance(x, y, BorderAppearance); });
        }
Пример #3
0
        private void PlotCell(CellSurface surface, int x, int y, int character, bool fillMe = false)
        {
            if (surface.IsValidCell(x, y))
            {
                var cell = surface[x, y];

                if (fillMe)
                {
                    cell.Background     = FillColor;
                    cell.Foreground     = Foreground;
                    cell.CharacterIndex = character;
                    return;
                }

                if (Foreground != Color.Transparent || DrawTransparency)
                {
                    cell.Foreground = Foreground;
                }

                if (BorderBackground != Color.Transparent || DrawTransparency)
                {
                    cell.Background = BorderBackground;
                }

                cell.CharacterIndex = character;
            }
        }
Пример #4
0
        public static void DrawImageToSurface(this Texture2D texture, CellSurface surface, Point position, Action <int, Cell, Color> cellProcessor)
        {
            Color[] pixels = new Color[texture.Width * texture.Height];
            texture.GetData <Color>(pixels);

            int startX       = position.X;
            int widthCounter = 0;

            for (int i = 0; i < pixels.Length; i++)
            {
                if (widthCounter >= texture.Width)
                {
                    widthCounter = 0;
                    position.X   = startX;
                    position.Y++;
                }

                if (surface.IsValidCell(position.X, position.Y))
                {
                    int destinationIndex = position.ToIndex(surface.Width);

                    cellProcessor(destinationIndex, surface[destinationIndex], pixels[i]);
                }

                position.X++;
                widthCounter++;
            }
        }
Пример #5
0
        public void Draw(CellSurface surface)
        {
            if (BorderAppearance == null)
            {
                BorderAppearance = new CellAppearance(Color.Blue, Color.Black, 4);
            }

            Algorithms.Circle(Center.X, Center.Y, Radius, (x, y) => { if (surface.IsValidCell(x, y))
                                                                      {
                                                                          surface.SetCellAppearance(x, y, BorderAppearance);
                                                                      }
                              });
        }
Пример #6
0
        public static void DrawImageToSurface(this Texture2D texture, CellSurface surface, Point position, bool useBackground, Func <Color, Color, Color> blendOperation = null)
        {
            Color[] pixels = new Color[texture.Width * texture.Height];
            texture.GetData <Color>(pixels);

            int startX       = position.X;
            int widthCounter = 0;

            for (int i = 0; i < pixels.Length; i++)
            {
                if (widthCounter >= texture.Width)
                {
                    widthCounter = 0;
                    position.X   = startX;
                    position.Y++;
                }

                if (surface.IsValidCell(position.X, position.Y))
                {
                    int destinationIndex = position.ToIndex(surface.Width);

                    if (useBackground)
                    {
                        if (blendOperation == null)
                        {
                            surface[destinationIndex].Background = pixels[i];
                        }
                        else
                        {
                            surface[destinationIndex].Background = blendOperation(surface[destinationIndex].Background, pixels[i]);
                        }
                    }
                    else
                    {
                        if (blendOperation == null)
                        {
                            surface[destinationIndex].Foreground = pixels[i];
                        }
                        else
                        {
                            surface[destinationIndex].Foreground = blendOperation(surface[destinationIndex].Foreground, pixels[i]);
                        }
                    }
                }

                position.X++;
                widthCounter++;
            }
        }
Пример #7
0
        public static void DrawImageToSurface(this Texture2D texture, CellSurface surface, Point position, bool useBackground, Func<Color, Color, Color> blendOperation = null)
        {
            Color[] pixels = new Color[texture.Width * texture.Height];
            texture.GetData<Color>(pixels);

            int startX = position.X;
            int widthCounter = 0;

            for (int i = 0; i < pixels.Length; i++)
            {
                if (widthCounter >= texture.Width)
                {
                    widthCounter = 0;
                    position.X = startX;
                    position.Y++;
                }

                if (surface.IsValidCell(position.X, position.Y))
                {
                    int destinationIndex = position.ToIndex(surface.Width);

                    if (useBackground)
                    {
                        if (blendOperation == null)
                            surface[destinationIndex].Background = pixels[i];
                        else
                            surface[destinationIndex].Background = blendOperation(surface[destinationIndex].Background, pixels[i]);
                    }
                    else
                    {
                        if (blendOperation == null)
                            surface[destinationIndex].Foreground = pixels[i];
                        else
                            surface[destinationIndex].Foreground = blendOperation(surface[destinationIndex].Foreground, pixels[i]);
                    }
                }

                position.X++;
                widthCounter++;
            }
        }
Пример #8
0
        private void PlotCell(CellSurface surface, int x, int y, int character, bool fillMe = false)
        {
            if (surface.IsValidCell(x,y))
            {
                var cell = surface[x, y];

                if (fillMe)
                {
                    cell.Background = FillColor;
                    cell.Foreground = Foreground;
                    cell.CharacterIndex = character;
                    return;
                }

                if (Foreground != Color.Transparent || DrawTransparency)
                    cell.Foreground = Foreground;

                if (BorderBackground != Color.Transparent || DrawTransparency)
                    cell.Background = BorderBackground;

                cell.CharacterIndex = character;
            }
        }
Пример #9
0
        //public ICellAppearance FillAppearance;
        //public bool Fill;

        public void Draw(CellSurface surface)
        {
            Algorithms.Ellipse(StartingPoint.X, StartingPoint.Y, EndingPoint.X, EndingPoint.Y, (x, y) => { if (surface.IsValidCell(x, y))
                                                                                                           {
                                                                                                               surface.SetCellAppearance(x, y, BorderAppearance);
                                                                                                           }
                               });
        }
Пример #10
0
        //public ICellAppearance FillAppearance;
        //public bool Fill;

        public void Draw(CellSurface surface)
        {
            Algorithms.Ellipse(StartingPoint.X, StartingPoint.Y, EndingPoint.X, EndingPoint.Y, (x, y) => { if (surface.IsValidCell(x, y)) surface.SetCellAppearance(x, y, BorderAppearance); });
        }