public override void DrawGraph(GameTime gameTime) { BasicShapes.DrawSolidPolygon(this.PrimitiveBatch, BackgroundPolygon, 4, Color.Black, true); float x = Bounds.X; float deltaX = Bounds.Width / (float)ValuesToGraph; float yScale = Bounds.Bottom - (float)Bounds.Top; // we must have at least 2 values to start rendering if (GraphValues.Count <= 2) { return; } // start at last value (newest value added) // continue until no values are left for (var i = GraphValues.Count - 1; i > 0; i--) { var y1 = Bounds.Bottom - ((GraphValues[i] / (AdaptiveMaximum - AdaptiveMinimum)) * yScale); var y2 = Bounds.Bottom - ((GraphValues[i - 1] / (AdaptiveMaximum - AdaptiveMinimum)) * yScale); var x1 = new Vector2(MathHelper.Clamp(x, Bounds.Left, Bounds.Right), MathHelper.Clamp(y1, Bounds.Top, Bounds.Bottom)); var x2 = new Vector2(MathHelper.Clamp(x + deltaX, Bounds.Left, Bounds.Right), MathHelper.Clamp(y2, Bounds.Top, Bounds.Bottom)); BasicShapes.DrawSegment(this.PrimitiveBatch, x1, x2, Color.DeepSkyBlue); x += deltaX; } }
public World(ContentManager content, Rectangle bounds, int width, int height) { LoadContent(content); Bounds = bounds; Shapes = new BasicShapes(); Fps = new FrameCounter(); Creatures = new List<Creature>(); for (int i = 0; i < CreatureCount; ++i) { Creatures.Add(new Creature(bounds, TxCreature, Color.White)); } Food = new List<Food>(); Obstacles = new List<Obstacle>(); AddFood(0); AddObstacles(0); Camera = new Camera(new Viewport(0, 0, width, height), width + width / 4, height); GA = new GeneticAlgorithm(75, 1); GraphValues = new double[30000]; DoDrawScene = true; DoDrawGraph = true; }
public static Geometry ToGeometry(this BasicShapes source) { if (source == BasicShapes.None) { return(null); } return(Clone(GeometryDictionary[source])); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); BasicShapes.LoadContent(GraphicsDevice, spriteBatch, ContentPath); drawAreaInset.LoadContent(GraphicsDevice, spriteBatch, 2, 2, 2); //drawTerrain.LoadContent(GraphicsDevice); // can only be done when route is known! }
internal override void Draw(ContentArea contentArea, ColorVariation colorVariation = ColorVariation.None) { Color color = GetColor <GridTile>(colorVariation); BasicShapes.DrawLine(1, color, contentArea.WorldToScreenCoordinates(lowerLeft), contentArea.WorldToScreenCoordinates(lowerRight), contentArea.SpriteBatch); BasicShapes.DrawLine(1, color, contentArea.WorldToScreenCoordinates(lowerRight), contentArea.WorldToScreenCoordinates(upperRight), contentArea.SpriteBatch); BasicShapes.DrawLine(1, color, contentArea.WorldToScreenCoordinates(lowerLeft), contentArea.WorldToScreenCoordinates(upperLeft), contentArea.SpriteBatch); BasicShapes.DrawLine(1, color, contentArea.WorldToScreenCoordinates(upperLeft), contentArea.WorldToScreenCoordinates(upperRight), contentArea.SpriteBatch); }
private void Generate() { var stopwatch = Stopwatch.StartNew(); cylinder = BasicShapes.CreateCylinder(vertexCount, radius, height, Quaternion.Euler(rotation)); GetComponent <MeshFilter>().sharedMesh = cylinder; stopwatch.Stop(); Debug.Log($"Generating took {stopwatch.Elapsed.TotalMilliseconds:F3}ms"); Debug.Log($"Cylinder stats | verts: {cylinder.vertexCount} | tris: {cylinder.triangles.Length / 3}"); }
/// <summary> /// Draw (print) the values of longitude and latitude /// </summary> /// <param name="editor">The patheditor for which we need to draw the status</param> public void Draw(PathEditor editor) { if (editor == null) { return; } if (!Properties.Settings.Default.showEditorAction) { return; } BasicShapes.DrawString(lowerLeft, DrawColors.colorsNormal.Text, editor.CurrentActionDescription); }
/// <summary> /// Creates a new basic shape and adds it to the document's active layer. /// </summary> /// <param name="basicShape"></param> /// <param name="bounds"></param> /// <param name="text"></param> /// <param name="styleSheetName"></param> /// <returns></returns> public NShape CreateBasicShape(BasicShapes basicShape, NRectangleF bounds, string text, string styleSheetName) { NBasicShapesFactory factory = new NBasicShapesFactory(document); NShape shape = factory.CreateShape((int)basicShape); shape.Bounds = bounds; shape.Text = text; shape.StyleSheetName = styleSheetName; document.ActiveLayer.AddChild(shape); return(shape); }
/// <summary> /// Creates a predefined basic shape /// </summary> /// <param name="basicShape">basic shape</param> /// <param name="bounds">bounds</param> /// <param name="text">default label text</param> /// <param name="styleSheetName">name of the stylesheet from which to inherit styles</param> /// <returns>new basic shape</returns> protected NShape CreateBasicShape(BasicShapes basicShape, NRectangleF bounds, string text, string styleSheetName) { NBasicShapesFactory factory = new NBasicShapesFactory(document); factory.DefaultSize = bounds.Size; NShape shape = factory.CreateShape((int)basicShape); shape.Location = bounds.Location; shape.Text = text; shape.StyleSheetName = styleSheetName; document.ActiveLayer.AddChild(shape); return(shape); }
/// <summary> /// /// </summary> /// <param name="basicShape"></param> /// <param name="bounds"></param> /// <param name="text"></param> /// <param name="fillStyle"></param> /// <param name="addToActiveLayer"></param> /// <returns></returns> public NShape CreateBasicShape(BasicShapes basicShape, NRectangleF bounds, string text, NFillStyle fillStyle, bool addToActiveLayer) { NBasicShapesFactory factory = new NBasicShapesFactory(document); NShape shape = factory.CreateShape((int)basicShape); shape.Bounds = bounds; shape.Text = text; shape.Style.FillStyle = (NFillStyle)fillStyle.Clone(); if (addToActiveLayer) { document.ActiveLayer.AddChild(shape); } return(shape); }
private BasicShape CreateNode(BasicShapes shape, double width, double height, double offsetx, double offsety, string labelText, string fillColor, string borderColor) { BasicShape node = new BasicShape(); node.Name = labelText; node.Width = width; node.Height = height; node.OffsetX = offsetx; node.OffsetY = offsety; node.FillColor = fillColor; node.BorderColor = borderColor; node.Shape = shape; Syncfusion.JavaScript.DataVisualization.Models.Diagram.Label label = new Syncfusion.JavaScript.DataVisualization.Models.Diagram.Label(); label.Text = labelText; label.FontColor = "white"; label.Name = labelText + "_label"; node.Labels.Add(label); return(node); }
/// <summary> /// Simplified Draw routine that only shows background and a message. /// </summary> /// <param name="message">The message you want to show</param> private void DrawLoadingMessage(string message) { // This is not really a game State, because it is not used interactively. In fact, Draw itself is // probably not called because the program is doing other things BeginDraw(); GraphicsDevice.Clear(DrawColors.colorsNormal.ClearWindow); spriteBatch.Begin(); // it is better to have integer locations, otherwise text is difficult to read Vector2 messageLocation = new Vector2((float)Math.Round(ScreenW / 2f), (float)Math.Round(ScreenH / 2f)); BasicShapes.DrawStringCentered(messageLocation, DrawColors.colorsNormal.Text, message); // we have to redo the string drawing, because we now first have to load the characters into textures. fontManager.Update(GraphicsDevice); BasicShapes.DrawStringCentered(messageLocation, DrawColors.colorsNormal.Text, message); spriteBatch.End(); EndDraw(); }
/// <summary> /// Draws the statistics. /// </summary> /// <param name="gameTime"></param> public override void Draw(GameTime gameTime) { _frameCounter++; // backup the raster and depth-stencil states. var previousRasterizerState = this.Game.GraphicsDevice.RasterizerState; var previousDepthStencilState = this.Game.GraphicsDevice.DepthStencilState; // set new states for drawing primitive shapes. this.Game.GraphicsDevice.RasterizerState = RasterizerState.CullNone; this.Game.GraphicsDevice.DepthStencilState = DepthStencilState.Default; _primitiveBatch.Begin(this._localProjection, this._localView); // initialize the primitive batch. BasicShapes.DrawSolidPolygon(this._primitiveBatch, this._backgroundPolygon, 4, Color.Black, true); _primitiveBatch.End(); // end the batch. // restore old states. this.Game.GraphicsDevice.RasterizerState = previousRasterizerState; this.Game.GraphicsDevice.DepthStencilState = previousDepthStencilState; // calculate drawn blocks if (this._chunkCache.ChunksDrawn >= 31) { _drawnBlocks = (this._chunkCache.ChunksDrawn / 31f).ToString("F2") + "M"; } else if (this._chunkCache.ChunksDrawn > 1) { _drawnBlocks = (this._chunkCache.ChunksDrawn / 0.03f).ToString("F2") + "K"; } else { _drawnBlocks = "0"; } // calculate total blocks if (this._chunkStorage.Count > 31) { _totalBlocks = (this._chunkStorage.Count / 31f).ToString("F2") + "M"; } else if (this._chunkStorage.Count > 1) { _totalBlocks = (this._chunkStorage.Count / 0.03f).ToString("F2") + "K"; } else { _totalBlocks = Core.Engine.Instance.Configuration.Chunk.Volume.ToString(CultureInfo.InvariantCulture); } _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); // Attention: DO NOT use string.format as it's slower than string concat. // FPS _stringBuilder.Length = 0; _stringBuilder.Append("fps:"); _stringBuilder.Append(this.FPS); _spriteBatch.DrawString(_spriteFont, _stringBuilder, new Vector2(this._bounds.X + 5, this._bounds.Y + 5), Color.White); // mem used _stringBuilder.Length = 0; _stringBuilder.Append("mem:"); _stringBuilder.Append(this.MemoryUsed.GetKiloString()); _spriteBatch.DrawString(_spriteFont, _stringBuilder, new Vector2(this._bounds.X + 105, this._bounds.Y + 5), Color.White); // chunks _stringBuilder.Length = 0; _stringBuilder.Append("chunks:"); _stringBuilder.AppendNumber(this._chunkCache.ChunksDrawn); _stringBuilder.Append('/'); _stringBuilder.AppendNumber(this._chunkStorage.Count); _spriteBatch.DrawString(_spriteFont, _stringBuilder, new Vector2(this._bounds.X + 205, this._bounds.Y + 5), Color.White); // blocks _stringBuilder.Length = 0; _stringBuilder.Append("blocks:"); _stringBuilder.Append(_drawnBlocks); _stringBuilder.Append('/'); _stringBuilder.Append(_totalBlocks); _spriteBatch.DrawString(_spriteFont, _stringBuilder, new Vector2(this._bounds.X + 305, this._bounds.Y + 5), Color.White); // process queues. this.GenerateQueue = this._chunkCache.StateStatistics[ChunkState.AwaitingGenerate] + this._chunkCache.StateStatistics[ChunkState.Generating]; this.LightenQueue = this._chunkCache.StateStatistics[ChunkState.AwaitingLighting] + this._chunkCache.StateStatistics[ChunkState.Lighting] + this._chunkCache.StateStatistics[ChunkState.AwaitingRelighting]; this.BuildQueue = this._chunkCache.StateStatistics[ChunkState.AwaitingBuild] + this._chunkCache.StateStatistics[ChunkState.Building] + this._chunkCache.StateStatistics[ChunkState.AwaitingRebuild]; this.ReadyQueue = this._chunkCache.StateStatistics[ChunkState.Ready]; this.RemovalQueue = this._chunkCache.StateStatistics[ChunkState.AwaitingRemoval]; // chunk generation queue _stringBuilder.Length = 0; _stringBuilder.Append("GenerateQ:"); _stringBuilder.AppendNumber(this.GenerateQueue); _spriteBatch.DrawString(_spriteFont, _stringBuilder, new Vector2(this._bounds.X + 450, this._bounds.Y + 5), Color.White); // chunk lighting queue _stringBuilder.Length = 0; _stringBuilder.Append("LightenQ:"); _stringBuilder.AppendNumber(this.LightenQueue); _spriteBatch.DrawString(_spriteFont, _stringBuilder, new Vector2(this._bounds.X + 550, this._bounds.Y + 5), Color.White); // chunk build queue _stringBuilder.Length = 0; _stringBuilder.Append("BuildQ:"); _stringBuilder.AppendNumber(this.BuildQueue); _spriteBatch.DrawString(_spriteFont, _stringBuilder, new Vector2(this._bounds.X + 650, this._bounds.Y + 5), Color.White); // ready chunks queue _stringBuilder.Length = 0; _stringBuilder.Append("Ready:"); _stringBuilder.AppendNumber(this.ReadyQueue); _spriteBatch.DrawString(_spriteFont, _stringBuilder, new Vector2(this._bounds.X + 750, this._bounds.Y + 5), Color.White); // chunk removal queue _stringBuilder.Length = 0; _stringBuilder.Append("Removal:"); _stringBuilder.AppendNumber(this.RemovalQueue); _spriteBatch.DrawString(_spriteFont, _stringBuilder, new Vector2(this._bounds.X + 850, this._bounds.Y + 5), Color.White); // infinitive world _stringBuilder.Length = 0; _stringBuilder.Append("inf:"); _stringBuilder.Append(Core.Engine.Instance.Configuration.World.IsInfinitive ? "On" : "Off"); _spriteBatch.DrawString(_spriteFont, _stringBuilder, new Vector2(this._bounds.X + 5, this._bounds.Y + 15), Color.White); // fly _stringBuilder.Length = 0; _stringBuilder.Append("fly:"); _stringBuilder.Append(this._player.FlyingEnabled ? "On" : "Off"); _spriteBatch.DrawString(_spriteFont, _stringBuilder, new Vector2(this._bounds.X + 105, this._bounds.Y + 15), Color.White); // fog _stringBuilder.Length = 0; _stringBuilder.Append("fog:"); _stringBuilder.Append(this._fogger.State); _spriteBatch.DrawString(_spriteFont, _stringBuilder, new Vector2(this._bounds.X + 205, this._bounds.Y + 15), Color.White); // player position _stringBuilder.Length = 0; _stringBuilder.Append("pos:"); _stringBuilder.Append(this._player.Position); _spriteBatch.DrawString(_spriteFont, _stringBuilder, new Vector2(this._bounds.X + 305, this._bounds.Y + 15), Color.White); _spriteBatch.End(); }
/// <summary> /// Set the shape of this Picture to one in the BasicShapes enumeration. /// </summary> /// <param name="shape">A shape from the BasicShapes enumeration.</param> public void SetPictureShape(BasicShapes shape) { SetPictureShape((object)shape); }
/// <summary> /// Set the shape of this Picture to one in the BasicShapes enumeration. /// </summary> /// <param name="shape">A shape from the BasicShapes enumeration.</param> public void SetPictureShape(BasicShapes shape) { SetPictureShape((object)shape); }
/// <summary> /// /// </summary> /// <param name="basicShape"></param> /// <param name="bounds"></param> /// <param name="text"></param> /// <param name="fillStyle"></param> /// <returns></returns> public NShape CreateBasicShape(BasicShapes basicShape, NRectangleF bounds, string text, NFillStyle fillStyle) { return(CreateBasicShape(basicShape, bounds, text, fillStyle, true)); }
private Node CreateNode(string name, double width, double height, double offsetx, double offsety, BasicShapes shape, string text, double corner, string fillColor, double opacity) { BasicShape node = new BasicShape(); node.Name = name; node.Width = width; node.Height = height; node.OffsetX = offsetx; node.OffsetY = offsety; node.FillColor = fillColor; node.CornerRadius = corner; node.Type = Shapes.Basic; node.BorderColor = "transparent"; node.Opacity = opacity; Syncfusion.JavaScript.DataVisualization.Models.Diagram.Label label = new Label() { Text = text, FontSize = 18, FontFamily = "segoe", FontColor = "white", Bold = true }; node.Labels.Add(label); if (shape != null) { node.Shape = shape; } else { node.Shape = BasicShapes.Rectangle; } return(node); }