internal override void _window_DrawGraphics(object sender, DrawGraphicsEventArgs e) { if (!Loaded) { return; } if (!_windowLoaded) { return; } e.Graphics.ClearScene(); var layerUsed = false; if (!CurrentOpacity.CloseTo(1f)) { var lp = new LayerParameters() { ContentBounds = new RawRectangleF(0, 0, Window.Width, Window.Height), Opacity = CurrentOpacity }; e.Graphics.LayerHelper.AddOpacity(lp); layerUsed = true; } DxWindow.Draw(e.Graphics); OnDraw?.Invoke(sender, e); if (layerUsed) { e.Graphics.LayerHelper.RemoveOpacity(); } }
private void mapPanel_Paint(object sender, PaintEventArgs e) { if (mapImage != null) { double aspectRatioX = (double)mapPanel.Width / (double)mapImage.Width; double aspectRatioY = (double)mapPanel.Height / (double)mapImage.Height; ratio = aspectRatioX < aspectRatioY ? aspectRatioX : aspectRatioY; scaleHeight = Convert.ToInt32(mapImage.Height * ratio); scaleWidth = Convert.ToInt32(mapImage.Width * ratio); Rectangle destination = new Rectangle() { X = 0, Y = 0, Width = scaleWidth, Height = scaleHeight }; e.Graphics.TranslateTransform(mapPanel.Width / 2, mapPanel.Height / 2); e.Graphics.ScaleTransform(fibonacciZoom[zoomIndex], fibonacciZoom[zoomIndex]); e.Graphics.TranslateTransform(-mapPanel.Width / 2, -mapPanel.Height / 2); e.Graphics.TranslateTransform(drawSpotX, drawSpotY); e.Graphics.DrawImage(mapImage, destination); OnDraw?.Invoke(e.Graphics); e.Graphics.ResetTransform(); } e.Graphics.DrawLine(Pens.Yellow, 0, mapPanel.Height / 2, mapPanel.Width, mapPanel.Height / 2); e.Graphics.DrawLine(Pens.Yellow, mapPanel.Width / 2, 0, mapPanel.Width / 2, mapPanel.Height); }
/// <summary> /// Invalidate the current frame and draw + display a new frame. /// </summary> public void DrawGame() { screenInvalidated = true; if (container.chessBoardBitmap.Image != null) { container.chessBoardBitmap.Image.Dispose(); } container.chessBoardBitmap.Image = new Bitmap(container.chessBoardBitmap.Size.Width, container.chessBoardBitmap.Size.Height); tileWidth = container.chessBoardBitmap.Size.Width / (float)BoardSize; tileHeight = container.chessBoardBitmap.Size.Height / (float)BoardSize; for (int y = 0; y < BoardSize; y++) { for (int x = 0; x < BoardSize; x++) { DrawTile(new Point(x, y)); } } OnDraw?.Invoke(this, null); screenInvalidated = false; }
private void Draw(float time) { _dx11DeviceContext.ClearRenderTargetView(_renderView, Color); _dx11DeviceContext.ClearDepthStencilView(_depthView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0); OnDraw?.Invoke(time); _swapChain.Present(0, PresentFlags.None); }
/// <summary> /// Prepares the device for drawing and invoke OnDraw event /// </summary> /// <exception cref="System.Exception"> /// </exception> public void BeginDraw() { if (d3dContext == null) { throw new Exception(MethodBase.GetCurrentMethod().Name + "DeviceContext is null"); } if (d3dRenderTarget != null && viewport != null) { d3dContext.OutputMerger.SetRenderTargets(d3dDepthStencil, d3dRenderTarget); d3dContext.Rasterizer.SetViewport(viewport); d3dContext.ClearRenderTargetView(d3dRenderTarget, BackgroundColor); d3dContext.ClearDepthStencilView(d3dDepthStencil, D3D11.DepthStencilClearFlags.Depth | D3D11.DepthStencilClearFlags.Stencil, 1, 0); if (OnDraw != null) { OnDraw.Invoke(this, EventArgs.Empty); } } else { throw new Exception(MethodBase.GetCurrentMethod().Name + " RenderTarget or Viewport is null"); } }
public void Draw() { var tempBitmap = new Bitmap(drawable.Width, drawable.Height); var g = Graphics.FromImage(tempBitmap); population.First().Value.Draw(g); OnDraw?.Invoke(tempBitmap); }
void IThreadProcess.Update() { GL.Clear(ClearBufferMask.ColorBufferBit); OnDraw?.Invoke(); _window.SwapBuffers(); }
public override void Draw() { OnDraw?.Invoke(this, new DrawEventArgs($"It's square")); foreach (Point p in points) { p.Draw(); } }
public WebMapTileImage() { Image = new HTMLImageElement(); Image.OnLoad += (e) => { OnDraw?.Invoke(this, new EventArgs()); }; }
public IFuture<ICardAgent> Draw() { var cardModel = Model.Draw(); var futureAgent = New.Future<ICardAgent>(); var agent = Registry.Get<ICardAgent>(cardModel); OnDraw?.Invoke(agent); futureAgent.Value = agent; return futureAgent; }
protected override void Draw(GameTime gameTime) { _drawStopwatch.Start(); OnDraw?.Invoke(this, gameTime); _drawStopwatch.Stop(); DrawTime = (int)_drawStopwatch.ElapsedMilliseconds; _drawStopwatch.Reset(); }
static void Main(string[] args) { ContextSettings contextSettings = new ContextSettings() { DepthBits = 32, AntialiasingLevel = 8 }; Window = new RenderWindow(new VideoMode(700, 500), "Client", Styles.Default, contextSettings); Window.SetFramerateLimit(61); Window.SetActive(); Window.Closed += Window_Closed; Window.Resized += Window_Resized; sL = new GUI.ScanLines(); Program.CConsole = new GUI.Console(); TestMenu = new TestMenu(); Map = new GUI.Map(); /* * PlayerName = LoadName(); * CNetwork = new Network(); * CConsole = new GUI.Console(); * DebugView dv = new DebugView();*/ PreShakeView = Window.GetView(); Random random = new Random(DateTime.Now.Millisecond); while (Window.IsOpen()) { Window.DispatchEvents(); Window.Clear(new Color(50, 50, 50)); if (OnUpdate != null) { OnUpdate.Invoke(); } if (Shake) { View view = Window.GetView(); view.Move(new Vector2f(random.Next(-2, 3), random.Next(-2, 2))); Window.SetView(view); } else { View newView = new View(new FloatRect(0, 0, Window.Size.X, Window.Size.Y)); Window.SetView(newView); } ElapsedGameTime++; if (OnDraw != null) { OnDraw.Invoke(); } Window.Display(); } }
protected virtual async void OnFrame(object sender, RangeBaseValueChangedEventArgs e) { if (m_current_frame.HasValue && m_current_frame.Value != (int)m_slider.Value) { await GetRenderObjects(); OnDraw?.Invoke(); } m_current_frame = (int)m_slider.Value; }
//---------------------------------------// //----- MÉTODOS -----// //---------------------------------------// /// <summary> /// Desenha o ator. /// </summary> /// <param name="gameTime">Obtém acesso aos tempos de jogo.</param> /// <param name="spriteBatch">A instância do SpriteBatch para desenho.</param> public void Draw(GameTime gameTime, SpriteBatch spriteBatch) { if (Enable.IsVisible) { Components.Draw(gameTime, spriteBatch, ActorComponent.DrawPriority.Back); _Draw(gameTime, spriteBatch); OnDraw?.Invoke(this, gameTime, spriteBatch); Components.Draw(gameTime, spriteBatch, ActorComponent.DrawPriority.Forward); } }
public ShapeDrawerController() { client = new Client(); client.Start("127.0.0.1", 1111); client.OnShadeSelected += (o, e) => { ShapeDrawerPaint(e.Message.Shape); OnDraw?.Invoke(this, new ShapeEventArgs(e.Message.Shape)); }; }
private void Draw() { if (isPaused) { return; } _dx11DeviceContext.ClearRenderTargetView(_renderView, new SharpDX.Color(0, 0, 0)); _dx11DeviceContext.ClearDepthStencilView(_depthView, DX11.DepthStencilClearFlags.Depth | DX11.DepthStencilClearFlags.Stencil, 1.0f, 0); OnDraw?.Invoke(1); _swapChain.Present(0, PresentFlags.None); }
public void Draw() { if (_x >= 0 && _y >= 0) { OnDraw?.Invoke(this, new DrawEventArgs($"({_x},{_y})")); } else { throw new PointException("I can't draw in negative..."); } }
private void Canvas_OnDraw(DXCanvas canvas, DXCanvas.Layer layer) { Vector scale = new Vector(1.0 / Scroll.Area.Width, 1.0 / Scroll.Area.Height); Matrix cameraView = new Matrix(scale.X, 0, 0, scale.Y, -scale.X * Scroll.Area.Location.X, -scale.Y * Scroll.Area.Location.Y); canvas.CameraView = cameraView; Scroll.Size = new Size(canvas.RenderCanvas.ClientSize.Width / RenderSettings.DpiScale.X, canvas.RenderCanvas.ClientSize.Height / RenderSettings.DpiScale.Y); OnDraw?.Invoke(canvas, layer, Scroll); }
private void EmitDrawEvent(DrawState state, bool isEmpty = false) { OnDraw.Invoke(this, new DrawEventArgs() { DrawType = current.Shape, Shape = current.Element as Shape, IsEmpty = isEmpty, Area = current.ElementRect, State = state }); }
public override void Draw(RenderContext rc, CommandBuffer cb) { Clear(); if (OnDraw != null) { OnDraw.Invoke(this, rc, cb); } else { DrawScene(cb); } }
public void Draw(SpriteBatch sb) { float lastParallaxValue = float.NaN; foreach (IWorldObject obj in WorldObjects) { // skip objects that don't have anything to draw if (!(obj is IRenderedObject rObj)) { continue; } float parallaxValue = (obj is IParallaxable pObj) ? pObj.ParallaxMultiplier : 1.0f; if (parallaxValue != lastParallaxValue || rObj.DisableBatching) { // if it isn't the first time we begin a new SpriteBatch we'll first have to end the old one if (!float.IsNaN(lastParallaxValue)) { sb.End(); } Matrix transformMatrix = parallaxValue != 1.0f ? Camera.GetMatrix(parallaxValue) : Camera.GetMatrix(); sb.Begin(blendState: BlendState.AlphaBlend, rasterizerState: RasterizerState.CullNone, transformMatrix: transformMatrix); } rObj.Draw(sb, Camera); lastParallaxValue = parallaxValue; } sb.End(); if (Settings.DrawColliders) { sb.Begin(transformMatrix: Camera.GetMatrix()); foreach (ICollider collider in Colliders) { collider.Draw(sb, Camera, Color.Green, false); } sb.End(); } OnDraw?.Invoke(this, sb); }
private void Display() { // this is more or less part of what reshade/etc do to avoid having to manually // set the cursor inside the ui // This will just tell ImGui to draw its own software cursor instead of using the hardware cursor // The scene internally will handle hiding and showing the hardware (game) cursor // If the player has the game software cursor enabled, we can't really do anything about that and // they will see both cursors. // Doing this here because it's somewhat application-specific behavior //ImGui.GetIO().MouseDrawCursor = ImGui.GetIO().WantCaptureMouse; this.lastWantCapture = ImGui.GetIO().WantCaptureMouse; OnDraw?.Invoke(); }
protected override void Draw(GameTime gameTime) { if (UiThread == null) { UiThread = Thread.CurrentThread; } _drawStopwatch.Start(); OnDraw?.Invoke(this, gameTime); _drawStopwatch.Stop(); DrawTime = (int)_drawStopwatch.ElapsedMilliseconds; _drawStopwatch.Reset(); }
public override void DrawShapes(Camera cam) { if (!ShowPoint) { return; } using (Draw.Command(cam)) { Draw.Ring(transformPoint, BezierCurveManager.Instance.ControlPointRadius, pointColor); onDraw?.Invoke(); } }
/// <summary> /// Draw this entity. /// </summary> /// <param name="parent">Parent node that's currently drawing this entity.</param> /// <param name="localTransformations">Local transformations from the direct parent node.</param> /// <param name="worldTransformations">World transformations to apply on this entity (this is what you should use to draw this entity).</param> public override void Draw(Node parent, ref Matrix localTransformations, ref Matrix worldTransformations) { // not visible / no active camera? skip if (!Visible || GraphicsManager.ActiveCamera == null) { return; } // call draw callback OnDraw?.Invoke(this); // draw all meshes foreach (DictionaryEntry mesh in _meshes) { GraphicsManager.DrawEntity(mesh.Value as MeshEntity, worldTransformations); } }
/// <summary> /// Draw the state /// </summary> /// <param name="renderer"></param> internal void Draw(Renderer renderer) { //Begin rendering with camera renderer.Begin(RenderSortMode.Depth, Camera.TranslationMatrix); //Draw the background if (Background != null) { renderer.Draw(Background.Texture, Color.White, BackgroundDepth, new Rectangle(0, 0, Background.Width, Background.Height), Background.SourceRectangle, Background.Origin, Background.Rotation); } //Draw event OnDraw?.Invoke(this, new StateOnDrawEventArgs(renderer)); //Draw all instances lock (_instances) { foreach (var instance in _instances.Where(instance => instance != null) .Where(instance => instance.Draws)) { //Draw check if (DrawMode == DrawMode.DrawCheck && !Camera.Drawable(instance.Bounds)) { continue; } //Safezone check if (DrawMode == DrawMode.SafeArea && SafeZoneEnabled && !SafeZone.Contains(instance.Position)) { continue; } instance.Draw(renderer); } } renderer.End(); //Now draw User Interface without the camera translation renderer.Begin(RenderSortMode.Depth); UserInterface.Draw(renderer); renderer.End(); }
public void Draw(Image cameraSource) { if (DateTime.UtcNow > intervalEnd) { intervalEnd = DateTime.UtcNow.AddSeconds(1); fps = frameCount; frameCount = 0; } lock (mutex) // img disposed during resize - prevent error { backbufferGraphics.Clear(Color.Black); var imgSourceBmp = (Bitmap)cameraSource.Clone(); var imgSourceGraphics = Graphics.FromImage(imgSourceBmp); if (OnDraw != null) { OnDraw.Invoke(new DrawEventArgs(imgSourceGraphics, cameraSource)); } var newWidth = 0; var newHeight = 0; if (panel.Width < panel.Height) { var aspectRatio = (double)imgSourceBmp.Height / imgSourceBmp.Width; newWidth = (int)panel.Width; newHeight = (int)(newWidth * aspectRatio); } else { var aspectRatio = (double)imgSourceBmp.Width / imgSourceBmp.Height; newHeight = panel.Height; newWidth = (int)(newHeight * aspectRatio); } backbufferGraphics.DrawImage(imgSourceBmp, new Rectangle((panel.Width - newWidth) / 2, 0, newWidth, newHeight), new Rectangle(0, 0, imgSourceBmp.Width, imgSourceBmp.Height), GraphicsUnit.Pixel);// prevent flickering foregroundGraphics.DrawImage(backBuffer, new Point(0, 0)); } frameCount++; }
/// <summary> Отрисовка текста из буфера. </summary> public static void Flush() { OnDraw?.Invoke(); while (writeData.Count > 0) { WriteData wd = writeData.Dequeue(); if (wd.Text == null) { continue; } // set pos if (wd.X.HasValue) { Console.CursorLeft = wd.X.Value; } if (wd.Y.HasValue) { Console.CursorTop = wd.Y.Value; } // set color if (wd.ForeColor.HasValue) { Console.ForegroundColor = wd.ForeColor.Value; } if (wd.BackColor.HasValue) { Console.BackgroundColor = wd.BackColor.Value; } // write if (wd.Text.Length > Console.BufferWidth) { // fix width Console.Write(wd.Text.Substring(0, Console.BufferWidth - 3) + "..."); } else { Console.Write(wd.Text); } } }
public void Render(ref RenderWindow renderWindow) { DeltaTime = clock.Restart().AsSeconds(); renderWindow.Clear(Color.White); //FPS FPSText.DisplayedString = (1f / DeltaTime).ToString("00"); renderWindow.Draw(FPSText); AnimationManager.UpdateAll(); foreach (var obj in Children) { obj.Draw(ref renderWindow); } OnDraw?.Invoke(ref renderWindow); renderWindow.Display(); }
static void HandleTimerCallback(object state) { OnDraw?.Invoke(null, EventArgs.Empty); if (OnConsoleResized == null) { return; } try { var newSize = Size; if (newSize != _OldSize) { _OldSize = newSize; OnConsoleResized(null, EventArgs.Empty); } } catch (IOException) { } catch (ArgumentOutOfRangeException) { } }