public MouseRenderingDebug() : base(80, 23) { pal = new Palette(new ColorGradient(Color.White, Color.Violet, Color.Black, Color.White).ToColorArray(25)); PaletteSurface surfacePal = new PaletteSurface(5, 5, pal); for (int i = 0; i < 25; i++) { ((CellPalette)surfacePal[i]).BackgroundIndex = i; } Children.Add(surfacePal); surfacePal.Print(0, 0, "Hello from printing!"); timer = new Timer(100, (t, a) => pal.ShiftRight(0, 5)); timer5 = new Timer(2000, (t, a) => pal.ShiftLeft()); }
public override void RenderCells(SurfaceBase surfacePreCast, bool force = false) { PaletteSurface surface = (PaletteSurface)surfacePreCast; if (surface.IsDirty || force) { if (surface.Tint.A != 255) { CellPalette cell; Color background; Color foreground; if (surface.DefaultBackground.A != 0) { Global.SpriteBatch.Draw(surface.Font.FontImage, surface.AbsoluteArea, surface.Font.GlyphRects[surface.Font.SolidGlyphIndex], surface.DefaultBackground, 0f, Vector2.Zero, SpriteEffects.None, 0.2f); } for (int i = 0; i < surface.RenderCells.Length; i++) { cell = (CellPalette)surface.RenderCells[i]; if (cell.IsVisible) { background = palette[cell.BackgroundIndex]; foreground = palette[cell.ForegroundIndex]; if (background != Color.Transparent && background != surface.DefaultBackground) { Global.SpriteBatch.Draw(surface.Font.FontImage, surface.RenderRects[i], surface.Font.GlyphRects[surface.Font.SolidGlyphIndex], background, 0f, Vector2.Zero, SpriteEffects.None, 0.3f); } if (foreground != Color.Transparent) { Global.SpriteBatch.Draw(surface.Font.FontImage, surface.RenderRects[i], surface.Font.GlyphRects[cell.Glyph], foreground, 0f, Vector2.Zero, cell.Mirror, 0.4f); } } } } } }
public MouseRenderingDebug() : base(80, 23) { pal = new Palette(new ColorGradient(Color.White, Color.Violet, Color.Black, Color.White).ToColorArray(25)); PaletteSurface surfacePal = new PaletteSurface(5, 5, pal); PaletteSurfaceRenderer rendererPal = new PaletteSurfaceRenderer(); rendererPal.palette = pal; for (int i = 0; i < 25; i++) { ((CellPalette)surfacePal[i]).BackgroundIndex = i; } Console childConsole = new Console(surfacePal); childConsole.Renderer = rendererPal; childConsole.Position = new Point(4, 12); Children.Add(childConsole); timer = new Timer(100, (t, a) => pal.ShiftRight(0, 5)); timer5 = new Timer(2000, (t, a) => pal.ShiftLeft()); }
public MouseRenderingDebug() : base(80, 23) { pal = new Palette(new ColorGradient(Color.White, Color.Violet, Color.Black, Color.White).ToColorArray(25)); PaletteSurface surfacePal = new PaletteSurface(5, 5, pal); for (int i = 0; i < 25; i++) { ((CellPalette)surfacePal[i]).BackgroundIndex = i; } Children.Add(surfacePal); surfacePal.Print(0, 0, "Hello from printing!"); timer = new Timer(TimeSpan.FromMilliseconds(100)); timer.TimerElapsed += (t, e) => pal.ShiftRight(0, 5); timer5 = new Timer(TimeSpan.FromMilliseconds(2000)); timer5.TimerElapsed += (t, e) => pal.ShiftLeft(); Components.Add(timer); Components.Add(timer5); }