Beispiel #1
0
        private void DrawPlayerCrosshair(float yOffset, float xOffset)
        {
            float x  = 1280 / 2;
            float y  = 1024 / 2;
            float dy = 1024 / 90;
            float dx = 1280 / 90;

            x -= (dx * (xOffset));
            y += (dy * (yOffset));

            DrawTypes.RawVector2 CrosshairHStart = new DrawTypes.RawVector2(x - 11, y);
            DrawTypes.RawVector2 CrosshairHEnd   = new DrawTypes.RawVector2(x - 3, y);
            device.DrawLine(CrosshairHStart, CrosshairHEnd, brushSolidYellow, 2);

            DrawTypes.RawVector2 CrosshairVStart = new DrawTypes.RawVector2(x, y - 11);
            DrawTypes.RawVector2 CrosshairVEnd   = new DrawTypes.RawVector2(x, y - 3);
            device.DrawLine(CrosshairVStart, CrosshairVEnd, brushSolidYellow, 2);

            DrawTypes.RawVector2 CrosshairH1Start = new DrawTypes.RawVector2(x + 11, y);
            DrawTypes.RawVector2 CrosshairH1End   = new DrawTypes.RawVector2(x + 3, y);
            device.DrawLine(CrosshairH1Start, CrosshairH1End, brushSolidYellow, 2);

            DrawTypes.RawVector2 CrosshairV1Start = new DrawTypes.RawVector2(x, y + 11);
            DrawTypes.RawVector2 CrosshairV1End   = new DrawTypes.RawVector2(x, y + 3);
            device.DrawLine(CrosshairV1Start, CrosshairV1End, brushSolidYellow, 2);
        }
Beispiel #2
0
        /// <summary>
        /// Starts a new figure at the specified point.
        /// </summary>
        /// <param name="startPoint">The point at which to begin the new figure.</param>
        /// <param name="figureBegin">Whether the new figure should be hollow or filled.</param>
        /// <unmanaged>void BeginFigure([None] D2D1_POINT_2F startPoint,[None] D2D1_FIGURE_BEGIN figureBegin)</unmanaged>
        /// <remarks>
        /// If this method is called while a figure is currently in progress, the interface is invalidated and all future methods will fail.
        /// </remarks>
        public void BeginFigure(SharpDX.Mathematics.Interop.RawVector2 startPoint, FigureBegin figureBegin)
        {
            m_currentPolygonBuilder.Clear();
            m_currentPolygonBuilder.Add(new Vector2(startPoint.X, startPoint.Y) - m_origin);

            m_currentFigureBegin = figureBegin;
        }
Beispiel #3
0
        private void DrawPlayerHead(float x, float y, float distance)
        {
            float radius = 4000 / distance;

            DrawTypes.RawVector2 HeadPos = new DrawTypes.RawVector2(x, y);

            Ellipse HeadCricle = new Ellipse(HeadPos, radius, radius);

            device.DrawEllipse(HeadCricle, brushSolidGreenYellow);
        }
Beispiel #4
0
        public void Measure()
        {
            for (int i = 0; i < particleCount; i++)
            {
                float ratio = (sw.ElapsedMilliseconds % timings[i]) / timings[i];

                float ratio2 = ((sw.ElapsedMilliseconds + shakeOffset[i]) % shakeCycle[i]) / shakeCycle[i];
                f[i]      = startF[i] - ratio * startF[i];
                nowPos[i] = new Mathe.RawVector2(startPos[i].X + (float)Math.Sin(ratio2 * 2 * Math.PI) * 10, startPos[i].Y - sw.ElapsedMilliseconds % timings[i] * speeds[i]);
            }
        }
