/// <summary> /// Converts the <see cref="RawMatrix3x2"/> to the equivalend float array. /// </summary> /// <param name="matrix">The matrix to convert.</param> /// <returns>The converted result array.</returns> private static float[] ToArray(RawMatrix3x2 matrix) { return new[] { matrix.M11, matrix.M12, matrix.M21, matrix.M22, matrix.M31, matrix.M32, }; }
/// <summary> /// Initializes a new instance of the <see cref="LayerParameters1"/> struct. /// </summary> /// <param name="contentBounds">The content bounds.</param> /// <param name="geometryMask">The geometry mask.</param> /// <param name="maskAntialiasMode">The mask antialias mode.</param> /// <param name="maskTransform">The mask transform.</param> /// <param name="opacity">The opacity.</param> /// <param name="opacityBrush">The opacity brush.</param> /// <param name="layerOptions">The layer options.</param> public LayerParameters1(RawRectangleF contentBounds, Geometry geometryMask, AntialiasMode maskAntialiasMode, RawMatrix3x2 maskTransform, float opacity, Brush opacityBrush, LayerOptions1 layerOptions) : this() { ContentBounds = contentBounds; geometricMask_ = geometryMask.NativePointer; MaskAntialiasMode = maskAntialiasMode; MaskTransform = maskTransform; Opacity = opacity; opacityBrush_ = opacityBrush.NativePointer; LayerOptions = layerOptions; }
public TransformHelperImpl(D2D1.RenderTarget target, PxMatrix matrix, float x, float y) { _target = target; _matrix = target.Transform; var matrix2 = PxMatrix.Translate(-x, -y) * matrix * PxMatrix.Translate(x, y); target.Transform = matrix2.ToMatrix3x2() * _matrix; }
/// <summary> /// Computes the appropriate flattening tolerance to pass to APIs that take a flattening tolerance (for instance, <see cref="DeviceContext.CreateFilledGeometryRealization"/>). /// </summary> /// <param name="matrix">The matrix that will be applied subsequently to the geometry being flattened.</param> /// <param name="dpiX">The horizontal DPI of the render target that the geometry will be rendered onto (a choice of 96 implies no DPI correction).</param> /// <param name="dpiY">The vertical DPI of the render target that the geometry will be rendered onto (a choice of 96 implies no DPI correction).</param> /// <param name="maxZoomFactor">The maximum amount of additional scaling (on top of any scaling implied by the matrix or the DPI) that will be applied to the geometry.</param> /// <returns>The flattening tolerance.</returns> public static float ComputeFlatteningTolerance(ref RawMatrix3x2 matrix, float dpiX = DefaultDpi, float dpiY = DefaultDpi, float maxZoomFactor = 1f) { var scaleX = dpiX / DefaultDpi; var scaleY = dpiY / DefaultDpi; var dpiDependentTransform = new RawMatrix3x2 { M11 = matrix.M11 * scaleX, M12 = matrix.M12 * scaleY, M21 = matrix.M21 * scaleX, M22 = matrix.M22 * scaleY, M31 = matrix.M31 * scaleX, M32 = matrix.M32 * scaleY }; var absMaxZoomFactor = maxZoomFactor > 0f ? maxZoomFactor : -maxZoomFactor; return DefaultFlatteningTolerance / (absMaxZoomFactor * ComputeMaximumScaleFactor(ref dpiDependentTransform)); }
/// <summary> /// Determines whether the geometry's stroke contains the specified point given the specified stroke thickness, style, and transform. /// </summary> /// <param name="point">The point to test for containment. </param> /// <param name="strokeWidth">The thickness of the stroke to apply. </param> /// <param name="strokeStyle">The style of stroke to apply. </param> /// <param name="transform">The transform to apply to the stroked geometry. </param> /// <returns>When this method returns, contains a boolean value set to true if the geometry's stroke contains the specified point; otherwise, false. You must allocate storage for this parameter. </returns> /// <unmanaged>HRESULT ID2D1Geometry::StrokeContainsPoint([None] D2D1_POINT_2F point,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out] BOOL* contains)</unmanaged> public bool StrokeContainsPoint(RawVector2 point, float strokeWidth, StrokeStyle strokeStyle, RawMatrix3x2 transform) { return StrokeContainsPoint(point, strokeWidth, strokeStyle, transform, FlatteningTolerance); }
/// <summary> /// Creates a simplified version of the geometry that contains only lines and (optionally) cubic Bezier curves and writes the result to an <see cref="SharpDX.Direct2D1.SimplifiedGeometrySink"/>. /// </summary> /// <param name="simplificationOption">A value that specifies whether the simplified geometry should contain curves.</param> /// <param name="worldTransform">The transform to apply to the simplified geometry, or NULL.</param> /// <param name="flatteningTolerance">The maximum bounds on the distance between points in the polygonal approximation of the geometry. Smaller values produce more accurate results but cause slower execution. </param> /// <param name="geometrySink"> The <see cref="SharpDX.Direct2D1.SimplifiedGeometrySink"/> to which the simplified geometry is appended. </param> /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns> /// <unmanaged>HRESULT Simplify([None] D2D1_GEOMETRY_SIMPLIFICATION_OPTION simplificationOption,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] FLOAT flatteningTolerance,[In] ID2D1SimplifiedGeometrySink* geometrySink)</unmanaged> public void Simplify(SharpDX.Direct2D1.GeometrySimplificationOption simplificationOption, RawMatrix3x2? worldTransform, float flatteningTolerance, SimplifiedGeometrySink geometrySink) { this.Simplify_(simplificationOption, worldTransform, flatteningTolerance, GeometrySinkShadow.ToIntPtr(geometrySink)); }
/// <summary> /// Computes the outline of the geometry and writes the result to an <see cref="SharpDX.Direct2D1.SimplifiedGeometrySink"/>. /// </summary> /// <remarks> /// The {{Outline}} method allows the caller to produce a geometry with an equivalent fill to the input geometry, with the following additional properties: The output geometry contains no transverse intersections; that is, segments may touch, but they never cross.The outermost figures in the output geometry are all oriented counterclockwise. The output geometry is fill-mode invariant; that is, the fill of the geometry does not depend on the choice of the fill mode. For more information about the fill mode, see <see cref="SharpDX.Direct2D1.FillMode"/>.Additionally, the {{Outline}} method can be useful in removing redundant portions of said geometries to simplify complex geometries. It can also be useful in combination with <see cref="SharpDX.Direct2D1.GeometryGroup"/> to create unions among several geometries simultaneously. /// </remarks> /// <param name="worldTransform">The transform to apply to the geometry outline, or NULL.</param> /// <param name="flatteningTolerance">The maximum bounds on the distance between points in the polygonal approximation of the geometry. Smaller values produce more accurate results but cause slower execution. </param> /// <param name="geometrySink">The <see cref="SharpDX.Direct2D1.SimplifiedGeometrySink"/> to which the geometry's transformed outline is appended. </param> /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns> /// <unmanaged>HRESULT Outline([In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] FLOAT flatteningTolerance,[In] ID2D1SimplifiedGeometrySink* geometrySink)</unmanaged> public void Outline(RawMatrix3x2? worldTransform, float flatteningTolerance, GeometrySink geometrySink) { this.Outline_(worldTransform, flatteningTolerance, GeometrySinkShadow.ToIntPtr(geometrySink)); }
/// <summary> /// Indicates whether the area filled by the geometry would contain the specified point given the specified flattening tolerance. /// </summary> /// <param name="point">The point to test. </param> /// <param name="worldTransform">The transform to apply to the geometry prior to testing for containment, or NULL. </param> /// <param name="flatteningTolerance">The numeric accuracy with which the precise geometric path and path intersection is calculated. Points missing the fill by less than the tolerance are still considered inside. Smaller values produce more accurate results but cause slower execution. </param> /// <returns>When this method returns, contains a bool value that is true if the area filled by the geometry contains point; otherwise, false.You must allocate storage for this parameter. </returns> /// <unmanaged>HRESULT ID2D1Geometry::FillContainsPoint([None] D2D1_POINT_2F point,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out] BOOL* contains)</unmanaged> public bool FillContainsPoint(RawPoint point, RawMatrix3x2 worldTransform, float flatteningTolerance) { return FillContainsPoint(new RawVector2 {X = point.X, Y = point.Y}, worldTransform, flatteningTolerance); }
/// <summary> /// Create a GDI Compatible TextLayout. Takes a string, format, and associated constraints, and produces an object representing the result, formatted for a particular display resolution and measuring mode. /// </summary> /// <remarks> /// The resulting text layout should only be used for the intended resolution, and for cases where text scalability is desired {{CreateTextLayout}} should be used instead. /// </remarks> /// <param name="factory">an instance of <see cref = "SharpDX.DirectWrite.Factory" /></param> /// <param name="text">An array of characters that contains the string to create a new <see cref="T:SharpDX.DirectWrite.TextLayout" /> object from. This array must be of length stringLength and can contain embedded NULL characters. </param> /// <param name="textFormat">The text formatting object to apply to the string. </param> /// <param name="layoutWidth">The width of the layout box. </param> /// <param name="layoutHeight">The height of the layout box. </param> /// <param name="pixelsPerDip">The number of physical pixels per DIP (device independent pixel). For example, if rendering onto a 96 DPI device pixelsPerDip is 1. If rendering onto a 120 DPI device pixelsPerDip is 1.25 (120/96). </param> /// <param name="transform">An optional transform applied to the glyphs and their positions. This transform is applied after the scaling specifies the font size and pixels per DIP. </param> /// <param name="useGdiNatural">Instructs the text layout to use the same metrics as GDI bi-level text when set to FALSE. When set to TRUE, instructs the text layout to use the same metrics as text measured by GDI using a font created with CLEARTYPE_NATURAL_QUALITY. </param> /// <unmanaged>HRESULT IDWriteFactory::CreateGdiCompatibleTextLayout([In, Buffer] const wchar_t* string,[None] int stringLength,[None] IDWriteTextFormat* textFormat,[None] float layoutWidth,[None] float layoutHeight,[None] float pixelsPerDip,[In, Optional] const DWRITE_MATRIX* transform,[None] BOOL useGdiNatural,[Out] IDWriteTextLayout** textLayout)</unmanaged> public TextLayout(Factory factory, string text, TextFormat textFormat, float layoutWidth, float layoutHeight, float pixelsPerDip, RawMatrix3x2? transform, bool useGdiNatural) : base(IntPtr.Zero) { factory.CreateGdiCompatibleTextLayout(text, text.Length, textFormat, layoutWidth, layoutHeight, pixelsPerDip, transform, useGdiNatural, this); }
/// <summary> /// Widens the geometry by the specified stroke and writes the result to an <see cref="SharpDX.Direct2D1.SimplifiedGeometrySink"/> after it has been transformed by the specified matrix and flattened using the specified tolerance. /// </summary> /// <param name="strokeWidth">The amount by which to widen the geometry.</param> /// <param name="strokeStyle">The style of stroke to apply to the geometry, or NULL.</param> /// <param name="worldTransform">The transform to apply to the geometry after widening it, or NULL.</param> /// <param name="flatteningTolerance">The maximum bounds on the distance between points in the polygonal approximation of the geometry. Smaller values produce more accurate results but cause slower execution.</param> /// <param name="geometrySink">The <see cref="SharpDX.Direct2D1.SimplifiedGeometrySink"/> to which the widened geometry is appended.</param> /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns> /// <unmanaged>HRESULT Widen([None] FLOAT strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] FLOAT flatteningTolerance,[In] ID2D1SimplifiedGeometrySink* geometrySink)</unmanaged> public void Widen(float strokeWidth, SharpDX.Direct2D1.StrokeStyle strokeStyle, RawMatrix3x2? worldTransform, float flatteningTolerance, GeometrySink geometrySink) { this.Widen_(strokeWidth, strokeStyle, worldTransform, flatteningTolerance, GeometrySinkShadow.ToIntPtr(geometrySink)); }
private Glyph ImportGlyph(Factory factory, FontFace fontFace, char character, FontMetrics fontMetrics, float fontSize, FontAntiAliasMode antiAliasMode) { var indices = fontFace.GetGlyphIndices(new int[] { character }); var metrics = fontFace.GetDesignGlyphMetrics(indices, false); var metric = metrics[0]; var width = (float)(metric.AdvanceWidth - metric.LeftSideBearing - metric.RightSideBearing) / fontMetrics.DesignUnitsPerEm * fontSize; var height = (float)(metric.AdvanceHeight - metric.TopSideBearing - metric.BottomSideBearing) / fontMetrics.DesignUnitsPerEm * fontSize; var xOffset = (float)metric.LeftSideBearing / fontMetrics.DesignUnitsPerEm * fontSize; var yOffset = (float)(metric.TopSideBearing - metric.VerticalOriginY) / fontMetrics.DesignUnitsPerEm * fontSize; var advanceWidth = (float)metric.AdvanceWidth / fontMetrics.DesignUnitsPerEm * fontSize; //var advanceHeight = (float)metric.AdvanceHeight / fontMetrics.DesignUnitsPerEm * fontSize; var pixelWidth = (int)Math.Ceiling(width + 4); var pixelHeight = (int)Math.Ceiling(height + 4); var matrix = new RawMatrix3x2 { M11 = 1, M22 = 1, M31 = -(float)Math.Floor(xOffset) + 1, M32 = -(float)Math.Floor(yOffset) + 1 }; Bitmap bitmap; if (char.IsWhiteSpace(character)) { bitmap = new Bitmap(1, 1, PixelFormat.Format32bppArgb); } else { var glyphRun = new GlyphRun { FontFace = fontFace, Advances = new[] { (float)Math.Ceiling(advanceWidth) }, FontSize = fontSize, BidiLevel = 0, Indices = indices, IsSideways = false, Offsets = new[] { new GlyphOffset() } }; RenderingMode renderingMode; if (antiAliasMode != FontAntiAliasMode.Aliased) { var rtParams = new RenderingParams(factory); renderingMode = fontFace.GetRecommendedRenderingMode(fontSize, 1.0f, MeasuringMode.Natural, rtParams); rtParams.Dispose(); } else { renderingMode = RenderingMode.Aliased; } using (var runAnalysis = new GlyphRunAnalysis(factory, glyphRun, 1.0f, matrix, renderingMode, MeasuringMode.Natural, 0.0f, 0.0f)) { var bounds = new RawRectangle(0, 0, pixelWidth, pixelHeight); bitmap = new Bitmap(pixelWidth, pixelHeight, PixelFormat.Format32bppArgb); if (renderingMode == RenderingMode.Aliased) { var texture = new byte[pixelWidth * pixelHeight]; runAnalysis.CreateAlphaTexture(TextureType.Aliased1x1, bounds, texture, texture.Length); for (int y = 0; y < pixelHeight; y++) { for (int x = 0; x < pixelWidth; x++) { int pixelX = y * pixelWidth + x; var grey = texture[pixelX]; var color = Color.FromArgb(grey, grey, grey); bitmap.SetPixel(x, y, color); } } } else { var texture = new byte[pixelWidth * pixelHeight * 3]; runAnalysis.CreateAlphaTexture(TextureType.Cleartype3x1, bounds, texture, texture.Length); for (int y = 0; y < pixelHeight; y++) { for (int x = 0; x < pixelWidth; x++) { int pixelX = (y * pixelWidth + x) * 3; var red = LinearToGamma(texture[pixelX]); var green = LinearToGamma(texture[pixelX + 1]); var blue = LinearToGamma(texture[pixelX + 2]); var color = Color.FromArgb(red, green, blue); bitmap.SetPixel(x, y, color); } } } } } var glyph = new Glyph(character, bitmap) { XOffset = -matrix.M31, XAdvance = advanceWidth, YOffset = -matrix.M32, }; return glyph; }
/// <summary> /// Obtains glyph metrics in font design units with the return values compatible with what GDI would produce. /// </summary> /// <param name="fontSize">The logical size of the font in DIP units. </param> /// <param name="pixelsPerDip">The number of physical pixels per DIP. </param> /// <param name="transform">An optional transform applied to the glyphs and their positions. This transform is applied after the scaling specified by the font size and pixelsPerDip. </param> /// <param name="useGdiNatural">When set to FALSE, the metrics are the same as the metrics of GDI aliased text. When set to TRUE, the metrics are the same as the metrics of text measured by GDI using a font created with CLEARTYPE_NATURAL_QUALITY. </param> /// <param name="glyphIndices">An array of glyph indices for which to compute the metrics. </param> /// <param name="isSideways">A BOOL value that indicates whether the font is being used in a sideways run. This can affect the glyph metrics if the font has oblique simulation because sideways oblique simulation differs from non-sideways oblique simulation. </param> /// <returns>An array of <see cref="T:SharpDX.DirectWrite.GlyphMetrics" /> structures filled by this function. The metrics are in font design units. </returns> /// <unmanaged>HRESULT IDWriteFontFace::GetGdiCompatibleGlyphMetrics([None] float emSize,[None] float pixelsPerDip,[In, Optional] const DWRITE_MATRIX* transform,[None] BOOL useGdiNatural,[In, Buffer] const short* glyphIndices,[None] int glyphCount,[Out, Buffer] DWRITE_GLYPH_METRICS* glyphMetrics,[None] BOOL isSideways)</unmanaged> public GlyphMetrics[] GetGdiCompatibleGlyphMetrics(float fontSize, float pixelsPerDip, RawMatrix3x2? transform, bool useGdiNatural, short[] glyphIndices, bool isSideways) { var glyphMetrics = new GlyphMetrics[glyphIndices.Length]; GetGdiCompatibleGlyphMetrics(fontSize, pixelsPerDip, transform, useGdiNatural, glyphIndices, glyphIndices.Length, glyphMetrics, isSideways); return glyphMetrics; }
/// <summary> /// Modifies the content transform while maintaining the output transform. /// </summary> /// <param name="transform"></param> public void SyncContentTransform(RawMatrix3x2 transform) { var values = ToArray(transform); SyncContentTransform(values, 6); }
/// <summary> /// Creates a glyph run analysis object, which encapsulates information used to render a glyph run. /// </summary> /// <param name="factory">The factory.</param> /// <param name="glyphRun">A structure that contains the properties of the glyph run (font face, advances, and so on).</param> /// <param name="pixelsPerDip">Number of physical pixels per DIP (device independent pixel). For example, if rendering onto a 96 DPI bitmap then pixelsPerDip is 1. If rendering onto a 120 DPI bitmap then pixelsPerDip is 1.25.</param> /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the scaling specified the emSize and pixelsPerDip.</param> /// <param name="renderingMode">A value that specifies the rendering mode, which must be one of the raster rendering modes (that is, not default and not outline).</param> /// <param name="measuringMode">Specifies the measuring mode to use with glyphs.</param> /// <param name="baselineOriginX">The horizontal position (X-coordinate) of the baseline origin, in DIPs.</param> /// <param name="baselineOriginY">Vertical position (Y-coordinate) of the baseline origin, in DIPs.</param> /// <remarks> /// The glyph run analysis object contains the results of analyzing the glyph run, including the positions of all the glyphs and references to all of the rasterized glyphs in the font cache. /// </remarks> /// <unmanaged>HRESULT IDWriteFactory::CreateGlyphRunAnalysis([In] const DWRITE_GLYPH_RUN* glyphRun,[None] float pixelsPerDip,[In, Optional] const DWRITE_MATRIX* transform,[None] DWRITE_RENDERING_MODE renderingMode,[None] DWRITE_MEASURING_MODE measuringMode,[None] float baselineOriginX,[None] float baselineOriginY,[Out] IDWriteGlyphRunAnalysis** glyphRunAnalysis)</unmanaged> public GlyphRunAnalysis(Factory factory, GlyphRun glyphRun, float pixelsPerDip, RawMatrix3x2? transform, RenderingMode renderingMode, MeasuringMode measuringMode, float baselineOriginX, float baselineOriginY) { factory.CreateGlyphRunAnalysis(glyphRun, pixelsPerDip, transform, renderingMode, measuringMode, baselineOriginX, baselineOriginY, this); }
/// <summary> /// Gets the GDI compatible glyph placements. /// </summary> /// <param name="textString">The text string.</param> /// <param name="clusterMap">The cluster map.</param> /// <param name="textProps">The text props.</param> /// <param name="textLength">Length of the text.</param> /// <param name="glyphIndices">The glyph indices.</param> /// <param name="glyphProps">The glyph props.</param> /// <param name="glyphCount">The glyph count.</param> /// <param name="fontFace">The font face.</param> /// <param name="fontEmSize">Size of the font em.</param> /// <param name="pixelsPerDip">The pixels per dip.</param> /// <param name="transform">The transform.</param> /// <param name="useGdiNatural">if set to <c>true</c> [use GDI natural].</param> /// <param name="isSideways">if set to <c>true</c> [is sideways].</param> /// <param name="isRightToLeft">if set to <c>true</c> [is right to left].</param> /// <param name="scriptAnalysis">The script analysis.</param> /// <param name="localeName">Name of the locale.</param> /// <param name="features">The features.</param> /// <param name="featureRangeLengths">The feature range lengths.</param> /// <param name="glyphAdvances">The glyph advances.</param> /// <param name="glyphOffsets">The glyph offsets.</param> /// <returns> /// If the method succeeds, it returns <see cref="Result.Ok"/>. /// </returns> /// <unmanaged>HRESULT IDWriteTextAnalyzer::GetGdiCompatibleGlyphPlacements([In, Buffer] const wchar_t* textString,[In, Buffer] const unsigned short* clusterMap,[In, Buffer] DWRITE_SHAPING_TEXT_PROPERTIES* textProps,[In] unsigned int textLength,[In, Buffer] const unsigned short* glyphIndices,[In, Buffer] const DWRITE_SHAPING_GLYPH_PROPERTIES* glyphProps,[In] unsigned int glyphCount,[In] IDWriteFontFace* fontFace,[In] float fontEmSize,[In] float pixelsPerDip,[In, Optional] const DWRITE_MATRIX* transform,[In] BOOL useGdiNatural,[In] BOOL isSideways,[In] BOOL isRightToLeft,[In] const DWRITE_SCRIPT_ANALYSIS* scriptAnalysis,[In, Buffer, Optional] const wchar_t* localeName,[In, Optional] const void** features,[In, Buffer, Optional] const unsigned int* featureRangeLengths,[In] unsigned int featureRanges,[Out, Buffer] float* glyphAdvances,[Out, Buffer] DWRITE_GLYPH_OFFSET* glyphOffsets)</unmanaged> public void GetGdiCompatibleGlyphPlacements(string textString, short[] clusterMap, SharpDX.DirectWrite.ShapingTextProperties[] textProps, int textLength, short[] glyphIndices, SharpDX.DirectWrite.ShapingGlyphProperties[] glyphProps, int glyphCount, SharpDX.DirectWrite.FontFace fontFace, float fontEmSize, float pixelsPerDip, RawMatrix3x2? transform, bool useGdiNatural, bool isSideways, bool isRightToLeft, SharpDX.DirectWrite.ScriptAnalysis scriptAnalysis, string localeName, FontFeature[][] features, int[] featureRangeLengths, float[] glyphAdvances, SharpDX.DirectWrite.GlyphOffset[] glyphOffsets) { var pFeatures = AllocateFeatures(features); try { GetGdiCompatibleGlyphPlacements( textString, clusterMap, textProps, textLength, glyphIndices, glyphProps, glyphCount, fontFace, fontEmSize, pixelsPerDip, transform, useGdiNatural, isSideways, isRightToLeft, scriptAnalysis, localeName, pFeatures, featureRangeLengths, featureRangeLengths == null ? 0 : featureRangeLengths.Length, glyphAdvances, glyphOffsets ); } finally { if (pFeatures != IntPtr.Zero) Marshal.FreeHGlobal(pFeatures); } }
/// <summary> /// Determines whether the geometry's stroke contains the specified point given the specified stroke thickness, style, and transform. /// </summary> /// <param name="point">The point to test for containment. </param> /// <param name="strokeWidth">The thickness of the stroke to apply. </param> /// <param name="strokeStyle">The style of stroke to apply. </param> /// <param name="transform">The transform to apply to the stroked geometry. </param> /// <param name="flatteningTolerance">The numeric accuracy with which the precise geometric path and path intersection is calculated. Points missing the stroke by less than the tolerance are still considered inside. Smaller values produce more accurate results but cause slower execution. </param> /// <returns>When this method returns, contains a boolean value set to true if the geometry's stroke contains the specified point; otherwise, false. You must allocate storage for this parameter. </returns> /// <unmanaged>HRESULT ID2D1Geometry::StrokeContainsPoint([None] D2D1_POINT_2F point,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out] BOOL* contains)</unmanaged> public bool StrokeContainsPoint(RawPoint point, float strokeWidth, StrokeStyle strokeStyle, RawMatrix3x2 transform, float flatteningTolerance) { return StrokeContainsPoint(new RawVector2 { X = point.X, Y = point.Y}, strokeWidth, strokeStyle, transform, flatteningTolerance); }
/// <summary> /// Creates a set of clockwise-wound triangles that cover the geometry after it has been transformed using the specified matrix and flattened using the specified tolerance /// </summary> /// <param name="worldTransform">The transform to apply to this geometry, or NULL.</param> /// <param name="flatteningTolerance">The maximum bounds on the distance between points in the polygonal approximation of the geometry. Smaller values produce more accurate results but cause slower execution. </param> /// <param name="tessellationSink">The <see cref="SharpDX.Direct2D1.TessellationSink"/> to which the tessellated is appended.</param> /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns> /// <unmanaged>HRESULT Tessellate([In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] FLOAT flatteningTolerance,[In] ID2D1TessellationSink* tessellationSink)</unmanaged> public void Tessellate(RawMatrix3x2? worldTransform, float flatteningTolerance, TessellationSink tessellationSink) { this.Tessellate_(worldTransform, flatteningTolerance, TessellationSinkShadow.ToIntPtr(tessellationSink)); }
/// <summary> /// Default Constructor for a <see cref = "SharpDX.Direct2D1.TransformedGeometry" />. /// </summary> /// <param name="factory">an instance of <see cref = "SharpDX.Direct2D1.Factory" /></param> /// <param name="geometrySource"></param> /// <param name="matrix3X2"></param> public TransformedGeometry(Factory factory, Geometry geometrySource, RawMatrix3x2 matrix3X2) : base(IntPtr.Zero) { factory.CreateTransformedGeometry(geometrySource, ref matrix3X2, this); }
/// <summary> /// Combines this geometry with the specified geometry and stores the result in an <see cref="SharpDX.Direct2D1.SimplifiedGeometrySink"/>. /// </summary> /// <param name="inputGeometry">The geometry to combine with this instance.</param> /// <param name="combineMode">The type of combine operation to perform.</param> /// <param name="inputGeometryTransform">The transform to apply to inputGeometry before combining, or NULL.</param> /// <param name="flatteningTolerance">The maximum bounds on the distance between points in the polygonal approximation of the geometries. Smaller values produce more accurate results but cause slower execution. </param> /// <param name="geometrySink">The result of the combine operation.</param> /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns> /// <unmanaged>HRESULT CombineWithGeometry([In] ID2D1Geometry* inputGeometry,[None] D2D1_COMBINE_MODE combineMode,[In, Optional] const D2D1_MATRIX_3X2_F* inputGeometryTransform,[None] FLOAT flatteningTolerance,[In] ID2D1SimplifiedGeometrySink* geometrySink)</unmanaged> public void Combine(SharpDX.Direct2D1.Geometry inputGeometry, SharpDX.Direct2D1.CombineMode combineMode, RawMatrix3x2? inputGeometryTransform, float flatteningTolerance, GeometrySink geometrySink) { this.Combine_(inputGeometry, combineMode, inputGeometryTransform, flatteningTolerance, GeometrySinkShadow.ToIntPtr(geometrySink)); }
public TransformHelperImpl(D2D1.RenderTarget target, PxMatrix matrix) { _target = target; _matrix = target.Transform; target.Transform = matrix.ToMatrix3x2() * _matrix; }