public DrawLine ( RawVector2 point0, RawVector2 point1, Brush brush ) : void | ||
point0 | RawVector2 | The start point of the line, in device-independent pixels. |
point1 | RawVector2 | The end point of the line, in device-independent pixels. |
brush | Brush | The brush used to paint the line's stroke. |
Résultat | void |
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); }
protected void DrawHintAndInput() { if (!Paradigm.Config.Gui.InputBarVisibility) { return; } /* Draw Hint */ if (HintText != null) { SharedBrush.Color = new Color(ForegroundColor.R, ForegroundColor.G, ForegroundColor.B, 0.7F); RenderTarget.DrawText(HintText, InputTextFormat, new RawRectangleF(10, 0, Width - 10, InputBoxHeight / 2), SharedBrush, D2D1.DrawTextOptions.None); } /* Draw user input text */ if (InputTextLayout != null) { var rect = HintText == null ? new RawRectangleF(10, 5, Width - 10, InputBoxHeight - 5) : new RawRectangleF(10, InputBoxHeight / 2, Width - 10, InputBoxHeight); InputTextLayout.MaxWidth = rect.Right - rect.Left; InputTextLayout.MaxHeight = rect.Bottom - rect.Top; InputTextLayout.Draw(_customColorRenderer, rect.Left, rect.Top); } /* Draw Input Box Bottom Line */ SharedBrush.Color = ForegroundColor; RenderTarget.DrawLine(new RawVector2(10, InputBoxHeight + 2), new RawVector2(Width - 10, InputBoxHeight + 2), SharedBrush, 2); }
public static void DrawLine(this SharpDX.Direct2D1.RenderTarget target, ID2DPen pen, float x1, float y1, float x2, float y2) { var pt1 = new RawVector2(x1, y1); var pt2 = new RawVector2(x2, y2); target.DrawLine(pt1, pt2, pen.Brush.NativeBrush, pen.StrokeWidth, pen.StrokeStyle); }
public void Draw(double x, double y, double width, double height) { render.DrawLine(new Vector2((float)x, (float)(y)), new Vector2((float)(x + width - 1), (float)(y)), this.brush, this.thickness, this.stroke); }
//--------------------------------------------------------------------------------------------------------- /// <summary> /// Рисование линии /// </summary> //--------------------------------------------------------------------------------------------------------- public override void Draw() { Direct2D.RenderTarget render_target = XDirect2DManager.D2DRenderTarget; if (mIsStroked) { render_target.DrawLine(mStartPoint.ToRawVector2(), mEndPoint.ToRawVector2(), mStroke.Brush.D2DBrush, mStroke.Thickness, mStroke.mD2DStrokeStyle); } }
public void Create3dObjects() { //Create RenderWindow RenderWindowInstance = new ModelRenderWindow(); FormInstance = RenderWindowInstance.CreateWindow(1080,1240,FormStartPosition.CenterScreen); //Create SwapChain SwapChainCreator = new ModelSwapChainDesc(); SwapChainD = SwapChainCreator.CreateSwapChain(2, Usage.RenderTargetOutput, FormInstance.Handle, true, 0, 0, new Rational(60, 1), Format.R8G8B8A8_UNorm, 1,0,SwapChainFlags.AllowModeSwitch, SwapEffect.Discard); //Create Device Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, SwapChainD, out GraphicsDevice, out NewSwapChain); //Create Back buffer BackBuffer = Surface.FromSwapChain(NewSwapChain, 0); //Create Factory FactoryD2D FactoryInstance = new FactoryD2D(); //Create RenderTarget RenderTargetInstance = new ModelRenderTarget(); RenderTarget = RenderTargetInstance.CreateRenderTarget(SharpDX.Direct2D1.FeatureLevel.Level_DEFAULT, new PixelFormat(Format.Unknown, SharpDX.Direct2D1.AlphaMode.Ignore), RenderTargetType.Default, RenderTargetUsage.None, BackBuffer, FactoryInstance); RenderLoop.Run(FormInstance, () => { RenderTarget.BeginDraw(); RenderTarget.Transform = Matrix3x2.Identity; RenderTarget.Clear(Color.White); using (var brush = new SolidColorBrush(RenderTarget, Color.Red)) { //for (int x = 0; x < RenderTarget.Size.Width; x += 10) // RenderTarget.DrawLine(new Vector2(x, 0), new Vector2(x, RenderTarget.Size.Height), brush, 0.5f); //for (int y = 0; y < RenderTarget.Size.Height; y += 10) // RenderTarget.DrawLine(new Vector2(0, y), new Vector2(RenderTarget.Size.Width, y), brush, 0.5f); RenderTarget.DrawLine(new Vector2(300, 10), new Vector2(300, 300), brush,1.5f); // RenderTarget.FillRectangle(new RectangleF(RenderTarget.Size.Width / 2 - 50, RenderTarget.Size.Height / 2 - 50, 100, 100), brush); } // RenderTarget.DrawRectangle( // new RectangleF(RenderTarget.Size.Width / 2 - 100, RenderTarget.Size.Height / 2 - 100, 200, 200), // new SolidColorBrush(RenderTarget, Color.CornflowerBlue)); RenderTarget.EndDraw(); NewSwapChain.Present(0, PresentFlags.None); }); RenderTarget.Dispose(); NewSwapChain.Dispose(); GraphicsDevice.Dispose(); }
public void OnRender(RenderTarget target) { target.FillRectangle(new RectangleF(0, 0, mSize.X, mSize.Y), Brushes.Solid[0xFF333333]); target.PushAxisAlignedClip(new RectangleF(0, 100, mSize.X, mSize.Y - 100), AntialiasMode.Aliased); foreach (var label in mMapLabels) label.OnRender(target); target.PopAxisAlignedClip(); target.DrawLine(new Vector2(0, 100.0f), new Vector2(mSize.X, 100.0f), Brushes.White); mTitleLabel.OnRender(target); mLabelScroll.OnRender(target); }
/// <summary> /// Draws the given line with the given brush. /// </summary> public void DrawLine(Vector2 start, Vector2 end, BrushResource brush, float strokeWidth = 1f) { if (m_renderTarget == null) { return; } brush.EnsureNotNull(nameof(brush)); strokeWidth.EnsurePositiveAndNotZero(nameof(strokeWidth)); m_renderTarget.DrawLine( start.ToDXVector(), end.ToDXVector(), brush.GetBrush(m_device), strokeWidth); }
public void OnRender(RenderTarget target) { var borderStart = new Vector2(mPosition.X + BorderOffsets.X, mPosition.Y); var borderEnd = new Vector2(mPosition.X + mSize.X - BorderOffsets.Y, mPosition.Y); target.FillRectangle(mTargetRectangle, Brushes.Solid[0xCC333333]); target.DrawLine(borderStart, borderEnd, Brushes.White); var ot = target.Transform; target.Transform *= Matrix3x2.Translation(Position.X, Position.Y); foreach (var item in Items) item.OnRender(target); target.Transform = ot; }
public void Draw(ServiceResult serviceResult, float currentTime, float duration) { if (!uiInitialized) { return; } if (!redraw) { return; } redraw = false; target2d.BeginDraw(); target2d.Clear(new Color4(0, 0, 0, 0.7f)); target2d.DrawLine(new Vector2(0, 1), new Vector2(1024, 1), blueBrush, 2); target2d.DrawLine(new Vector2(0, 511), new Vector2(1024, 511), blueBrush, 2); textFormat.TextAlignment = SharpDX.DirectWrite.TextAlignment.Center; textFormatSmall.TextAlignment = SharpDX.DirectWrite.TextAlignment.Center; if (serviceResult.contentType == ServiceResult.ContentType.video) { target2d.DrawText("now playing:", textFormatSmall, new RectangleF(0, 0, 1024, 100), textBrush); target2d.DrawText(serviceResult.TitleWithFallback, textFormat, new RectangleF(0, 50, 1024, 100), textBrush); var barLength = 1024 - 265; var currentLength = barLength * (currentTime / duration); target2d.DrawLine(new Vector2(128, 384), new Vector2(1024 - 128, 384), textBrush, 6); target2d.DrawLine(new Vector2(128, 384), new Vector2(128 + currentLength, 384), blueBrush, 6); var ellipse = new DX2D.Ellipse(new Vector2(128 + currentLength + 3.5f, 384), 7, 7); target2d.FillEllipse(ellipse, blueBrush); target2d.DrawEllipse(new DX2D.Ellipse(new Vector2(512, 256), 48, 48), textBrush, 2); var dist = 8; var len = 10; target2d.DrawLine(new Vector2(512 - dist, 256 - len), new Vector2(512 - dist, 256 + len), textBrush, 2); target2d.DrawLine(new Vector2(512 + dist, 256 - len), new Vector2(512 + dist, 256 + len), textBrush, 2); textFormatSmall.TextAlignment = SharpDX.DirectWrite.TextAlignment.Trailing; target2d.DrawText((new TimeSpan(0, 0, (int)Math.Floor(duration))).ToString(), textFormatSmall, new Rectangle(1024 - 128 - 150, 384, 150, 50), textBrush); int positionx = (int)(128 + currentLength - 74 / 2); positionx = MathUtil.Clamp(positionx, 128, 1024 - 128 - 74); textFormatSmall.TextAlignment = SharpDX.DirectWrite.TextAlignment.Center; target2d.DrawText((new TimeSpan(0, 0, (int)Math.Floor(currentTime))).ToString(), textFormatSmall, new Rectangle(positionx, 340, 74, 32), textBrush); } target2d.EndDraw(); }
public Result DrawUnderline(object clientDrawingContext, float baselineOriginX, float baselineOriginY, ref DW.Underline underline, ComObject clientDrawingEffect) { D2D.RenderTarget render = clientDrawingContext as D2D.RenderTarget; if (render == null) { return(SharpDX.Result.Ok); } D2D.SolidColorBrush foreBrush = this.factory.GetSolidColorBrush(this.DefaultFore); DrawingEffect effect = clientDrawingEffect as DrawingEffect; if (clientDrawingEffect != null && effect != null) { foreBrush = this.factory.GetSolidColorBrush(effect.Fore); float thickness = effect.isBoldLine ? D2DRenderCommon.BoldThickness : D2DRenderCommon.NormalThickness; if (effect.Stroke == HilightType.Squiggle) { SquilleLineMarker marker = new D2DSquilleLineMarker(render, this.factory.GetSolidColorBrush(effect.Fore), this.factory.GetStroke(effect.Stroke), 1); marker.Draw( baselineOriginX, baselineOriginY + underline.Offset, underline.Width, underline.RunHeight ); } else { LineMarker marker = new LineMarker(render, this.factory.GetSolidColorBrush(effect.Fore), this.factory.GetStroke(effect.Stroke), GetThickness(render, thickness)); marker.Draw( baselineOriginX, baselineOriginY + underline.Offset, underline.Width, 0 ); } } if (effect == null) { render.DrawLine(new Vector2(baselineOriginX, baselineOriginY + underline.Offset), new Vector2(baselineOriginX + underline.Width - 1, baselineOriginY + underline.Offset), foreBrush, GetThickness(render, underline.Thickness)); } return(SharpDX.Result.Ok); }
/// <summary> /// Draws a line. /// </summary> /// <param name="pen">The stroke pen.</param> /// <param name="p1">The first point of the line.</param> /// <param name="p2">The second point of the line.</param> public void DrawLine(Pen pen, Point p1, Point p2) { if (pen != null) { var size = new Rect(p1, p2).Size; using (var d2dBrush = CreateBrush(pen.Brush, size)) using (var d2dStroke = pen.ToDirect2DStrokeStyle(_renderTarget)) { if (d2dBrush.PlatformBrush != null) { _renderTarget.DrawLine( p1.ToSharpDX(), p2.ToSharpDX(), d2dBrush.PlatformBrush, (float)pen.Thickness, d2dStroke); } } } }
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; }
public Result DrawStrikethrough(object clientDrawingContext, float baselineOriginX, float baselineOriginY, ref DW.Strikethrough strikethrough, ComObject clientDrawingEffect) { D2D.RenderTarget render = clientDrawingContext as D2D.RenderTarget; if (render == null) { return(SharpDX.Result.Ok); } D2D.SolidColorBrush foreBrush = this.factory.GetSolidColorBrush(this.DefaultFore); DrawingEffect effect = clientDrawingEffect as DrawingEffect; if (clientDrawingEffect != null && clientDrawingEffect != null) { foreBrush = this.factory.GetSolidColorBrush(effect.Fore); } if (effect == null) { render.DrawLine(new Vector2(baselineOriginX, baselineOriginY + strikethrough.Offset), new Vector2(baselineOriginX + strikethrough.Width - 1, baselineOriginY + strikethrough.Offset), foreBrush, GetThickness(render, strikethrough.Thickness)); } return(Result.Ok); }
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 DrawFpsSamples(RenderTarget target) { var maxValue = mFpsSamples.Max(); var minValue = mFpsSamples.Min(); if (MathUtil.WithinEpsilon(minValue, maxValue, 0.5f)) maxValue = minValue + 10; var baseOffset = 0.0f; var step = mSize.X / 19.0f; var diff = (DateTime.Now - mLastFpsSample); if (mFpsSamples.Count == 20) baseOffset = (float)diff.TotalSeconds * step; var curPos = mFpsRectangle.Left - baseOffset; var endY = mFpsRectangle.Bottom - 5; var height = mFpsRectangle.Height - 20; target.PushAxisAlignedClip(mFpsRectangle, AntialiasMode.Aliased); for (var i = 1; i < mFpsSamples.Count; ++i) { var sat = (mFpsSamples[i] - minValue) / (maxValue - minValue); var satPrev = (mFpsSamples[i - 1] - minValue) / (maxValue - minValue); target.DrawLine(new Vector2(curPos, endY - satPrev * height), new Vector2(curPos + step, endY - sat * height), Brushes.White); curPos += step; } var satLast = (mFpsSamples.Last() - minValue) / (maxValue - minValue); target.DrawLine(new Vector2(curPos, endY - satLast * height), new Vector2(curPos + (float)diff.TotalSeconds * step, endY - satLast * height), Brushes.White); target.PopAxisAlignedClip(); mFpsMin.Text = minValue.ToString("F2"); mFpsMax.Text = maxValue.ToString("F2"); target.DrawTextLayout(new Vector2(Position.X + 3.0f, mFpsRectangle.Top - 20.0f), mFpsMax, Brushes.White); target.DrawTextLayout(new Vector2(Position.X + 3.0f, mFpsRectangle.Bottom + 2.0f), mFpsMin, Brushes.White); }
private void DrawMemorySamples(RenderTarget target) { var maxValue = mMemorySamples.Max(); var minValue = mMemorySamples.Min(); if (minValue == maxValue) maxValue = minValue + 50; var baseOffset = 0.0f; var step = mSize.X / 19.0f; var diff = (DateTime.Now - mLastMemorySample); if (mMemorySamples.Count == 20) baseOffset = ((float)diff.TotalSeconds / 0.5f) * step; var curPos = mMemoryRectangle.Left - baseOffset; var endY = mMemoryRectangle.Bottom - 5; var height = mMemoryRectangle.Height - 20; target.PushAxisAlignedClip(mMemoryRectangle, AntialiasMode.Aliased); for (var i = 1; i < mMemorySamples.Count; ++i) { var sat = (mMemorySamples[i] - (float)minValue) / (maxValue - minValue); var satPrev = (mMemorySamples[i - 1] - (float)minValue) / (maxValue - minValue); target.DrawLine(new Vector2(curPos, endY - satPrev * height), new Vector2(curPos + step, endY - sat * height), Brushes.White); curPos += step; } var satLast = (mMemorySamples.Last() - (float) minValue) / (maxValue - minValue); target.DrawLine(new Vector2(curPos, endY - satLast * height), new Vector2(curPos + ((float)diff.TotalSeconds / 0.5f) * step, endY - satLast * height), Brushes.White); target.PopAxisAlignedClip(); DrawMemoryStrings(target, maxValue, minValue); }
public void DrawLine(Location From, Location To) { _renderTarget.DrawLine(From.ToD2D(), To.ToD2D(), brush); }
public void Draw(SharpDX.Direct2D1.RenderTarget renderTarget) { renderTarget.DrawLine(From, To, Color, StrokeWidth); }
protected override void Draw(D2D1.RenderTarget renderTarget) { renderTarget.Clear(Color.Black); double[][] samples; lock (_values) samples = _values.ToArray(); var sampleCount = samples.Length; double range; double[] chMeans; { var channelSums = new double[_channelNum]; var max = double.NegativeInfinity; var min = double.PositiveInfinity; foreach (var channels in samples) { for (var ch = 0; ch < channels.Length; ch++) { var channel = channels[ch]; channelSums[ch] += channel; if (max < channel) { max = channel; } if (min > channel) { min = channel; } } } range = max - (min + max) / 2; for (var i = 0; i < channelSums.Length; i++) { channelSums[i] /= sampleCount; } chMeans = channelSums; } var clientSize = ClientSize; var channelHeight = clientSize.Height / (float)_channelNum; var sampleInterval = clientSize.Width / (float)_windowLength; RawVector2 Point(float xOffset, float yOffset, int sIdx, int chIdx) => new RawVector2(xOffset, (float)(yOffset + channelHeight / 2 + (samples[sIdx][chIdx] - chMeans[chIdx]) / range * channelHeight / 2 * 0.9)); SolidColorBrush.Color = Color.White; if (!samples.IsEmpty()) { for (var ch = 0; ch < _channelNum; ch++) { var yOffset = ch * channelHeight; var xOffset = (float)Width; var s = samples.Length - 1; var prev = Point(xOffset, yOffset, s, ch); for (; s >= 0; s--) { xOffset -= sampleInterval; var current = Point(xOffset, yOffset, s, ch); renderTarget.DrawLine(prev, current, SolidColorBrush, 2); prev = current; } } } }
/// <summary> /// render the circle to specific render target of Direct2D1 /// </summary> /// <param name="renderTarget"></param> public void Render2D( RenderTarget renderTarget, SharpDX.Direct2D1.Brush brush ) { // if the brush is dirty renew it if ( m_isLineColorBrushDirty ) { // clean the color brush if ( m_lineColorBrush != null ) m_lineColorBrush.Dispose(); // allocate a new one m_lineColorBrush = new SolidColorBrush( renderTarget, m_lineColor ); // clean the flag m_isLineColorBrushDirty = false; } if (m_useDefaultColor || m_lineColorBrush == null) { renderTarget.DrawLine(m_pStart, m_pEnd, brush, m_lineWidth); } else { // draw renderTarget.DrawLine(m_pStart, m_pEnd, m_lineColorBrush, m_lineWidth); } }