Beispiel #5
0
 private void DrawPlayerBones(float[] bones)
 {
     for (int i = 0; i < bones.Length; i++)
     {
         if (i % 4 == 0)
         {
             DrawTypes.RawVector2 BoneStart = new DrawTypes.RawVector2(bones[i], bones[i + 1]);
             DrawTypes.RawVector2 BoneEnd   = new DrawTypes.RawVector2(bones[i + 2], bones[i + 3]);
             device.DrawLine(BoneStart, BoneEnd, brushTransparentRed);
         }
     }
 }
Beispiel #6
0
        public void Measure()
        {
            for (int i = 0; i < _particleCount; i++)
            {
                float ratio = (_sw.ElapsedMilliseconds % _timings[i]) / _timings[i];

                float ratio2 = ((_sw.ElapsedMilliseconds + _shakeOffset[i]) % _shakeCycle[i]) / _shakeCycle[i];
                _f[i]      = _startF[i] - ratio * _startF[i];
                _nowPos[i] = new Mathe.RawVector2(_startPos[i].X + (float)Math.Sin(ratio2 * 2 * Math.PI) * 10,
                                                  _startPos[i].Y - _sw.ElapsedMilliseconds % _timings[i] * _speeds[i]);
            }
        }
Beispiel #7
0
        public Particle(int count)
        {
            _particleCount = count;

            // Load bitmap
            FileInfo[] fis = new DirectoryInfo("element").GetFiles("*.png", SearchOption.TopDirectoryOnly);
            _oriBitmaps = new D2D.Bitmap[fis.Length];
            for (int i = 0; i < _oriBitmaps.Length; i++)
            {
                _oriBitmaps[i] = DxHelper.LoadFromFile(fis[i].FullName);
            }

            _startPos = new Mathe.RawVector2[count];
            _nowPos   = new Mathe.RawVector2[count];
            _speeds   = new float[count];
            _timings  = new float[count];
            _bitmaps  = new D2D.Bitmap[count];

            _r           = new float[count];
            _startF      = new float[count];
            _f           = new float[count];
            _shakeOffset = new float[count];
            _shakeCycle  = new float[count];

            for (int i = 0; i < count; i++)
            {
                _bitmaps[i]  = _oriBitmaps[_rnd.Next(0, _oriBitmaps.Length)];
                _r[i]        = (float)(_rnd.NextDouble() * 20);
                _startF[i]   = (float)_rnd.NextDouble();
                _speeds[i]   = _r[i] * _r[i] * 0.0005f;
                _timings[i]  = 1 / _speeds[i] * 1000;
                _startPos[i] =
                    new Mathe.RawVector2(_rnd.Next(0, RenderForm.Width), RenderForm.Height + _rnd.Next(40, 50));
                _shakeCycle[i]  = 1 / _speeds[i] * 500;
                _shakeOffset[i] = (float)_rnd.NextDouble() * _shakeCycle[i];
            }

            _sw = new Stopwatch();
            _sw.Restart();
        }
