Exemplo n.º 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++;
            }
        }
Exemplo n.º 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); });
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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++;
            }
        }
Exemplo n.º 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);
                                                                      }
                              });
        }
Exemplo n.º 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++;
            }
        }
Exemplo n.º 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++;
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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);
                                                                                                           }
                               });
        }
Exemplo n.º 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); });
        }