public IEnumerable <ImageRenderInfo> Render(GameModel gameModel, bool debugging = false) { return(gameModel.ObjectsToRender .Select(obj => new { Point = gameOrigin.Add(obj.Position.X, -obj.Position.Y - obj.ObjectParameters.Size.Height), Renderer = GetRendererForObjectOrNull(obj), GameObject = obj }) .Select(x => new ImageRenderInfo { Point = x.Point, Image = RenderObject(gameModel.State, x.GameObject, x.Renderer) }) .If(debugging, q => q.Select(x => new ImageRenderInfo { Point = x.Point, Image = x.Image.AddBorders(Color.Red) }) .ConcatWith(new ImageRenderInfo { Image = DrawingHelpers.CreateSquare(3, 3, Color.GreenYellow), Point = gameOrigin })) .ToArray()); }
void OnDrawGizmos() { foreach (var item in _trackedObjects) { var box = BurstColliderFactory.CreateBox(item.Value.WrappedObject.transform); DrawingHelpers.DrawWireFrame(box); } }
void OnDrawGizmos() { if (!ExecuteInEditMode && !Application.isPlaying) { return; } DrawingHelpers.DrawWireFrame(Box); }
public Bitmap Render() { var txt = GetInFixNotation(); var size = DrawingHelpers.GetSizeOfText(txt, DrawingHelpers.globalFont); Bitmap bmp = new Bitmap((int)size.Width, (int)size.Height); Graphics g = Graphics.FromImage(bmp); var brush = new SolidBrush(DrawingHelpers.globalColor); g.DrawString(txt, DrawingHelpers.globalFont, brush, new PointF(0, 0)); brush.Dispose(); g.Dispose(); return(bmp); }
public void DrawMap(Map map) { var maxDepth = map.GetMaxDepth(); for (var x = 0; x < map.Width; x++) { for (var y = 0; y < map.Height; y++) { var cell = map.GetCell(new Point(x, y)); var drawing = new DrawingVisual(); SolidColorBrush brush; if (cell.Depth > 0) { var depthCoefficient = cell.Depth / maxDepth; var redValue = 255 - 255 * depthCoefficient; brush = new SolidColorBrush(Color.FromArgb(255, (byte)redValue, 255, 0)); } else { brush = new SolidColorBrush(Color.FromArgb(64, 255, 0, 0)); } using (var context = drawing.RenderOpen()) { context.DrawRectangle(brush, new Pen(Brushes.Black, 2), new Rect(new GraphicsPoint(0, 0), new GraphicsPoint(Constants.CellSize, Constants.CellSize))); var text = DrawingHelpers.GetFormattedText(cell.Depth.ToString(CultureInfo.CurrentCulture), 10, new SolidColorBrush(Colors.Black)); context.DrawText(text, new GraphicsPoint(10, 25)); } var source = new RenderTargetBitmap(Constants.CellSize, Constants.CellSize, 96, 96, PixelFormats.Pbgra32); source.Render(drawing); var drawer = new DrawnObjectViewModel(source) { X = x * Constants.CellSize, Y = y * Constants.CellSize }; _drawableObjects.Add(drawer); } } }
public Bitmap Render() { var parameterLeftBmp = this.FirstParameter.Render(); var parameterRightBmp = this.SecondParameter.Render(); var sizeFunctionStart = DrawingHelpers.GetSizeOfText("log(", DrawingHelpers.globalFont); var sizeFunctionMiddle = DrawingHelpers.GetSizeOfText(", ", DrawingHelpers.globalFont); var sizeFunctionEnd = DrawingHelpers.GetSizeOfText(")", DrawingHelpers.globalFont); var brush = new SolidBrush(DrawingHelpers.globalColor); var bmp = new Bitmap( (int)sizeFunctionStart.Width + parameterLeftBmp.Width + (int)sizeFunctionMiddle.Width + parameterRightBmp.Width + (int)sizeFunctionEnd.Width, Math.Max(parameterRightBmp.Height, Math.Max((int)sizeFunctionStart.Height, parameterLeftBmp.Height))); Graphics g = Graphics.FromImage(bmp); g.DrawString("log(", DrawingHelpers.globalFont, brush, new PointF(0, bmp.Height - (int)sizeFunctionStart.Height)); g.DrawImage(parameterLeftBmp, new Point((int)sizeFunctionStart.Width + DrawingHelpers.Padding, bmp.Height - parameterLeftBmp.Height)); g.DrawString(", ", DrawingHelpers.globalFont, brush, new PointF((int)sizeFunctionStart.Width + DrawingHelpers.Padding + parameterLeftBmp.Width, bmp.Height - (int)sizeFunctionMiddle.Height)); g.DrawImage(parameterRightBmp, new Point((int)sizeFunctionStart.Width + DrawingHelpers.Padding + (int)sizeFunctionMiddle.Width, bmp.Height - parameterRightBmp.Height)); g.DrawString(")", DrawingHelpers.globalFont, brush, new PointF((int)sizeFunctionStart.Width + 2 * DrawingHelpers.Padding + parameterRightBmp.Width + parameterLeftBmp.Width + (int)sizeFunctionMiddle.Width, bmp.Height - (int)sizeFunctionEnd.Height)); g.Dispose(); parameterLeftBmp.Dispose(); parameterRightBmp.Dispose(); brush.Dispose(); return(bmp); }
private RenderTargetBitmap GetImage() { RenderTargetBitmap source = null; Application.Current.Dispatcher.Invoke(() => { var drawing = new DrawingVisual(); using (var context = drawing.RenderOpen()) { context.DrawRectangle(Brushes.Blue, null, new Rect(new Point(0, 0), new Point(Constants.CellSize, Constants.CellSize))); var text = DrawingHelpers.GetFormattedText(_ship.MoveDirection.ToString(), 10, new SolidColorBrush(Colors.White)); context.DrawText(text, new Point(0, 0)); } source = new RenderTargetBitmap(Constants.CellSize, Constants.CellSize, 96, 96, PixelFormats.Pbgra32); source.Render(drawing); }); return(source); }
public Bitmap Render() => DrawingHelpers.DrawSingularFunction(this.Parameter.Render(), "arctg");
public Bitmap Render() => DrawingHelpers.DrawSimpleOperation(LeftOperand.Render(), RightOperand.Render(), "*");
protected override bool TryDrawPartialImplementation(Rectangle bounds, Rectangle relativeBounds) { DrawingHelpers.DrawRectanglePartial(Environment, _pen, bounds, relativeBounds); return(true); }