public void Render( IColorInImageDetection colorInImageDetection, ISelectedColorHandle selectedColorHandle, IRenderContext renderContext, Rectangle rectangle) { var recogArray = colorInImageDetection.GetUnlockedResultsForColor(selectedColorHandle); if (recogArray == null) { return; } var color = colorInImageDetection.GetValueForColor(selectedColorHandle); var widthScale = (int)Math.Ceiling(rectangle.Width / (float)recogArray.GetLength(0)); var heightScale = (int)Math.Ceiling(rectangle.Height / (float)recogArray.GetLength(1)); var xx = rectangle.X; var yy = rectangle.Y; for (var x = 0; x < recogArray.GetLength(0); x++) { for (var y = 0; y < recogArray.GetLength(1); y++) { Color col; var score = recogArray[x, y] / colorInImageDetection.GetSensitivityForColor(selectedColorHandle); if (score < 0) { var scoreCapped = Math.Min(255, -score); col = new Color(scoreCapped / 255f, scoreCapped / 255f, scoreCapped / 255f, 1f); } else { var scoreCapped = Math.Max(0, score); col = new Color( scoreCapped / 255f * (color.R / 255f), scoreCapped / 255f * (color.G / 255f), scoreCapped / 255f * (color.B / 255f), 1f); } _renderUtilities.RenderRectangle( renderContext, new Rectangle( xx + x * widthScale, yy + y * heightScale, widthScale, heightScale), col, true); } } _renderUtilities.RenderText( renderContext, new Vector2( rectangle.X + rectangle.Width / 2, rectangle.Y + 40), "Total " + colorInImageDetection.GetNameForColor(selectedColorHandle) + ": " + colorInImageDetection.GetTotalDetectedForColor(selectedColorHandle), _defaultFont); }
public override void Render(IGameContext gameContext, IRenderContext renderContext) { base.Render(gameContext, renderContext); if (renderContext.IsCurrentRenderPass <I2DBatchedRenderPass>()) { var recogArray = _currentColor.RecognisedArray; if (recogArray == null) { return; } WidthScale = (int)Math.Ceiling(renderContext.GraphicsDevice.PresentationParameters.BackBufferWidth / (float)recogArray.GetLength(0)); HeightScale = (int)Math.Ceiling(renderContext.GraphicsDevice.PresentationParameters.BackBufferHeight / (float)recogArray.GetLength(1)); for (var x = 0; x < recogArray.GetLength(0); x++) { for (var y = 0; y < recogArray.GetLength(1); y++) { Color col; var score = recogArray[x, y] / _currentColor.Sensitivity; //var scoreCapped = MathHelper.Clamp(score, 0f, 255f) / 255f; //col = new Color(scoreCapped, scoreCapped, scoreCapped); if (score < 0) { var scoreCapped = Math.Min(255, -score); col = new Color(scoreCapped / 255f, scoreCapped / 255f, scoreCapped / 255f, 1f); } else { var scoreCapped = Math.Max(0, score); col = new Color( scoreCapped / 255f * (_currentColor.Color.R / 255f), scoreCapped / 255f * (_currentColor.Color.G / 255f), scoreCapped / 255f * (_currentColor.Color.B / 255f), 1f); } _renderUtilities.RenderRectangle( renderContext, new Rectangle( (int)(X + x * WidthScale), (int)(Y + y * HeightScale), WidthScale, HeightScale), col, true); } } _renderUtilities.RenderText( renderContext, new Vector2( renderContext.GraphicsDevice.PresentationParameters.BackBufferWidth / 2, 40), "Total " + _currentColor.Name + ": " + _currentColor.TotalDetected, _defaultFont); } }
public void Render(IGameContext gameContext, IRenderContext renderContext) { if (renderContext.IsCurrentRenderPass <I2DBatchedLoadingScreenRenderPass>()) { var bounds = renderContext.GraphicsDevice.PresentationParameters.Bounds; _renderUtilities.RenderRectangle( renderContext, bounds, new Color(0x33, 0x33, 0x33, 0xFF), true); _renderUtilities.RenderText( renderContext, new Vector2(bounds.Width - 20, bounds.Height - 20), "Loading...", _defaultFont, HorizontalAlignment.Right, VerticalAlignment.Bottom, Color.White, true, Color.Black); _renderUtilities.RenderText( renderContext, new Vector2(20, bounds.Height - 20), "Made with Protogame (protogame.org)", _defaultFont, HorizontalAlignment.Left, VerticalAlignment.Bottom, new Color(0x66, 0x66, 0x66, 0xFF), false, Color.Black); } }
public void Render(IRenderContext renderContext, Rectangle layout, Rectangle renderedLayout, ConsoleContainer container) { _renderUtilities.RenderRectangle(renderContext, renderedLayout, new Color(0, 0, 0, 255), true); if (container.Console == null) { return; } var entries = container.Console.Entries; var a = 0; for (var i = 0; i < entries.Length; i++) { var color = Color.White; switch (entries[i].LogLevel) { case ConsoleLogLevel.Debug: color = Color.White; break; case ConsoleLogLevel.Info: color = Color.Cyan; break; case ConsoleLogLevel.Warning: color = Color.Orange; break; case ConsoleLogLevel.Error: color = Color.Red; break; } var x = entries[i]; var message = x.Name == string.Empty ? x.Message : $"<{x.Name,-20}> ({x.Count,5}) {x.Message}"; var lines = message.Split(new[] { Environment.NewLine }, StringSplitOptions.None).Length; var pointA = new Point(layout.X + 2, layout.Y + a * 16); var pointB = new Point(layout.X + 2, layout.Y + (a + lines) * 16); if (renderedLayout.Contains(pointA) || renderedLayout.Contains(pointB)) { _renderUtilities.RenderText( renderContext, pointA.ToVector2(), message, _fontAsset, textColor: color, renderShadow: false); } a += lines; } }
public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass, RenderTarget2D postProcessingSource) { if (!Enabled) { return; } var x = 0; var y = 0; if (_console != null) { if (_console.State == ConsoleState.Open || _console.State == ConsoleState.OpenNoInput) { y = 300; } } renderContext.SpriteBatch.Begin(SpriteSortMode.Immediate); var size = _backBufferDimensions.GetSize(renderContext.GraphicsDevice); foreach (var visualiser in Visualisers) { var height = visualiser.GetHeight(size.Height); var rect = new Rectangle( Position == ProfilerPosition.TopLeft ? 0 : (size.Width - 300), y, 300, height); // Draw a background for the profiler. _renderUtilities.RenderRectangle( renderContext, rect, new Color(0, 0, 0, 210), true); // Ask the profiler to render it's content. visualiser.Render(gameContext, renderContext, rect); y += height; } renderContext.SpriteBatch.End(); }
public void Render(IRenderContext renderContext, Rectangle layout, ListItem listItem) { var textHighlighted = false; if (listItem.Parent is ListView) { var view = listItem.Parent as ListView; if (view.SelectedItem == listItem) { _renderUtilities.RenderRectangle( renderContext, new Rectangle(layout.X, layout.Y, layout.Width, layout.Height), (listItem.Focused || view.Focused) ? new Color(22, 170, 66, 255) : new Color(66, 66, 66, 255), true); textHighlighted = true; } } if (listItem.Icon != null) { _renderUtilities.RenderTexture( renderContext, new Vector2(layout.X + 2, layout.Y + 1), listItem.Icon, new Vector2(layout.Height - 2, layout.Height - 2), textHighlighted ? Color.White : Color.Black); } _renderUtilities.RenderText( renderContext, new Vector2(layout.X + 5 + layout.Height, layout.Center.Y), listItem.Text, _fontAsset, verticalAlignment: VerticalAlignment.Center, textColor: textHighlighted ? Color.White : Color.Black, renderShadow: false); }
public void Render(IGameContext gameContext, IRenderContext renderContext, StringBuilder inputBuffer, ConsoleState state, List <Tuple <ConsoleLogLevel, string> > logEntries) { if (_fontAsset == null) { _fontAsset = _assetManager.Get <FontAsset>("font.Console"); } if (renderContext.IsCurrentRenderPass <I3DRenderPass>()) { return; } var h = 0; if (state == ConsoleState.Open || state == ConsoleState.OpenNoInput) { h = 300; } else if (state == ConsoleState.FullOpen || state == ConsoleState.FullOpenNoInput) { h = gameContext.Window.ClientBounds.Height; } _renderUtilities.RenderRectangle( renderContext, new Rectangle(0, 0, gameContext.Window.ClientBounds.Width, h), new Color(0, 0, 0, 210), true); _renderUtilities.RenderRectangle( renderContext, new Rectangle(0, 0, gameContext.Window.ClientBounds.Width - 1, h - 1), Color.White); var o = 16; if (state == ConsoleState.FullOpen || state == ConsoleState.Open) { _renderUtilities.RenderLine( renderContext, new Vector2(0, h - 16), new Vector2(gameContext.Window.ClientBounds.Width, h - 16), Color.White); _renderUtilities.RenderText( renderContext, new Vector2(2, h - 16), inputBuffer.ToString(), _fontAsset); o = 32; } var a = 0; for (var i = Math.Max(0, logEntries.Count - 30); i < logEntries.Count; i++) { var color = Color.White; switch (logEntries[logEntries.Count - i - 1].Item1) { case ConsoleLogLevel.Debug: color = Color.White; break; case ConsoleLogLevel.Info: color = Color.Cyan; break; case ConsoleLogLevel.Warning: color = Color.Orange; break; case ConsoleLogLevel.Error: color = Color.Red; break; } _renderUtilities.RenderText( renderContext, new Vector2(2, h - o - a * 16), logEntries[logEntries.Count - i - 1].Item2, _fontAsset, textColor: color); a++; } }
public void Render(IRenderContext renderContext, Rectangle layout, ScrollableContainer scrollableContainer) { var vertAdjust = (scrollableContainer.NeedsVerticalScrollbar ? _skinLayout.VerticalScrollBarWidth : 0); var horAdjust = (scrollableContainer.NeedsHorizontalScrollbar ? _skinLayout.HorizontalScrollBarHeight : 0); var layoutWidth = layout.Width - vertAdjust; var layoutHeight = layout.Height - horAdjust; var layoutFullWidth = layout.Width - _skinLayout.VerticalScrollBarWidth; var layoutFullHeight = layout.Height - _skinLayout.HorizontalScrollBarHeight; if (scrollableContainer.NeedsVerticalScrollbar) { var xPosition = layout.X + layout.Width - _skinLayout.VerticalScrollBarWidth / 2 - 3; var yPosition = layout.Y + _skinLayout.VerticalScrollBarWidth / 2 - 1; var lastYPosition = layout.Y + layout.Height - _skinLayout.VerticalScrollBarWidth / 2 - 3; _renderUtilities.RenderRectangle( renderContext, new Rectangle( layout.X + layout.Width - _skinLayout.VerticalScrollBarWidth, layout.Y, _skinLayout.VerticalScrollBarWidth, layout.Height), new Color(208, 208, 208, 255), true); _renderUtilities.RenderLine( renderContext, new Vector2(layout.X + layout.Width - _skinLayout.VerticalScrollBarWidth - 1, layout.Y), new Vector2(layout.X + layout.Width - _skinLayout.VerticalScrollBarWidth - 1, layout.Y + layout.Height - 1), new Color(182, 182, 182, 255)); _renderUtilities.RenderTexture( renderContext, new Vector2(xPosition, yPosition), _scrollbarVerticalBackgroundTopTexture, new Vector2(6, 3)); _renderUtilities.RenderTexture( renderContext, new Vector2(xPosition, yPosition + 3), _scrollbarVerticalBackgroundTexture, new Vector2(6, lastYPosition - (yPosition + 3))); _renderUtilities.RenderTexture( renderContext, new Vector2(xPosition, lastYPosition), _scrollbarVerticalBackgroundBottomTexture, new Vector2(6, 3)); var scrollbarOffset = (int)(yPosition + scrollableContainer.ScrollY * (layoutFullHeight - layoutFullHeight / (float)scrollableContainer.ChildHeight * layoutFullHeight)); var scrollbarLastOffset = scrollbarOffset + (int)(layoutFullHeight / (float)scrollableContainer.ChildHeight * layoutFullHeight); _renderUtilities.RenderTexture( renderContext, new Vector2(xPosition, scrollbarOffset), _scrollbarVerticalTopTexture, new Vector2(6, 3)); _renderUtilities.RenderTexture( renderContext, new Vector2(xPosition, scrollbarOffset + 3), _scrollbarVerticalTexture, new Vector2(6, scrollbarLastOffset - (scrollbarOffset + 3))); _renderUtilities.RenderTexture( renderContext, new Vector2(xPosition, scrollbarLastOffset), _scrollbarVerticalBottomTexture, new Vector2(6, 3)); } _renderUtilities.RenderTexture( renderContext, new Vector2(layout.X, layout.Y), scrollableContainer.ChildContent, new Vector2(layoutWidth, layoutHeight)); }
public void DrawFlat(IRenderContext context, Rectangle layout) { _renderUtilities.RenderRectangle(context, layout, _basicSkin.SurfaceColor, true); _renderUtilities.RenderRectangle(context, layout, _basicSkin.LightEdgeColor); }
public void Render(IRenderContext renderContext, Rectangle layout, Canvas canvas) { _renderUtilities.RenderRectangle(renderContext, layout, new Color(162, 162, 162, 255), true); }
public void Render(IRenderContext renderContext, Rectangle layout, Canvas canvas) { _renderUtilities.RenderRectangle(renderContext, layout, _basicSkin.BackSurfaceColor, true); }
public override void Render(IGameContext gameContext, IRenderContext renderContext) { base.Render(gameContext, renderContext); if (renderContext.IsCurrentRenderPass <I2DBatchedRenderPass>()) { if (DetectedPoints != null) { foreach (var point in DetectedPoints) { _renderUtilities.RenderRectangle( renderContext, new Rectangle( (int)point.X * _detectorEntity.WidthScale, (int)point.Y * _detectorEntity.HeightScale, _detectorEntity.WidthScale, _detectorEntity.HeightScale), Color.Lime); } } if (TopLeft != null) { _renderUtilities.RenderText( renderContext, new Vector2(TopLeft.Value.X * _detectorEntity.WidthScale, TopLeft.Value.Y * _detectorEntity.HeightScale), "Top-Left", _defaultFont); } if (TopRight != null) { _renderUtilities.RenderText( renderContext, new Vector2(TopRight.Value.X * _detectorEntity.WidthScale, TopRight.Value.Y * _detectorEntity.HeightScale), "Top-Right", _defaultFont); } if (BottomLeft != null) { _renderUtilities.RenderText( renderContext, new Vector2(BottomLeft.Value.X * _detectorEntity.WidthScale, BottomLeft.Value.Y * _detectorEntity.HeightScale), "Bottom-Left", _defaultFont); } if (BottomRight != null) { _renderUtilities.RenderText( renderContext, new Vector2(BottomRight.Value.X * _detectorEntity.WidthScale, BottomRight.Value.Y * _detectorEntity.HeightScale), "Bottom-Right", _defaultFont); } } }
public void Render(IRenderContext renderContext, Rectangle layout, SingleContainer container) { _renderUtilities.RenderRectangle(renderContext, layout, new Color(194, 194, 194, 255), true); _renderUtilities.RenderRectangle(renderContext, new Rectangle(layout.X, layout.Y, layout.Width - 1, layout.Height - 1), new Color(0, 0, 0, 72), false); _renderUtilities.RenderRectangle(renderContext, new Rectangle(layout.X + 1, layout.Y + 1, layout.Width - 3, layout.Height - 3), new Color(23, 23, 23, 12), false); }