Beispiel #8
0
 /// <summary>
 /// Creates a line segment between the current point and the specified end point and adds it to the geometry sink.
 /// </summary>
 /// <param name="point">The end point of the line to draw.</param>
 /// <unmanaged>void AddLine([None] D2D1_POINT_2F point)</unmanaged>
 public void AddLine(SharpDX.Mathematics.Interop.RawVector2 point)
 {
     m_currentPolygonBuilder.Add(new Vector2(point.X, point.Y) - m_origin);
 }
        public void RotateHakenkreuz(int x, int y, int size, float stroke, float rotation, int brush)
        {
            //left to right
            var first = new RawVector2(x - size, y - rotation);
            var second = new RawVector2(x + size, y + rotation);

            //top down
            var third = new RawVector2(x + rotation, y - size);
            var fourth = new RawVector2(x - rotation, y + size);

            //haken
            var haken1 = new RawVector2(third.X + size, third.Y + rotation);
            var haken2 = new RawVector2(second.X - rotation, second.Y + size);
            var haken3 = new RawVector2(fourth.X - size, fourth.Y - rotation);
            var haken4 = new RawVector2(first.X + rotation, first.Y - size);

            //das +
            _device.DrawLine(first, second, _brushContainer[brush], stroke);
            _device.DrawLine(third, fourth, _brushContainer[brush], stroke);

            //die haken
            _device.DrawLine(third, haken1, _brushContainer[brush], stroke);
            _device.DrawLine(second, haken2, _brushContainer[brush], stroke);
            _device.DrawLine(fourth, haken3, _brushContainer[brush], stroke);
            _device.DrawLine(first, haken4, _brushContainer[brush], stroke);
        }
 private static void AddLinesImpl(IntPtr thisPtr, IntPtr points, int pointsCount)
 {
     unsafe
     {
         var shadow = ToShadow<SimplifiedGeometrySinkShadow>(thisPtr);
         var callback = (SimplifiedGeometrySink)shadow.Callback;
         var managedPoints = new RawVector2[pointsCount];
         Utilities.Read(points, managedPoints, 0, pointsCount);
         callback.AddLines(managedPoints);
     }
 }
 public void AddLine(RawVector2 point)
 {
     AddLine_(point);
 }
Beispiel #12
0
 /// <summary>	
 /// Draws a line between the specified points. 	
 /// </summary>	
 /// <remarks>	
 /// This method doesn't return an error code if it fails. To determine whether a drawing operation (such as DrawLine) failed, check the result returned by the <see cref="M:SharpDX.Direct2D1.RenderTarget.EndDraw(System.Int64@,System.Int64@)" /> or <see cref="M:SharpDX.Direct2D1.RenderTarget.Flush(System.Int64@,System.Int64@)" /> methods.  	
 /// </remarks>	
 /// <param name="point0">The start point of the line, in device-independent pixels. </param>
 /// <param name="point1">The end point of the line, in device-independent pixels. </param>
 /// <param name="brush">The brush used to paint the line's stroke. </param>
 /// <param name="strokeWidth">A value greater than or equal to 0.0f that specifies the width of the stroke. If this parameter isn't specified, it defaults to 1.0f.  The stroke is centered on the line. </param>
 /// <unmanaged>void ID2D1RenderTarget::DrawLine([None] D2D1_POINT_2F point0,[None] D2D1_POINT_2F point1,[In] ID2D1Brush* brush,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle)</unmanaged>
 public void DrawLine(RawVector2 point0, RawVector2 point1, Brush brush, float strokeWidth)
 {
     DrawLine(point0, point1, brush, strokeWidth, null);
 }
Beispiel #13
0
 /// <summary>	
 /// No documentation.	
 /// </summary>	
 /// <param name="image">No documentation.</param>	
 /// <param name="targetOffset">No documentation.</param>	
 /// <param name="interpolationMode">No documentation.</param>	
 /// <param name="compositeMode">No documentation.</param>	
 /// <unmanaged>void ID2D1DeviceContext::DrawImage([In] ID2D1Image* image,[In, Optional] const D2D_POINT_2F* targetOffset,[In, Optional] const D2D_RECT_F* imageRectangle,[In] D2D1_INTERPOLATION_MODE interpolationMode,[In] D2D1_COMPOSITE_MODE compositeMode)</unmanaged>	
 public void DrawImage(SharpDX.Direct2D1.Image image, RawVector2 targetOffset, SharpDX.Direct2D1.InterpolationMode interpolationMode = InterpolationMode.Linear, SharpDX.Direct2D1.CompositeMode compositeMode = CompositeMode.SourceOver)
 {
     DrawImage(image, targetOffset, null, interpolationMode, compositeMode);
 }
Beispiel #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Ellipse"/> struct.
 /// </summary>
 /// <param name="center">The center.</param>
 /// <param name="radiusX">The radius X.</param>
 /// <param name="radiusY">The radius Y.</param>
 public Ellipse(RawVector2 center, float radiusX, float radiusY)
 {
     Point = center;
     RadiusX = radiusX;
     RadiusY = radiusY;
 }
