public TrackRenderer(ITrackParameters trackParameters, ITrackPathBuilder trackPathBuilder) { _trackParameters = trackParameters; _cornerTrackPath = trackPathBuilder.BuildCornerTrackPath(); _cornerPlankPath = trackPathBuilder.BuildCornerPlankPath(); _cornerSinglePlankPath = trackPathBuilder.BuildCornerPlankPath(1); _horizontalTrackPath = trackPathBuilder.BuildHorizontalTrackPath(); _horizontalPlankPath = trackPathBuilder.BuildHorizontalPlankPath(); _plankPaint = new PaintBrush { Color = Colors.Black, Style = PaintStyle.Stroke, StrokeWidth = _trackParameters.PlankWidth, IsAntialias = true }; _trackClear = new PaintBrush { Color = Colors.White, Style = PaintStyle.Stroke, StrokeWidth = _trackParameters.RailTopWidth, IsAntialias = true }; _trackEdge = new PaintBrush { Color = Colors.Black, Style = PaintStyle.Stroke, StrokeWidth = _trackParameters.RailWidth, IsAntialias = true }; }
//public void Dispose() //{ // _bodyPaint.Dispose(); // _headPaint.Dispose(); //} public void Render(ICanvas canvas, Train train) { if (!_paletteMap.ContainsKey(train)) { _paletteMap.Add(train, GetRandomPalette()); } var palette = _paletteMap[train]; SetupCanvasToDrawTrain(canvas, train, _trackParameters); var outline = new PaintBrush { Color = palette.OutlineColor, Style = PaintStyle.Stroke, StrokeWidth = 2 }; var smokeStack = new PaintBrush { Color = palette.OutlineColor, Style = PaintStyle.Fill, StrokeWidth = 2 }; float startPos = -((_trainParameters.HeadWidth + _trainParameters.RearWidth) / 2); canvas.GradientRect(startPos, -(_trainParameters.RearHeight / 2), _trainParameters.RearWidth, _trainParameters.RearHeight, palette.RearSectionStartColor, palette.RearSectionEndColor); canvas.GradientRect(startPos + _trainParameters.RearWidth, -(_trainParameters.HeadHeight / 2), _trainParameters.HeadWidth, _trainParameters.HeadHeight, palette.FrontSectionStartColor, palette.FrontSectionEndColor); canvas.DrawRect(startPos, -(_trainParameters.RearHeight / 2), _trainParameters.RearWidth, _trainParameters.RearHeight, outline); canvas.DrawRect(startPos + _trainParameters.RearWidth, -(_trainParameters.HeadHeight / 2), _trainParameters.HeadWidth, _trainParameters.HeadHeight, outline); canvas.DrawCircle(startPos + _trainParameters.RearWidth + _trainParameters.HeadWidth - 5, 0, 2, smokeStack); }
public TerrainRenderer(ITerrainMap terrainMap, IPixelMapper pixelMapper, ITrackParameters trackParameters) { _terrainMap = terrainMap; _pixelMapper = pixelMapper; _trackParameters = trackParameters; _paintBrush = new PaintBrush { Color = Colors.LightGray, StrokeWidth = 1, Style = PaintStyle.Stroke }; }
public void Render(ICanvas canvas, Train train) { TrainPalette?palette = _trainPainter.GetPalette(train); SetupCanvasToDrawTrain(canvas, train); var outline = new PaintBrush { Color = palette.OutlineColor, Style = PaintStyle.Stroke, StrokeWidth = _trainParameters.StrokeWidth }; var smokeStack = new PaintBrush { Color = palette.OutlineColor, Style = PaintStyle.Fill, StrokeWidth = _trainParameters.StrokeWidth }; float startPos = -((_trainParameters.HeadWidth + _trainParameters.RearWidth) / 2); canvas.GradientRect(startPos, -(_trainParameters.RearHeight / 2), _trainParameters.RearWidth, _trainParameters.RearHeight, palette.RearSectionStartColor, palette.RearSectionEndColor); canvas.GradientRect(startPos + _trainParameters.RearWidth, -(_trainParameters.HeadHeight / 2), _trainParameters.HeadWidth, _trainParameters.HeadHeight, palette.FrontSectionStartColor, palette.FrontSectionEndColor); canvas.DrawRect(startPos, -(_trainParameters.RearHeight / 2), _trainParameters.RearWidth, _trainParameters.RearHeight, outline); canvas.DrawRect(startPos + _trainParameters.RearWidth, -(_trainParameters.HeadHeight / 2), _trainParameters.HeadWidth, _trainParameters.HeadHeight, outline); canvas.DrawCircle(startPos + _trainParameters.RearWidth + _trainParameters.HeadWidth - _trainParameters.SmokeStackOffset, 0, _trainParameters.SmokeStackRadius, smokeStack); }
public static void RenderTrain(ICanvas canvas, TrainPalette palette, ITrainParameters trainParameters, bool shouldHighlight) { var outline = new PaintBrush { Color = shouldHighlight ? Colors.LightGray : palette.OutlineColor, Style = PaintStyle.Stroke, StrokeWidth = trainParameters.StrokeWidth }; var smokeStack = new PaintBrush { Color = palette.OutlineColor, Style = PaintStyle.Fill, StrokeWidth = trainParameters.StrokeWidth }; float startPos = -((trainParameters.HeadWidth + trainParameters.RearWidth) / 2); canvas.DrawGradientRect(startPos, -(trainParameters.RearHeight / 2), trainParameters.RearWidth, trainParameters.RearHeight, palette.RearSectionStartColor, palette.RearSectionEndColor); canvas.DrawGradientRect(startPos + trainParameters.RearWidth, -(trainParameters.HeadHeight / 2), trainParameters.HeadWidth, trainParameters.HeadHeight, palette.FrontSectionStartColor, palette.FrontSectionEndColor); canvas.DrawRect(startPos, -(trainParameters.RearHeight / 2), trainParameters.RearWidth, trainParameters.RearHeight, outline); canvas.DrawRect(startPos + trainParameters.RearWidth, -(trainParameters.HeadHeight / 2), trainParameters.HeadWidth, trainParameters.HeadHeight, outline); canvas.DrawCircle(startPos + trainParameters.RearWidth + trainParameters.HeadWidth - trainParameters.SmokeStackOffset, 0, trainParameters.SmokeStackRadius, smokeStack); }
public TreeRenderer() { _centerOffset = 50.0f; _baseRadius = 25.0f; _minTreeSize = _baseRadius; _maxTreeSize = _baseRadius * 1.25f; _baseTreeBrush = new PaintBrush { Color = new Color("#1B633A"), Style = PaintStyle.Fill }; _topTreeBrush = new PaintBrush { Color = new Color("#236A42"), Style = PaintStyle.Fill, IsAntialias = true }; }
public void Render(ICanvas canvas, int width, int height, IPixelMapper pixelMapper) { var grid = new PaintBrush { Color = Colors.LightGray, StrokeWidth = 1, Style = PaintStyle.Stroke }; for (int x = pixelMapper.ViewPortX; x < pixelMapper.ViewPortWidth + 1; x += pixelMapper.CellSize) { canvas.DrawLine(x, 0, x, height, grid); } for (int y = pixelMapper.ViewPortY; y < pixelMapper.ViewPortHeight + 1; y += pixelMapper.CellSize) { canvas.DrawLine(0, y, width, y, grid); } }
public void Render(ICanvas canvas, int width, int height) { var grid = new PaintBrush { Color = Colors.LightGray, StrokeWidth = 1, Style = PaintStyle.Stroke }; for (int x = 0; x < width + 1; x += _parameters.CellSize) { canvas.DrawLine(x, 0, x, height, grid); } for (int y = 0; y < height + 1; y += _parameters.CellSize) { canvas.DrawLine(0, y, width, y, grid); } }
public TreeRenderer(IBitmapFactory bitmapFactory, ITrackParameters trackParameters) { _cellSize = trackParameters.CellSize; _centerOffset = _cellSize / 2.0f; _baseRadius = _cellSize / 4.0f; _minTreeSize = _baseRadius; _maxTreeSize = _baseRadius * 1.25f; _baseTreeBrush = new PaintBrush { Color = new Color("#1B633A"), Style = PaintStyle.Fill }; _topTreeBrush = new PaintBrush { Color = new Color("#236A42"), Style = PaintStyle.Fill, IsAntialias = true }; _bitmapFactory = bitmapFactory; }
public TrackRenderer(ITrackParameters parameters, IPathFactory pathFactory) { _parameters = parameters; _pathFactory = pathFactory; _plankPaint = new PaintBrush { Color = Colors.Black, Style = PaintStyle.Stroke, IsAntialias = true }; _arcTrackClear = new PaintBrush() { Style = PaintStyle.Stroke, Color = Colors.White, IsAntialias = true }; _arcTrackPaint = new PaintBrush() { Style = PaintStyle.Stroke, StrokeWidth = 1, Color = Colors.Black, IsAntialias = true }; _straightTrackPaint = new PaintBrush { Color = Colors.Black, Style = PaintStyle.Stroke, StrokeWidth = 1, IsAntialias = false }; _straightTrackClear = new PaintBrush { Color = Colors.White, Style = PaintStyle.Fill, StrokeWidth = 0 }; }
public IImage GetTerrainImage() { if (_imageCache.IsDirty(this)) { int width = _pixelMapper.Columns; int _height = _pixelMapper.Rows; using IImageCanvas textureImage = _imageFactory.CreateImageCanvas(width, _height); foreach (Terrain terrain in _terrainMap) { Color colour = GetTerrainColour(terrain); PaintBrush paint = GetPaint(colour); textureImage.Canvas.DrawRect(terrain.Column, terrain.Row, 1, 1, paint); } _imageCache.Set(this, textureImage.Render()); Changed?.Invoke(this, EventArgs.Empty); } return(_imageCache.Get(this) !); }
private void DrawTreeLayer(ICanvas canvas, Random r, int circleCount, float angleOffset, float scale, PaintBrush brush) { for (int i = 0; i < circleCount; i++) { float angle = angleOffset + (float)(Math.PI * 2.0 * i / circleCount); float offset = r.NextFloat(_minTreeSize, _maxTreeSize); float radius = r.NextFloat(10.0f, 15.0f); float x = (float)(scale * offset * Math.Cos(angle)); float y = (float)(scale * offset * Math.Sin(angle)); canvas.DrawCircle(x, y, radius, brush); } }