Beispiel #1
0
        public float DrawCharacter(BGICanvas bgi, float x, float y, BGICanvas.Direction dir, int size, byte character, IList <Rectangle> updates)
        {
            byte          foreCol = bgi.GetColor();
            FontCharacter fc      = this[character];

            if (dir == BGICanvas.Direction.Horizontal)
            {
                int starty = (int)y;
                for (int cy = 0; cy < Height; cy++)
                {
                    int startx = (int)x;
                    for (int cx = 0; cx < Width; cx++)
                    {
                        if (fc[cx, cy])
                        {
                            if (size == 1)
                            {
                                bgi.PutPixelInternal(startx, starty, foreCol);
                            }
                            else
                            {
                                for (int ccy = 0; ccy < size; ccy++)
                                {
                                    for (int ccx = 0; ccx < size; ccx++)
                                    {
                                        bgi.PutPixelInternal(startx + ccx, starty + ccy, foreCol);
                                    }
                                }
                            }
                        }
                        startx += size;
                    }
                    starty += size;
                }
                var updateRect = new Rectangle((int)x, (int)y, Width * size, Height * size);
                if (updates != null)
                {
                    updates.Add(updateRect);
                }
                else
                {
                    bgi.UpdateRegion(updateRect);
                }
            }
            else
            {
                int startx = (int)x;
                for (int cy = 0; cy < Height; cy++)
                {
                    int starty = (int)y;
                    for (int cx = 0; cx < Width; cx++)
                    {
                        if (fc[cx, cy])
                        {
                            if (size == 1)
                            {
                                bgi.PutPixelInternal(startx, starty, foreCol);
                            }
                            else
                            {
                                for (int ccy = 0; ccy < size; ccy++)
                                {
                                    for (int ccx = 0; ccx < size; ccx++)
                                    {
                                        bgi.PutPixelInternal(startx + ccx, starty - ccy, foreCol);
                                    }
                                }
                            }
                        }
                        starty -= size;
                    }
                    startx += size;
                }
                var updateRect = new Rectangle((int)x, (int)y, Height * size, Width * size);
                if (updates != null)
                {
                    updates.Add(updateRect);
                }
                else
                {
                    bgi.UpdateRegion(updateRect);
                }
            }
            return(Width * size);
        }
Beispiel #2
0
 public override bool InternalShouldApply(BGICanvas bgi)
 {
     return(bgi.GetColor() != Value);
 }