Beispiel #15
0
 private unsafe static int DrawLineImpl(IntPtr thisPtr, RawVector2 point0, RawVector2 point1, IntPtr brush, float strokeWidth, IntPtr strokeStyle)
 {
     try
     {
         var shadow = ToShadow<CommandSinkShadow>(thisPtr);
         var callback = (CommandSink)shadow.Callback;
         callback.DrawLine(point0, point1, new Brush(brush), strokeWidth, new StrokeStyle(strokeStyle));
     }
     catch (Exception exception)
     {
         return (int)SharpDX.Result.GetResultFromException(exception);
     }
     return Result.Ok.Code;
 }
Beispiel #16
0
            private unsafe static int DrawGlyphRunImpl(IntPtr thisPtr, RawVector2 baselineOrigin, IntPtr glyphRunNative, IntPtr glyphRunDescriptionPtr, IntPtr foregroundBrush, SharpDX.Direct2D1.MeasuringMode measuringMode)
            {
                var glyphRun = new DirectWrite.GlyphRun();
                try
                {
                    var glyphRunDescription = new SharpDX.DirectWrite.GlyphRunDescription();
                    glyphRunDescription.__MarshalFrom(ref *(SharpDX.DirectWrite.GlyphRunDescription.__Native*)glyphRunDescriptionPtr);

                    glyphRun.__MarshalFrom(ref *(DirectWrite.GlyphRun.__Native*)glyphRunNative);

                    var shadow = ToShadow<CommandSinkShadow>(thisPtr);
                    var callback = (CommandSink)shadow.Callback;
                    callback.DrawGlyphRun(baselineOrigin, glyphRun, glyphRunDescription, new Brush(foregroundBrush), measuringMode);

                }
                catch (Exception exception)
                {
                    return (int)SharpDX.Result.GetResultFromException(exception);
                }
                finally
                {
                    glyphRun.__MarshalFree(ref *(DirectWrite.GlyphRun.__Native*)glyphRunNative);
                }
                return Result.Ok.Code;
            }
