コード例 #1
0
        public void RenderTextOffscreen(string text)
        {
            // Clear the off-screen render target.
            deviceResources.D3DDeviceContext.ClearRenderTargetView(renderTargetView, new RawColor4(0f, 0f, 0f, 0f));

            // Begin drawing with D2D.
            d2dRenderTarget.BeginDraw();

            // Create a text layout to match the screen.
            SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(deviceResources.DWriteFactory, text, textFormat, textureWidth, textureHeight);

            // Get the text metrics from the text layout.
            SharpDX.DirectWrite.TextMetrics metrics = textLayout.Metrics;

            // In this example, we position the text in the center of the off-screen render target.
            Matrix3x2 screenTranslation = Matrix3x2.CreateTranslation(
                textureWidth * 0.5f,
                textureHeight * 0.5f + metrics.Height * 0.5f
                );

            whiteBrush.Transform = screenTranslation.ToRawMatrix3x2();

            // Render the text using DirectWrite.
            d2dRenderTarget.DrawTextLayout(new RawVector2(), textLayout, whiteBrush);

            // End drawing with D2D.
            d2dRenderTarget.EndDraw();
        }
コード例 #2
0
 /// <summary>
 ///     Determines whether the path contains the specified point.
 /// </summary>
 /// <param name="point">The point.</param>
 /// <param name="transform"></param>
 /// <returns><see langword="true" /> if the point is within this path; otherwise <see langword="false" />.</returns>
 public bool ContainsPoint(Vector2 point, Matrix3x2 transform)
 => PathGeometry.FillContainsPoint(
     point.ToRawVector2(),
     transform.ToRawMatrix3x2(),
     PathGeometry.FlatteningTolerance);
コード例 #3
0
 /// <summary>
 ///     Determines whether the path contains the specified point.
 /// </summary>
 /// <param name="point">The point.</param>
 /// <param name="transform"></param>
 /// <returns><see langword="true" /> if the point is within this path; otherwise <see langword="false" />.</returns>
 public bool ContainsPoint(Vector2 point, Matrix3x2 transform)
     => PathGeometry.FillContainsPoint(
         point.ToRawVector2(),
         transform.ToRawMatrix3x2(),
         PathGeometry.FlatteningTolerance);