public DrawRectangle ( RawRectangleF rect, Brush brush ) : void | ||
rect | RawRectangleF | The dimensions of the rectangle to draw, in device-independent pixels. |
brush | Brush | The brush used to paint the rectangle's stroke. |
return | void |
internal void Render() { if (!IsRendererSuppressed) { if (RenderTarget != null) { if (!RenderTarget.IsDisposed) { CountFPS(); // === Start count frame time RenderTarget.BeginDraw(); RenderTarget.Clear(SceneManager.CurrentScene.BackgroundColor.RawColor); for (int obj = 0; obj < SceneManager.CurrentScene.GameObjects.Count; obj++) { SceneManager.CurrentScene.GameObjects[obj].GetComponent <IRenderable>().OnRender(RenderFrame); RenderTarget.Transform = Matrix3x2.Identity; } if (Debugging.DrawBounds) { for (int obj = 0; obj < SceneManager.CurrentScene.GameObjects.Count; obj++) { RenderTarget.DrawRectangle(SceneManager.CurrentScene.GameObjects[obj].Transform.DrawingBoundings.RawRectangle, DrawingBoundsBrush); RenderTarget.DrawRectangle(SceneManager.CurrentScene.GameObjects[obj].CollisionBox.ColliderBounds, CollisionBoxesBrush); RenderTarget.Transform = Matrix3x2.Identity; } } RenderTarget.Transform = Matrix3x2.Identity; RenderTarget.EndDraw(); switch (GameWindow.Current.WindowParameters.VSyncMode) { case VSyncMode.Off: SwapChain.Present(0, DXGI.PresentFlags.None); break; case VSyncMode.On: SwapChain.Present(1, DXGI.PresentFlags.None); break; case VSyncMode.Half: SwapChain.Present(2, DXGI.PresentFlags.None); break; } Clock.Restart(); // === End count frame time } } } }
public void OnRender(RenderTarget target) { if(gBorderBrush == null) { gBackgroundBrush = Brushes.Solid[0xCC555555]; gBackgroundHoverBrush = Brushes.Solid[0xCC888888]; gClickBrush = Brushes.Solid[0xFFFF7F00]; gBackgroundClickedBrush = Brushes.Solid[0xCCBBBBBB]; gBorderBrush = Brushes.White; } target.DrawTextLayout(new Vector2(Position.X + Size + 7, Position.Y - 2), mTextDraw, Brushes.White); var brush = gBackgroundBrush; if (mIsPressed) brush = gBackgroundClickedBrush; else if (mIsHovered) brush = gBackgroundHoverBrush; target.FillRectangle(mTargetRect, brush); target.DrawRectangle(mTargetRect, gBorderBrush); if (!Checked) return; target.DrawLine(Position + new Vector2(3, 3), Position + new Vector2(mSize - 3, mSize - 3), gClickBrush, mSize / 4.0f); target.DrawLine(new Vector2(Position.X + 3, Position.Y + mSize - 3), new Vector2(Position.X + mSize - 3, Position.Y + 3), gClickBrush, mSize / 4.0f); }
/// <summary> /// Draws the outline of a rectangle. /// </summary> /// <param name="pen">The pen.</param> /// <param name="rect">The rectangle bounds.</param> /// <param name="cornerRadius">The corner radius.</param> public void DrawRectangle(Pen pen, Rect rect, float cornerRadius) { using (var brush = CreateBrush(pen.Brush, rect.Size)) using (var d2dStroke = pen.ToDirect2DStrokeStyle(_renderTarget)) { if (brush.PlatformBrush != null) { if (cornerRadius == 0) { _renderTarget.DrawRectangle( rect.ToDirect2D(), brush.PlatformBrush, (float)pen.Thickness, d2dStroke); } else { _renderTarget.DrawRoundedRectangle( new RoundedRectangle { Rect = rect.ToDirect2D(), RadiusX = cornerRadius, RadiusY = cornerRadius }, brush.PlatformBrush, (float)pen.Thickness, d2dStroke); } } } }
public override void Render(RenderTarget pRender, float pPercent) { pRender.Transform = Matrix3x2.Identity; RectangleF rect = new RectangleF(x, y, width, height); pRender.FillRectangle(rect, highlight ? highlightBrush : backBrush); pRender.DrawRectangle(rect, borderBrush); pRender.DrawTextLayout(new Vector2(x + dx * (pPercent - 1), y + dy * (pPercent - 1)), textLayout, textBrush); }
//--------------------------------------------------------------------------------------------------------- /// <summary> /// Рисование прямоугольника /// </summary> //--------------------------------------------------------------------------------------------------------- public override void Draw() { Direct2D.RenderTarget render_target = XDirect2DManager.D2DRenderTarget; if (mIsFilled) { render_target.FillRectangle(mBoundsRect.ToRawRectF(), mFill.D2DBrush); } if (mIsStroked) { render_target.DrawRectangle(mBoundsRect.ToRawRectF(), mStroke.Brush.D2DBrush, mStroke.Thickness, mStroke.mD2DStrokeStyle); } }
public void DrawRectangle(Rect frame, Pen pen = null, Brush brush = null) { var p = GetBrush(pen); var b = GetBrush(frame, brush); if (b != null) { renderTarget.FillRectangle(frame.ToRectangleF(), b); } if (p != null) { renderTarget.DrawRectangle(frame.ToRectangleF(), p, (float)pen.Width, GetStrokeStyle(pen)); } }
public void EndDraw() { if (!IsFinished) { Target.Transform = Matrix3x2.Translation(-_x.RealTime - _originOffsetX, -_y.RealTime - _originOffsetY) * Matrix3x2.Scaling(_vx.RealTime, _vy.RealTime) * Matrix3x2.Rotation(_r.RealTime) * Matrix3x2.Translation(_x.RealTime + _originOffsetX, _y.RealTime + _originOffsetY); if (_f.RealTime > 0) { Target.DrawBitmap(Bitmap, Rect.RealTime, _f.RealTime, D2D.BitmapInterpolationMode.Linear /*, RtInRect*/); //todo: bug #if DEBUG Target.DrawRectangle(Rect.RealTime, _redBrush, 1); #endif } Target.Transform = new Matrix3x2(1, 0, 0, 1, 0, 0); } else { Target.Transform = Matrix3x2.Translation(-_x.RealTime - _originOffsetX, -_y.RealTime - _originOffsetY) * Matrix3x2.Scaling(_vx.RealTime, _vy.RealTime) * Matrix3x2.Rotation(_r.RealTime) * Matrix3x2.Translation(_x.RealTime + _originOffsetX, _y.RealTime + _originOffsetY); //if (EnableLog) LogUtil.LogInfo(string.Format("[{0},{1},{2},{3}]", InRect.RealTime.Left, // InRect.RealTime.Top, InRect.RealTime.Right, InRect.RealTime.Bottom)); //Target.FillOpacityMask(Bitmap, _brush, D2D.OpacityMaskContent.TextGdiCompatible, Rect.Target, null); if (_f.Target > 0) { Target.DrawBitmap(Bitmap, Rect.Target, _f.Target, D2D.BitmapInterpolationMode.Linear /*, TarInRect*/); //todo: bug #if DEBUG Target.DrawRectangle(Rect.Target, _redBrush, 1); #endif } Target.Transform = new Matrix3x2(1, 0, 0, 1, 0, 0); } }
public void Draw(RenderTarget g) { g.DrawRectangle(Bounds, Resources.SCBRUSH_RED, 2f); foreach(BaseEntity ent in Objects) { g.DrawText(Level.ToString(), Resources.TEXT_FORMAT, ent.Hitbox, Resources.SCBRUSH_RED); } for (int i = 0; i < Nodes.Length; i++) { if (Nodes[i] != null) { Nodes[i].Draw(g); } } }
/// <summary> /// Draws the given rectangle with the given brush. /// </summary> public void DrawRectangle(RectangleF rectangle, BrushResource brush, float strokeWidth = 1f) { if (m_renderTarget == null) { return; } brush.EnsureNotNull(nameof(brush)); rectangle.EnsureNotEmpty(nameof(rectangle)); strokeWidth.EnsurePositive(nameof(strokeWidth)); m_renderTarget.DrawRectangle( rectangle.ToDXRectangle(), brush.GetBrush(m_device), strokeWidth); }
public void OnRender(RenderTarget target) { if (gBorder == null) InitBrushes(); if(mIsHovered || mIsClicked) { if (mIsClicked) target.FillRectangle(mTargetRect, gClick); else if (mIsHovered) target.FillRectangle(mTargetRect, gHover); target.DrawRectangle(mTargetRect, gBorder); } target.DrawBitmap(mImage.GetBitmap(), mImageRect, 1.0f, BitmapInterpolationMode.Linear); }
//--------------------------------------------------------------------------------------------------------- /// <summary> /// Рисование изображения /// </summary> //--------------------------------------------------------------------------------------------------------- public override void Draw() { Direct2D.RenderTarget render_target = XDirect2DManager.D2DRenderTarget; if (mIsFilled) { render_target.FillRectangle(mBoundsRect.ToRawRectF(), mFill.D2DBrush); } if (mD2DBitmap != null) { render_target.DrawBitmap(mD2DBitmap, mBoundsRect.ToRawRectF(), 1.0f, Direct2D.BitmapInterpolationMode.NearestNeighbor); } if (mIsStroked) { render_target.DrawRectangle(mBoundsRect.ToRawRectF(), mStroke.Brush.D2DBrush, mStroke.Thickness, mStroke.mD2DStrokeStyle); } }
public override void Render( RenderTarget target ) { target.Clear( new RawColor4( 1.0f, 1.0f, 1.0f, 1.0f ) ); Brush brush = null; switch( rnd.Next( 3 ) ) { case 0: brush = resCache["RedBrush" ] as Brush; break; case 1: brush = resCache["GreenBrush"] as Brush; break; case 2: brush = resCache["BlueBrush" ] as Brush; break; } target.DrawRectangle( new RawRectangleF( x, y, x + w, y + h ), brush ); x = x + dx; y = y + dy; if ( x >= ActualWidth - w || x <= 0 ) { dx = -dx; } if ( y >= ActualHeight - h || y <= 0 ) { dy = -dy; } }
private void OnRender(D2D.RenderTarget renderTarget) { var brush = new D2D.SolidColorBrush(_d2DRenderTarget, new RawColor4(1, 0, 0, 1)); renderTarget.Clear(null); renderTarget.DrawRectangle(new RawRectangleF(_x, _y, _x + 10, _y + 10), brush); _x = _x + _dx; _y = _y + _dy; if (_x >= ActualWidth - 10 || _x <= 0) { _dx = -_dx; } if (_y >= ActualHeight - 10 || _y <= 0) { _dy = -_dy; } }
public void OnRender(RenderTarget target) { UpdateCaret(); var transform = target.Transform; target.Transform *= Matrix3x2.Translation(Position); target.AntialiasMode = AntialiasMode.Aliased; target.FillRectangle(new RectangleF(0, 0, mSize.X, mSize.Y), Brushes.Solid[0xCC111111]); target.DrawRectangle(new RectangleF(0, 0, mSize.X, mSize.Y), Brushes.Solid[System.Drawing.Color.White]); target.PushAxisAlignedClip(new RectangleF(4, 0, mSize.X - 8, mSize.Y), AntialiasMode.Aliased); target.DrawTextLayout(new Vector2(mStartPosition, 0), mTextDraw, Brushes.Solid[0xFFFFFFFF]); target.PopAxisAlignedClip(); if (mCaretVisible && mIsFocused) { target.DrawLine(new Vector2(mCaretOffset, 4), new Vector2(mCaretOffset, 23), Brushes.Solid[0xFFFFFFFF], 2.0f); } target.Transform = transform; }
protected override void Draw(D2D1.RenderTarget renderTarget) { renderTarget.Clear(Color.Black); var screenRects = Screen.AllScreens.Select(screen => screen.Bounds) .Select(SharpDXUtils.ToRawRectangleF) .ToArray(); var displayBounds = screenRects.GetBounds(); var clientSize = ClientSize; var scale = Math.Min(clientSize.Width / displayBounds.Width(), clientSize.Height / displayBounds.Height()) * 0.9F; var pixelDrawingScale = 1 / scale; var lineThickness = pixelDrawingScale * 2; var pointSize = pixelDrawingScale * 5; renderTarget.Transform = ((RawMatrix3x2)SharpDX.Matrix3x2.Identity) .Translate(clientSize.Width / 2F, clientSize.Height / 2F) .Scale(scale).Translate(displayBounds.Center().Multiply(-1)); SolidColorBrush.Color = Color.White; foreach (var rect in screenRects) { renderTarget.DrawRectangle(rect, SolidColorBrush, lineThickness); } lock (_gazePoints) { var count = 0; foreach (var gazePoint in _gazePoints) { var alpha = 1 - (float)count++ / _historyCount; SolidColorBrush.Color = new RawColor4(1, 0, 0, alpha * alpha); renderTarget.FillEllipse(new D2D1.Ellipse(gazePoint, pointSize, pointSize), SolidColorBrush); } } }
public void DrawRectangle(Rect frame, Size corner, Pen pen = null, Brush brush = null) { var p = GetBrush(pen); var b = GetBrush(frame, brush); if (b != null) { if (corner.Width > 0 || corner.Height > 0) { var rr = new D2D1.RoundedRectangle(); rr.Rect = frame.ToRectangleF(); rr.RadiusX = (float)corner.Width; rr.RadiusY = (float)corner.Height; renderTarget.FillRoundedRectangle(ref rr, b); } else { renderTarget.FillRectangle(frame.ToRectangleF(), b); } } if (p != null) { if (corner.Width > 0 || corner.Height > 0) { var rr = new D2D1.RoundedRectangle(); rr.Rect = frame.ToRectangleF(); rr.RadiusX = (float)corner.Width; rr.RadiusY = (float)corner.Height; renderTarget.DrawRoundedRectangle(ref rr, p, (float)pen.Width, GetStrokeStyle(pen)); } else { renderTarget.DrawRectangle(frame.ToRectangleF(), p, (float)pen.Width, GetStrokeStyle(pen)); } } }
public void OnRender(RenderTarget target) { target.AntialiasMode = AntialiasMode.Aliased; target.FillRectangle(mClientRectangle, gBackground); target.DrawRectangle(mClientRectangle, gBorder); if (HasCaption) { target.FillRectangle(mCaptionRect, gBorder); target.DrawTextLayout(new Vector2(Position.X + 5, Position.Y - 18.0f), mCaptionText, gCaptionText); } var oldTransform = target.Transform; target.Transform *= mTransform; target.PushAxisAlignedClip(mClipRect, AntialiasMode.Aliased); lock(Children) foreach (var child in Children) child.OnRender(target); target.PopAxisAlignedClip(); target.Transform = oldTransform; }
public virtual void Draw(RenderTarget g) { //Texture draw call if (Texture != null) { DrawingPositionRect = new RectangleF(X - Game.VIEWPORT.X, Y - Game.VIEWPORT.Y, Width, Height); Texture.DrawTexture(g, new RectangleF(X, Y, Width, Height)); } //Debug drawing options if (Config.DEBUG_MODE == DebugMode.DISPLAY_HITBOX) { g.DrawRectangle(new RectangleF(Hitbox.X, Hitbox.Y, Hitbox.Width, Hitbox.Height), Resources.SCBRUSH_RED); } else if (Config.DEBUG_MODE == DebugMode.DISPLAY_RECT) { g.DrawRectangle(new RectangleF(X, Y, Width, Height), Resources.SCBRUSH_RED); g.DrawLine(new Vector2(X, Y), new Vector2(X + Width, Y + Height), Resources.SCBRUSH_RED); g.DrawLine(new Vector2(X, Y + Height), new Vector2(X + Width, Y), Resources.SCBRUSH_RED); } /* Used for debug purposes if (drawHitbox) g.DrawRectangle(Hitbox, Resources.SCBRUSH_BLACK, 3f); */ }
private void OnEditViewportDrawPrimitives(Device device, RenderTarget target2D, Rectangle cliprectangle) { UiEncodingWindowSource source = _currentSource; WflContent info = source?.Info; if (info?.Header.TableType != WflHeader.LargeTable) return; int viewportX = _editViewport.X; int viewportY = _editViewport.Y; RectangleF rectangle = new RectangleF {Height = info.Header.LineHeight}; target2D.BeginDraw(); for (int i = 0; i < 256 * 2; i++) { if (i % 256 < 0x20) continue; int x, y; info.GetOffsets(i, out x, out y); x -= viewportX; y -= viewportY; byte before, width, after; info.GetSizes(i, out before, out width, out after); rectangle.X = x; rectangle.Y = y; rectangle.Width = width & 0x7F; if (_charactersControl.CurrentMainIndices.Contains(i)) { target2D.FillRectangle(rectangle, _selectedColorBrush); if (before > 0x7F) { rectangle.Width = (0xFF - before) + 1; rectangle.X = x; } else { rectangle.Width = before; rectangle.X = x - before; } target2D.FillRectangle(rectangle, _spacingColorBrush); if (after > 0x7F) { rectangle.Width = (0xFF - after) + 1; rectangle.X = x + (width & 0x7F) - rectangle.Width; } else { rectangle.Width = after; rectangle.X = x + width & 0x7F; } target2D.FillRectangle(rectangle, _spacingColorBrush); } else if (source.Chars[i % 256] == 0x00) { target2D.FillRectangle(rectangle, _notMappedColorBrush); } else { target2D.DrawRectangle(rectangle, _gridColorBrush, 1.0f); } } int squareSize = info.Header.LineSpacing + info.Header.SquareDiff; rectangle.Height = squareSize; rectangle.Width = squareSize; for (int i = 0; i < info.AdditionalTable.Length; i++) { int value = info.AdditionalTable[i]; if (value == 0) continue; rectangle.Y = (value >> 8) * squareSize - viewportY; rectangle.X = (value & 0xFF) * squareSize - viewportX; if (_charactersControl.CurrentAdditionalIndices.Contains(i)) target2D.FillRectangle(rectangle, _selectedColorBrush); else if (source.Chars[i + 256] == 0x00) target2D.FillRectangle(rectangle, _notMappedColorBrush); else target2D.DrawRectangle(rectangle, _gridColorBrush, 1.0f); } target2D.EndDraw(); }
public void OnRender(RenderTarget target) { ++mFrameCount; var now = DateTime.Now; if((now - mLastMemorySample).TotalSeconds > 0.5f) { mLastMemorySample = now; mMemorySamples.Add(Environment.WorkingSet); while (mMemorySamples.Count > 20) mMemorySamples.RemoveAt(0); } if((now - mLastFpsSample).TotalSeconds >= 1.0f) { mFpsSamples.Add(mFrameCount / (float) (now - mLastFpsSample).TotalSeconds); mLastFpsSample = now; mFrameCount = 0; while (mFpsSamples.Count > 20) mFpsSamples.RemoveAt(0); } target.FillRectangle(mMemoryRectangle, Brushes.Solid[0xBB333333]); target.DrawRectangle(mMemoryRectangle, Brushes.White); target.FillRectangle(mFpsRectangle, Brushes.Solid[0xBB333333]); target.DrawRectangle(mFpsRectangle, Brushes.White); DrawMemorySamples(target); DrawFpsSamples(target); target.DrawTextLayout(new Vector2(Position.X, mMemoryRectangle.Top - 20.0f), mMemoryCaption, Brushes.White); target.DrawTextLayout(new Vector2(Position.X, mFpsRectangle.Top - 20.0f), mFpsCaption, Brushes.White); }
public static void DrawRectangle(this SharpDX.Direct2D1.RenderTarget target, ID2DPen pen, float x, float y, float width, float height) { var rect = new RawRectangleF(x, y, x + width, y + height); target.DrawRectangle(rect, pen.Brush.NativeBrush, pen.StrokeWidth, pen.StrokeStyle); }
public void DrawRectangle(Rectangle rect, Location where) { _renderTarget.DrawRectangle(rect.ToD2D(), brush); }