Beispiel #17
0
 /// <summary>	
 /// No documentation.	
 /// </summary>	
 /// <param name="effect">No documentation.</param>	
 /// <param name="targetOffset">No documentation.</param>	
 /// <param name="interpolationMode">No documentation.</param>	
 /// <param name="compositeMode">No documentation.</param>	
 /// <unmanaged>void ID2D1DeviceContext::DrawImage([In] ID2D1Image* image,[In, Optional] const D2D_POINT_2F* targetOffset,[In, Optional] const D2D_RECT_F* imageRectangle,[In] D2D1_INTERPOLATION_MODE interpolationMode,[In] D2D1_COMPOSITE_MODE compositeMode)</unmanaged>	
 public void DrawImage(SharpDX.Direct2D1.Effect effect, RawVector2 targetOffset, SharpDX.Direct2D1.InterpolationMode interpolationMode = InterpolationMode.Linear, SharpDX.Direct2D1.CompositeMode compositeMode = CompositeMode.SourceOver)
 {
     using (var output = effect.Output)
         DrawImage(output, targetOffset, null, interpolationMode, compositeMode);
 }
        //geht
        public void DrawEdge(float x, float y, float width, float height, int length, float stroke, int brush)
        {
            //upper left edge
            var first = new RawVector2(x, y);
            var second = new RawVector2(x, y + length);
            var third = new RawVector2(x + length, y);

            _device.DrawLine(first, second, _brushContainer[brush], stroke);
            _device.DrawLine(first, third, _brushContainer[brush], stroke);

            //down left edge
            first.Y += height;
            second.Y = first.Y - length;
            third.Y = first.Y;
            third.X = first.X + length;

            _device.DrawLine(first, second, _brushContainer[brush], stroke);
            _device.DrawLine(first, third, _brushContainer[brush], stroke);

            //up right edge
            first.X = x + width;
            first.Y = y;
            second.X = first.X - length;
            second.Y = first.Y;
            third.X = first.X;
            third.Y = first.Y + length;

            _device.DrawLine(first, second, _brushContainer[brush], stroke);
            _device.DrawLine(first, third, _brushContainer[brush], stroke);

            //down right edge
            first.Y += height;
            second.X += length;
            second.Y = first.Y - length;
            third.Y = first.Y;
            third.X = first.X - length;

            _device.DrawLine(first, second, _brushContainer[brush], stroke);
            _device.DrawLine(first, third, _brushContainer[brush], stroke);
        }
 /// <summary>
 ///     Adds a series of lines to the end of the path.
 /// </summary>
 /// <param name="points">The points of the lines to add.</param>
 /// <returns>This <see cref="IGraphicsPath" />.</returns>
 public IGraphicsPath AddLines(ArraySegment<Vector2> points)
 {
     if (points.Array == null) throw new ArgumentNullException(nameof(points));
     RawVector2[] rawVecs = new RawVector2[points.Count];
     for (int i = 0, j = points.Offset; i < points.Count; i++, j++)
         rawVecs[i] = points.Array[j].ToRawVector2();
     _sink?.AddLines(rawVecs);
     return this;
 }
        public void DrawPlus(float x, float y, int length, float stroke, int brush)
        {
            //left to right
            var first = new RawVector2(x - length, y);
            var second = new RawVector2(x + length, y);

            //top down
            var third = new RawVector2(x, y - length);
            var fourth = new RawVector2(x, y + length);

            _device.DrawLine(first, second, _brushContainer[brush], stroke);
            _device.DrawLine(third, fourth, _brushContainer[brush], stroke);
        }
