public void Clear(int x, int y) { var mut = new GridMutation(); mut.AddSource(x, y); Render(mut); }
public void Render(int x, int y, char symbol, int color = DrawablePoint.DefaultForeColor, char d = ' ') { var dp = new DrawablePoint(x, y, color, symbol, d); var m = new GridMutation(); m.AddTarget(dp); Render(m); }
public static GridMutation Create(IEnumerable <Point> sources, IEnumerable <DrawablePoint> targets) { var m = new GridMutation(); m.AddSources(sources); m.AddTargets(targets); return(m); }
public static GridMutation Create(Point source, DrawablePoint target) { var m = new GridMutation(); m.AddSource(source); m.AddTarget(target); return(m); }
public void Render(int x, int y, char symbol, int oldX, int oldY, int color = DrawablePoint.DefaultForeColor, char d = ' ') { var @new = new DrawablePoint(x, y, color, symbol, d); var old = new Point(oldX, oldY); var mut = new GridMutation(); mut.AddSource(old); mut.AddTarget(@new); Render(mut); }
public void ProcessUpdates(CancellationToken cancellationToken) { while (true) { GridMutation m = _mutations.Take(); // Clears blocks after move foreach (var p in m.SourcePositions) { if (p.X < 0 || p.Y < 0) { continue; } Console.SetCursorPosition(p.X, p.Y); Console.Write(' '); } // Renders the block on the new position foreach (var p in m.TargetPositions) { if (p.X < 0 || p.Y < 0) { continue; } if (Console.ForegroundColor != (ConsoleColor)p.ForeColor) { Console.ForegroundColor = (ConsoleColor)p.ForeColor; } Console.SetCursorPosition(p.X, p.Y); Console.Write(_settings.Debug ? p.Debug : p.Symbol); } if (cancellationToken.IsCancellationRequested) { break; } } }
public void Render(GridMutation mutation) => _mutations.Add(mutation);