public void Undo(InkCanvas inkCanvas) { foreach (InkStroke isk in DeletedStrokes) { var strokeBuilder = new InkStrokeBuilder(); strokeBuilder.SetDefaultDrawingAttributes(isk.DrawingAttributes); System.Numerics.Matrix3x2 matr = isk.PointTransform; IReadOnlyList <InkPoint> inkPoints = isk.GetInkPoints(); inkCanvas.InkPresenter.StrokeContainer.AddStroke(strokeBuilder.CreateStrokeFromInkPoints(inkPoints, matr, isk.StrokeStartedTime, isk.StrokeDuration)); } }
public void RotateTest() { var t = new Transform(); // Assert the matrixes are the identity matrixes Assert.AreEqual(t.LocalToWorld, Matrix3x2.Identity); Assert.AreEqual(t.WorldToLocal, Matrix3x2.Identity); // Test identity rotation t.Rotate(90); Assert.AreEqual(t.LocalToWorld, Matrix3x2.CreateRotation(MathHelper.DegreesToRadians(-90))); Assert.AreEqual(t.WorldToLocal, Matrix3x2.CreateRotation(MathHelper.DegreesToRadians(90))); }
public EraseStrokeOperation(InkStroke inkStroke) { var stroke = inkStroke; var strokeBuilder = new InkStrokeBuilder(); strokeBuilder.SetDefaultDrawingAttributes(stroke.DrawingAttributes); System.Numerics.Matrix3x2 matr = stroke.PointTransform; IReadOnlyList <InkPoint> inkPoints = stroke.GetInkPoints(); ErasedStroke = strokeBuilder.CreateStrokeFromInkPoints(inkPoints, matr); ErasedStroke.StrokeStartedTime = stroke.StrokeStartedTime; }
public virtual void GetTransform( out System.Numerics.Matrix3x2 transform ) { var fp = GetFunctionPointer(7); if (m_GetTransformFunc == null) { m_GetTransformFunc = (GetTransformFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(GetTransformFunc)); } m_GetTransformFunc(m_ptr, out transform); }
public virtual void SetTransform( ref System.Numerics.Matrix3x2 transform ) { var fp = GetFunctionPointer(5); if (m_SetTransformFunc == null) { m_SetTransformFunc = (SetTransformFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(SetTransformFunc)); } m_SetTransformFunc(m_ptr, ref transform); }
public static Matrix ToXNA(this System.Numerics.Matrix3x2 matrix) { var result = Matrix.Identity; result.M11 = matrix.M11; result.M12 = matrix.M12; result.M21 = matrix.M21; result.M22 = matrix.M22; result.M41 = matrix.M31; result.M42 = matrix.M32; return(result); }
public virtual int GetBounds( ref System.Numerics.Matrix3x2 worldTransform, out System.Numerics.Vector4 bounds ) { var fp = GetFunctionPointer(4); if (m_GetBoundsFunc == null) { m_GetBoundsFunc = (GetBoundsFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(GetBoundsFunc)); } return(m_GetBoundsFunc(m_ptr, ref worldTransform, out bounds)); }
public TransformSRT2(System.Numerics.Matrix3x2 matrix) { var sx = matrix.M12 == 0 ? Math.Abs(matrix.M11) : new XY(matrix.M11, matrix.M12).Length(); var sy = matrix.M21 == 0 ? Math.Abs(matrix.M22) : new XY(matrix.M21, matrix.M22).Length(); if (matrix.GetDeterminant() < 0) { sy = -sy; } Scale = new XY(sx, sy); Rotation = (float)Math.Atan2(matrix.M12, matrix.M11); Translation = matrix.Translation; }
public virtual int CreateTransformedGeometry( ID2D1Geometry sourceGeometry, ref System.Numerics.Matrix3x2 transform, out ID2D1TransformedGeometry transformedGeometry ) { var fp = GetFunctionPointer(9); if (m_CreateTransformedGeometryFunc == null) { m_CreateTransformedGeometryFunc = (CreateTransformedGeometryFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(CreateTransformedGeometryFunc)); } transformedGeometry = new ID2D1TransformedGeometry(); return(m_CreateTransformedGeometryFunc(m_ptr, sourceGeometry != null ? sourceGeometry.Ptr : IntPtr.Zero, ref transform, out transformedGeometry.PtrForNew)); }
public virtual int ComputeLength( ref System.Numerics.Matrix3x2 worldTransform, float flatteningTolerance, out float length ) { var fp = GetFunctionPointer(14); if (m_ComputeLengthFunc == null) { m_ComputeLengthFunc = (ComputeLengthFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(ComputeLengthFunc)); } return(m_ComputeLengthFunc(m_ptr, ref worldTransform, flatteningTolerance, out length)); }
private void RestoreValue(BaseOperation operation) { if (operation is Operation <InkStroke> currentOperation) { InkStroke stroke = currentOperation.Instance; InkStrokeBuilder strokeBuilder = new InkStrokeBuilder(); strokeBuilder.SetDefaultDrawingAttributes(stroke.DrawingAttributes); System.Numerics.Matrix3x2 matr = stroke.PointTransform; IReadOnlyList <InkPoint> inkPoints = stroke.GetInkPoints(); InkStroke stk = strokeBuilder.CreateStrokeFromInkPoints(inkPoints, matr); presenter.StrokeContainer.AddStroke(stk); currentOperation.Instance = stk; } }
public void Redo(InkCanvas inkCanvas) { inkCanvas.InkPresenter.StrokeContainer.Clear(); foreach (InkStroke isk in StrokesAfter) { var strokeBuilder = new InkStrokeBuilder(); strokeBuilder.SetDefaultDrawingAttributes(isk.DrawingAttributes); System.Numerics.Matrix3x2 matr = isk.PointTransform; IReadOnlyList <InkPoint> inkPoints = isk.GetInkPoints(); InkStroke inkStroke = strokeBuilder.CreateStrokeFromInkPoints(inkPoints, matr); inkStroke.StrokeStartedTime = isk.StrokeStartedTime; inkCanvas.InkPresenter.StrokeContainer.AddStroke(inkStroke); } }
public virtual int Outline( ref System.Numerics.Matrix3x2 worldTransform, float flatteningTolerance, ID2D1SimplifiedGeometrySink geometrySink ) { var fp = GetFunctionPointer(12); if (m_OutlineFunc == null) { m_OutlineFunc = (OutlineFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(OutlineFunc)); } return(m_OutlineFunc(m_ptr, ref worldTransform, flatteningTolerance, geometrySink != null ? geometrySink.Ptr : IntPtr.Zero)); }
public virtual int Tessellate( ref System.Numerics.Matrix3x2 worldTransform, float flatteningTolerance, ID2D1TessellationSink tessellationSink ) { var fp = GetFunctionPointer(10); if (m_TessellateFunc == null) { m_TessellateFunc = (TessellateFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(TessellateFunc)); } return(m_TessellateFunc(m_ptr, ref worldTransform, flatteningTolerance, tessellationSink != null ? tessellationSink.Ptr : IntPtr.Zero)); }
public BitmapBounds(System.Numerics.Matrix3x2 srcXform, float srcW, float srcH) { var a = srcXform.Translation; var b = XY.Transform(new XY(srcW, 0), srcXform); var c = XY.Transform(new XY(srcW, srcH), srcXform); var d = XY.Transform(new XY(0, srcH), srcXform); var min = XY.Min(XY.Min(XY.Min(a, b), c), d); var max = XY.Max(XY.Max(XY.Max(a, b), c), d); this.X = (int)min.X; this.Y = (int)min.Y; this.Width = (int)max.X + 1 - this.X; this.Height = (int)max.Y + 1 - this.Y; }
public virtual int Simplify( D2D1_GEOMETRY_SIMPLIFICATION_OPTION simplificationOption, ref System.Numerics.Matrix3x2 worldTransform, float flatteningTolerance, ID2D1SimplifiedGeometrySink geometrySink ) { var fp = GetFunctionPointer(9); if (m_SimplifyFunc == null) { m_SimplifyFunc = (SimplifyFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(SimplifyFunc)); } return(m_SimplifyFunc(m_ptr, simplificationOption, ref worldTransform, flatteningTolerance, geometrySink != null ? geometrySink.Ptr : IntPtr.Zero)); }
public virtual int FillContainsPoint( System.Numerics.Vector2 point, ref System.Numerics.Matrix3x2 worldTransform, float flatteningTolerance, out int contains ) { var fp = GetFunctionPointer(7); if (m_FillContainsPointFunc == null) { m_FillContainsPointFunc = (FillContainsPointFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(FillContainsPointFunc)); } return(m_FillContainsPointFunc(m_ptr, point, ref worldTransform, flatteningTolerance, out contains)); }
private void Redo_Click(object sender, RoutedEventArgs e) { redo.IsChecked = false; if (UndoStrokes.Count > 0) { var stroke = UndoStrokes.Pop(); var strokeBuilder = new InkStrokeBuilder(); strokeBuilder.SetDefaultDrawingAttributes(stroke.DrawingAttributes); System.Numerics.Matrix3x2 matr = stroke.PointTransform; IReadOnlyList <InkPoint> inkPoints = stroke.GetInkPoints(); InkStroke stk = strokeBuilder.CreateStrokeFromInkPoints(inkPoints, matr); canvas.InkPresenter.StrokeContainer.AddStroke(stk); } }
public virtual int CompareWithGeometry( ID2D1Geometry inputGeometry, ref System.Numerics.Matrix3x2 inputGeometryTransform, float flatteningTolerance, out D2D1_GEOMETRY_RELATION relation ) { var fp = GetFunctionPointer(8); if (m_CompareWithGeometryFunc == null) { m_CompareWithGeometryFunc = (CompareWithGeometryFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(CompareWithGeometryFunc)); } return(m_CompareWithGeometryFunc(m_ptr, inputGeometry != null ? inputGeometry.Ptr : IntPtr.Zero, ref inputGeometryTransform, flatteningTolerance, out relation)); }
public virtual int CombineWithGeometry( ID2D1Geometry inputGeometry, D2D1_COMBINE_MODE combineMode, ref System.Numerics.Matrix3x2 inputGeometryTransform, float flatteningTolerance, ID2D1SimplifiedGeometrySink geometrySink ) { var fp = GetFunctionPointer(11); if (m_CombineWithGeometryFunc == null) { m_CombineWithGeometryFunc = (CombineWithGeometryFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(CombineWithGeometryFunc)); } return(m_CombineWithGeometryFunc(m_ptr, inputGeometry != null ? inputGeometry.Ptr : IntPtr.Zero, combineMode, ref inputGeometryTransform, flatteningTolerance, geometrySink != null ? geometrySink.Ptr : IntPtr.Zero)); }
public virtual int ComputePointAndSegmentAtLength( float length, uint startSegment, ref System.Numerics.Matrix3x2 worldTransform, float flatteningTolerance, out D2D1_POINT_DESCRIPTION pointDescription ) { var fp = GetFunctionPointer(21); if (m_ComputePointAndSegmentAtLengthFunc == null) { m_ComputePointAndSegmentAtLengthFunc = (ComputePointAndSegmentAtLengthFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(ComputePointAndSegmentAtLengthFunc)); } return(m_ComputePointAndSegmentAtLengthFunc(m_ptr, length, startSegment, ref worldTransform, flatteningTolerance, out pointDescription)); }
public void RedoLastStorke() { if (UndoStrokes.Count > 0) { var stroke = UndoStrokes.Pop(); // This will blow up sky high: // InkCanvas.InkPresenter.StrokeContainer.AddStroke(stroke); var strokeBuilder = new InkStrokeBuilder(); strokeBuilder.SetDefaultDrawingAttributes(stroke.DrawingAttributes); System.Numerics.Matrix3x2 matr = stroke.PointTransform; IReadOnlyList <InkPoint> inkPoints = stroke.GetInkPoints(); InkStroke stk = strokeBuilder.CreateStrokeFromInkPoints(inkPoints, matr); InkCanvas.InkPresenter.StrokeContainer.AddStroke(stk); } }
public virtual int GetWidenedBounds( float strokeWidth, ID2D1StrokeStyle strokeStyle, ref System.Numerics.Matrix3x2 worldTransform, float flatteningTolerance, out System.Numerics.Vector4 bounds ) { var fp = GetFunctionPointer(5); if (m_GetWidenedBoundsFunc == null) { m_GetWidenedBoundsFunc = (GetWidenedBoundsFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(GetWidenedBoundsFunc)); } return(m_GetWidenedBoundsFunc(m_ptr, strokeWidth, strokeStyle != null ? strokeStyle.Ptr : IntPtr.Zero, ref worldTransform, flatteningTolerance, out bounds)); }
public virtual int Widen( float strokeWidth, ID2D1StrokeStyle strokeStyle, ref System.Numerics.Matrix3x2 worldTransform, float flatteningTolerance, ID2D1SimplifiedGeometrySink geometrySink ) { var fp = GetFunctionPointer(16); if (m_WidenFunc == null) { m_WidenFunc = (WidenFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(WidenFunc)); } return(m_WidenFunc(m_ptr, strokeWidth, strokeStyle != null ? strokeStyle.Ptr : IntPtr.Zero, ref worldTransform, flatteningTolerance, geometrySink != null ? geometrySink.Ptr : IntPtr.Zero)); }
public virtual int ComputePointAtLength( float length, ref System.Numerics.Matrix3x2 worldTransform, float flatteningTolerance, out System.Numerics.Vector2 point, out System.Numerics.Vector2 unitTangentVector ) { var fp = GetFunctionPointer(15); if (m_ComputePointAtLengthFunc == null) { m_ComputePointAtLengthFunc = (ComputePointAtLengthFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(ComputePointAtLengthFunc)); } return(m_ComputePointAtLengthFunc(m_ptr, length, ref worldTransform, flatteningTolerance, out point, out unitTangentVector)); }
public void DrawTo(ICanvas2D target, System.Numerics.Matrix3x2 transform) { var tmp = new ImageSource(); for (int y = 0; y < _Height; ++y) { for (int x = 0; x < _Width; ++x) { var offset = new XY(x * 16, y * 16); var idx = _Tiles[y * _Width + x]; _Sprites[idx].CopyTo(tmp, -offset); target.DrawImage(transform, tmp); } } }
public virtual int StrokeContainsPoint( System.Numerics.Vector2 point, float strokeWidth, ID2D1StrokeStyle strokeStyle, ref System.Numerics.Matrix3x2 worldTransform, float flatteningTolerance, out int contains ) { var fp = GetFunctionPointer(6); if (m_StrokeContainsPointFunc == null) { m_StrokeContainsPointFunc = (StrokeContainsPointFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(StrokeContainsPointFunc)); } return(m_StrokeContainsPointFunc(m_ptr, point, strokeWidth, strokeStyle != null ? strokeStyle.Ptr : IntPtr.Zero, ref worldTransform, flatteningTolerance, out contains)); }
public static void warpAffine(Mat src, Mat dst, System.Numerics.Matrix3x2 trans, Size dSize, Interpolation inter = Interpolation.INTER_LINEAR, bool inverseMap = false, BorderMode borderMode = BorderMode.BORDER_CONSTANT, double[] borderValue = null) { Mat transMat = trans; int flags = inverseMap ? ((int)InverseMap.WARP_INVERSE_MAP | (int)inter) : (int)inter; Mat matBorderValue = null; IntPtr ptrBorderValue = IntPtr.Zero; if (borderMode == BorderMode.BORDER_CONSTANT && borderValue != null && borderValue.Length > 0) { matBorderValue = new Mat(1, borderValue.Length, Mat.makeType(1, Mat.MatDepth.CV_64F)); if (matBorderValue.Valid && matBorderValue.copyAll(borderValue, 0, borderValue.Length)) { ptrBorderValue = matBorderValue.Data; } } NativeInvoker.coreCvWarpAffine(src.MatObj, dst.MatObj, transMat.MatObj, (int)dSize.w, (int)dSize.h, flags, (int)borderMode, ptrBorderValue); }
public void TransformVertices(Span <Vertex2> vertices, System.Numerics.Matrix3x2 xform, _ImageFlags o, uint color) { xform = _Transforms[(int)o] * xform; var r0 = new XY(xform.M11, xform.M12); var r1 = new XY(xform.M21, xform.M22); vertices[0].Position = xform.Translation; vertices[0].Color = color; vertices[0].TextureCoord = _UV0; vertices[1].Position = xform.Translation + r0; vertices[1].Color = color; vertices[1].TextureCoord = _UV1; vertices[2].Position = xform.Translation + r0 + r1; vertices[2].Color = color; vertices[2].TextureCoord = _UV2; vertices[3].Position = xform.Translation + r1; vertices[3].Color = color; vertices[3].TextureCoord = _UV3; }
public Matrix(System.Numerics.Matrix3x2 matrix) { }