Beispiel #21
0
 /// <summary>	
 /// Draws the formatted text described by the specified <see cref="T:SharpDX.DirectWrite.TextLayout" /> object.	
 /// </summary>	
 /// <remarks>	
 /// When drawing the same text repeatedly, using the DrawTextLayout method is more efficient than using the {{DrawText}} method because the text doesn't need to be formatted and the layout processed with each call. This method doesn't return an error code if it fails. To determine whether a drawing operation (such as DrawTextLayout) failed, check the result returned by the <see cref="M:SharpDX.Direct2D1.RenderTarget.EndDraw(System.Int64@,System.Int64@)" /> or <see cref="M:SharpDX.Direct2D1.RenderTarget.Flush(System.Int64@,System.Int64@)" /> methods.  	
 /// </remarks>	
 /// <param name="origin">The point, described in device-independent pixels, at which the upper-left corner of the text described by textLayout is drawn. </param>
 /// <param name="textLayout">The formatted text to draw. Any drawing effects that do not inherit from <see cref="T:SharpDX.Direct2D1.Resource" /> are ignored. If there are drawing effects that inherit from ID2D1Resource that are not brushes, this method fails and the render target is put in an error state.  </param>
 /// <param name="defaultForegroundBrush">The brush used to paint any text in textLayout that does not already have a brush associated with it as a drawing effect (specified by the <see cref="M:SharpDX.DirectWrite.TextLayout.SetDrawingEffect(SharpDX.ComObject,SharpDX.DirectWrite.TextRange)" /> method).  </param>
 /// <unmanaged>void ID2D1RenderTarget::DrawTextLayout([None] D2D1_POINT_2F origin,[In] IDWriteTextLayout* textLayout,[In] ID2D1Brush* defaultForegroundBrush,[None] D2D1_DRAW_TEXT_OPTIONS options)</unmanaged>
 public void DrawTextLayout(RawVector2 origin, TextLayout textLayout, Brush defaultForegroundBrush)
 {
     DrawTextLayout(origin, textLayout, defaultForegroundBrush, DrawTextOptions.None);
 }
        public void DrawRectangle3D(int x, int y, int width, int height, int length, float stroke, int brush)
        {
            var first = new RawRectangleF(x, y, x + width, y + height);
            var second = new RawRectangleF(x + length, y - length, first.Right + length, first.Bottom - length);

            var lineStart = new RawVector2(x, y);
            var lineEnd = new RawVector2(second.Left, second.Top);

            _device.DrawRectangle(first, _brushContainer[brush], stroke);
            _device.DrawRectangle(second, _brushContainer[brush], stroke);

            //up left line
            _device.DrawLine(lineStart, lineEnd, _brushContainer[brush], stroke);

            //up right
            lineStart.X += width;
            lineEnd.X = lineStart.X + length;

            _device.DrawLine(lineStart, lineEnd, _brushContainer[brush], stroke);

            //down rigth
            lineStart.Y += height;
            lineEnd.Y += height;

            _device.DrawLine(lineStart, lineEnd, _brushContainer[brush], stroke);

            //down left
            lineStart.X -= width;
            lineEnd.X -= width;

            _device.DrawLine(lineStart, lineEnd, _brushContainer[brush], stroke);
        }
 private static void BeginFigureImpl(IntPtr thisPtr, RawVector2 startPoint, SharpDX.Direct2D1.FigureBegin figureBegin)
 {
     var shadow = ToShadow<SimplifiedGeometrySinkShadow>(thisPtr);
     var callback = (SimplifiedGeometrySink)shadow.Callback;
     callback.BeginFigure(startPoint, figureBegin);
 }
 private static unsafe void AddLineImpl(IntPtr thisPtr, RawVector2 point)
 {
     var shadow = ToShadow<GeometrySinkShadow>(thisPtr);
     var callback = (GeometrySink)shadow.Callback; 
     callback.AddLine(point);
 }
 /// <summary>
 /// Starts a new figure at the specified point.
 /// </summary>
 /// <param name="startPoint">The point at which to begin the new figure.</param>
 /// <param name="figureBegin">Whether the new figure should be hollow or filled.</param>
 /// <remarks>
 /// If this method is called while a figure is currently in progress, the interface is invalidated and all future methods will fail.
 /// </remarks>
 public void BeginFigure(RawVector2 startPoint, FigureBegin figureBegin)
 {
     BeginFigure_(startPoint, figureBegin);
 }
 /// <summary>
 /// Creates a sequence of lines using the specified points and adds them to the geometry sink.
 /// </summary>
 /// <param name="points">An array of one or more points that describe the lines to draw. A line is drawn from the geometry sink's current point (the end point of the last segment drawn or the location specified by <strong>BeginFigure</strong>) to the first point in the array. If the array contains additional points, a line is drawn from the first point to the second point in the array, from the second point to the third point, and so on.</param>
 public void AddLines(RawVector2[] points)
 {
     AddLines_(points, points.Length);
 }
 /// <summary>
 ///     Adds a series of lines to the end of the path.
 /// </summary>
 /// <param name="points">The points of the lines to add.</param>
 /// <returns>This <see cref="IGraphicsPath" />.</returns>
 public IGraphicsPath AddLines([NotNull] params Vector2[] points)
 {
     if (points == null) throw new ArgumentNullException(nameof(points));
     RawVector2[] rawVecs = new RawVector2[points.Length];
     for (int i = 0; i < points.Length; i++)
         rawVecs[i] = points[i].ToRawVector2();
     _sink?.AddLines(rawVecs);
     return this;
 }
Beispiel #28
0
 /// <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>
 /// <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)
 {
     return StrokeContainsPoint(point, strokeWidth, strokeStyle, null, FlatteningTolerance);
 }
Beispiel #29
0
 /// <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);            
 }
Beispiel #30
0
 /// <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="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(RawVector2 point, float flatteningTolerance)
 {
     return FillContainsPoint(point, null, flatteningTolerance);
 }
