public override void Render(DrawingHandleWorld handle) { if (onGrid) { var viewportSize = (Vector2)pManager._clyde.ScreenSize; var position = pManager.eyeManager.ScreenToMap(Vector2.Zero); var gridstart = pManager.eyeManager.WorldToScreen(new Vector2( //Find snap grid closest to screen origin and convert back to screen coords (float)(Math.Round(position.X / snapSize - 0.5f, MidpointRounding.AwayFromZero) + 0.5f) * snapSize, (float)(Math.Round(position.Y / snapSize - 0.5f, MidpointRounding.AwayFromZero) + 0.5f) * snapSize)); for (var a = gridstart.X; a < viewportSize.X; a += snapSize * 32) //Iterate through screen creating gridlines { var from = ScreenToWorld(new Vector2(a, 0)); var to = ScreenToWorld(new Vector2(a, viewportSize.Y)); handle.DrawLine(from, to, new Color(0, 0, 1f)); } for (var a = gridstart.Y; a < viewportSize.Y; a += snapSize * 32) { var from = ScreenToWorld(new Vector2(0, a)); var to = ScreenToWorld(new Vector2(viewportSize.X, a)); handle.DrawLine(from, to, new Color(0, 0, 1f)); } } // Draw grid BELOW the ghost thing. base.Render(handle); }
public override void Render(DrawingHandleWorld handle) { if (Grid != null) { var viewportSize = (Vector2)pManager._clyde.ScreenSize; var gridPosition = Grid.MapToGrid(pManager.eyeManager.ScreenToMap(Vector2.Zero)); var gridstart = pManager.eyeManager.CoordinatesToScreen( gridPosition.WithPosition(new Vector2(MathF.Floor(gridPosition.X), MathF.Floor(gridPosition.Y)))); for (var a = gridstart.X; a < viewportSize.X; a += SnapSize * EyeManager.PixelsPerMeter) //Iterate through screen creating gridlines { var from = ScreenToWorld(new Vector2(a, 0)); var to = ScreenToWorld(new Vector2(a, viewportSize.Y)); handle.DrawLine(from, to, new Color(0, 0, 1f)); } for (var a = gridstart.Y; a < viewportSize.Y; a += SnapSize * EyeManager.PixelsPerMeter) { var from = ScreenToWorld(new Vector2(0, a)); var to = ScreenToWorld(new Vector2(viewportSize.X, a)); handle.DrawLine(from, to, new Color(0, 0, 1f)); } } // Draw grid BELOW the ghost thing. base.Render(handle); }
public override void Render(DrawingHandleWorld handle) { if (onGrid) { const int ppm = EyeManager.PIXELSPERMETER; var viewportSize = (Vector2)pManager.DisplayManager.ScreenSize; var position = pManager.eyeManager.ScreenToWorld(Vector2.Zero); var gridstartx = (float)Math.Round(position.X / snapSize, MidpointRounding.AwayFromZero) * snapSize; var gridstarty = (float)Math.Round(position.Y / snapSize, MidpointRounding.AwayFromZero) * snapSize; var gridstart = pManager.eyeManager.WorldToScreen( new Vector2( //Find snap grid closest to screen origin and convert back to screen coords gridstartx, gridstarty)); for (var a = gridstart.X; a < viewportSize.X; a += snapSize * ppm) //Iterate through screen creating gridlines { var from = ScreenToWorld(new Vector2(a, 0)); var to = ScreenToWorld(new Vector2(a, viewportSize.Y)); handle.DrawLine(from, to, new Color(0, 0, 1f), 0.5f); } for (var a = gridstart.Y; a < viewportSize.Y; a += snapSize * ppm) { var from = ScreenToWorld(new Vector2(0, a)); var to = ScreenToWorld(new Vector2(viewportSize.X, a)); handle.DrawLine(from, to, new Color(0, 0, 1f), 0.5f); } } // Draw grid BELOW the ghost. base.Render(handle); }