Beispiel #31
0
 /// <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>
 /// <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)
 {
     return StrokeContainsPoint(point, strokeWidth, null);
 }
Beispiel #32
0
 /// <unmanaged>HRESULT ID2D1CommandSink::DrawImage([In] ID2D1Image* image,[In, Optional] const D2D_POINT_2F* targetOffset,[In, Optional] const D2D_RECT_F* imageRectangle,[In] D2D1_INTERPOLATION_MODE interpolationMode,[In] D2D1_COMPOSITE_MODE compositeMode)</unmanaged>	
 public void DrawImage(Image image, RawVector2? targetOffset, RawRectangleF? imageRectangle, InterpolationMode interpolationMode, CompositeMode compositeMode)
 {
     DrawImage_(image, targetOffset, imageRectangle, interpolationMode, compositeMode);
 }
Beispiel #33
0
 /// <summary>	
 /// Calculates the point and tangent vector at the specified distance along the geometry after it has been transformed by the specified matrix and flattened using the specified tolerance.	
 /// </summary>	
 /// <param name="length">The distance along the geometry of the point and tangent to find. If this distance is less then 0, this method calculates the first point in the geometry. If this distance is greater than the length of the geometry, this method calculates the last point in the geometry. </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="unitTangentVector">When this method returns, contains a reference to the tangent vector at the specified distance along the geometry. If the geometry is empty,  this vector contains NaN as its x and y values. You must allocate storage for this parameter. </param>
 /// <returns>The location at the specified distance along the geometry. If the geometry is empty,  this point contains NaN as its x and y values. </returns>
 /// <unmanaged>HRESULT ID2D1Geometry::ComputePointAtLength([None] float length,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out, Optional] D2D1_POINT_2F* point,[Out, Optional] D2D1_POINT_2F* unitTangentVector)</unmanaged>
 public RawVector2 ComputePointAtLength(float length, float flatteningTolerance, out RawVector2 unitTangentVector)
 {
     return ComputePointAtLength(length, null, flatteningTolerance, out unitTangentVector);
 }
Beispiel #34
0
 /// <unmanaged>HRESULT ID2D1CommandSink::DrawLine([In] D2D_POINT_2F point0,[In] D2D_POINT_2F point1,[In] ID2D1Brush* brush,[In] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle)</unmanaged>	
 public void DrawLine(RawVector2 point0, RawVector2 point1, Brush brush, float strokeWidth, StrokeStyle strokeStyle)
 {
     DrawLine_(point0, point1, brush, strokeWidth, strokeStyle);
 }
Beispiel #35
0
 /// <unmanaged>HRESULT ID2D1CommandSink::DrawGlyphRun([In] D2D_POINT_2F baselineOrigin,[In] const DWRITE_GLYPH_RUN* glyphRun,[In, Optional] const DWRITE_GLYPH_RUN_DESCRIPTION* glyphRunDescription,[In] ID2D1Brush* foregroundBrush,[In] DWRITE_MEASURING_MODE measuringMode)</unmanaged>	
 public void DrawGlyphRun(RawVector2 baselineOrigin, DirectWrite.GlyphRun glyphRun, DirectWrite.GlyphRunDescription glyphRunDescription, Brush foregroundBrush, MeasuringMode measuringMode)
 {
     DrawGlyphRun_(baselineOrigin, glyphRun, glyphRunDescription, foregroundBrush, measuringMode);
 }
Beispiel #36
0
 /// <unmanaged>HRESULT ID2D1CommandSink::DrawGdiMetafile([In] ID2D1GdiMetafile* gdiMetafile,[In, Optional] const D2D_POINT_2F* targetOffset)</unmanaged>	
 public void DrawGdiMetafile(GdiMetafile gdiMetafile, RawVector2? targetOffset)
 {
     DrawGdiMetafile_(gdiMetafile, targetOffset);
 }
Beispiel #37
0
        public Particles(int count, int panelHeight)
        {
            particleCount    = count;
            this.panelHeight = panelHeight;
            // Load bitmap
            FileInfo[] fis = new DirectoryInfo("element").GetFiles("*.png", SearchOption.TopDirectoryOnly);
            oriBitmaps = new D2D.Bitmap[fis.Length];
            for (int i = 0; i < oriBitmaps.Length; i++)
            {
                oriBitmaps[i] = LoadFromFile(RenderForm.RenderTarget, fis[i].FullName);
            }

            startPos = new Mathe.RawVector2[count];
            nowPos   = new Mathe.RawVector2[count];
            speeds   = new float[count];
            timings  = new float[count];
            bitmaps  = new D2D.Bitmap[count];

            r           = new float[count];
            startF      = new float[count];
            f           = new float[count];
            shakeOffset = new float[count];
            shakeCycle  = new float[count];

            brush1 = new D2D.LinearGradientBrush(RenderForm.RenderTarget, new D2D.LinearGradientBrushProperties()
            {
                StartPoint = new Mathe.RawVector2(0, 0),
                EndPoint   = new Mathe.RawVector2(0, panelHeight + 100),
            },
                                                 new D2D.GradientStopCollection(RenderForm.RenderTarget, new D2D.GradientStop[]
            {
                new D2D.GradientStop()
                {
                    Color    = new Mathe.RawColor4(0, 0, 0, 0),
                    Position = 1,
                },
                new D2D.GradientStop()
                {
                    Color    = new Mathe.RawColor4(0, 0, 0, 0.1f),
                    Position = 0,
                }
            }));

            brush2 = new D2D.LinearGradientBrush(RenderForm.RenderTarget, new D2D.LinearGradientBrushProperties()
            {
                StartPoint = new Mathe.RawVector2(0, RenderForm.Height - panelHeight),
                EndPoint   = new Mathe.RawVector2(0, RenderForm.Height),
            },
                                                 new D2D.GradientStopCollection(RenderForm.RenderTarget, new D2D.GradientStop[]
            {
                new D2D.GradientStop()
                {
                    Color    = new Mathe.RawColor4(0, 0, 0, 0),
                    Position = 0,
                },
                new D2D.GradientStop()
                {
                    Color    = new Mathe.RawColor4(0, 0, 0, 0.7f),
                    Position = 1,
                }
            }));

            for (int i = 0; i < count; i++)
            {
                bitmaps[i] = oriBitmaps[rnd.Next(0, oriBitmaps.Length)];
                r[i]       = (float)(rnd.NextDouble() * 20);
                startF[i]  = (float)rnd.NextDouble();
                speeds[i]  = r[i] * r[i] * 0.0005f;
                //speeds[i] = (float)(rnd.NextDouble() * 0.07 + 0.02);
                timings[i]     = 1 / speeds[i] * 1000;
                startPos[i]    = new Mathe.RawVector2(rnd.Next(0, RenderForm.Width), RenderForm.Height + rnd.Next(40, 50));
                shakeCycle[i]  = 1 / speeds[i] * 500;
                shakeOffset[i] = (float)rnd.NextDouble() * shakeCycle[i];
            }

            sw = new Stopwatch();
            sw.Restart();
        }
Beispiel #38
-1
 private static unsafe Result Fill2DCallbackImpl(RawColor4* outVector, RawVector2* textCoord, RawVector2* textelSize, IntPtr data)
 {
     try
     {
         var handle = GCHandle.FromIntPtr(data);
         *outVector = ((Fill2DCallback)handle.Target)(*textCoord, *textelSize);
     }
     catch (SharpDXException exception)
     {
         return exception.ResultCode.Code;
     }
     catch (Exception)
     {
         return Result.Fail.Code;
     }
     return Result.Ok.Code;
 }