public static bool IsFlipped(this Matrix3x2Double matrix)
        {
            if (matrix.IsIdentity)
            {
                return(false);
            }
            VectorDouble vec  = new VectorDouble(1.0, 0.0);
            VectorDouble num2 = matrix.Transform(vec);
            double       num4 = Math.Atan2(num2.Y, num2.X) * 57.295779513082323;
            VectorDouble num5 = new VectorDouble(0.0, 1.0);
            VectorDouble num6 = matrix.Transform(num5);
            double       num8 = (Math.Atan2(num6.Y, num6.X) * 57.295779513082323) - 90.0;

            while (num4 < 0.0)
            {
                num4 += 360.0;
            }
            while (num8 < 0.0)
            {
                num8 += 360.0;
            }
            double num9 = Math.Abs((double)(num4 - num8));

            return((num9 > 1.0) && (num9 < 359.0));
        }
        public static double GetRotationRadians(this Matrix3x2Double matrix)
        {
            if (matrix.IsIdentity)
            {
                return(0.0);
            }
            VectorDouble vec  = new VectorDouble(1.0, 0.0);
            VectorDouble num2 = matrix.Transform(vec);

            return(Math.Atan2(num2.Y, num2.X));
        }
Esempio n. 3
0
        private void RenderMask(ISurface <ColorAlpha8> dstMask, PointInt32 renderOffset)
        {
            int       width     = dstMask.Width;
            int       height    = dstMask.Height;
            bool      flag      = false;
            SizeInt32 size      = new SizeInt32(width, height);
            RectInt32 rectangle = new RectInt32(renderOffset, size);

            if (!flag && this.matrix.HasInverse)
            {
                Matrix3x2Double inverse           = this.matrix.Inverse;
                PointDouble     pt                = inverse.Transform(rectangle.TopLeft);
                PointDouble     num7              = inverse.Transform(rectangle.TopRight);
                PointDouble     num8              = inverse.Transform(rectangle.BottomLeft);
                PointDouble     num9              = inverse.Transform(rectangle.BottomRight);
                RectDouble      srcCoverageBounds = this.srcCoverageBounds;
                if ((srcCoverageBounds.Contains(pt) && srcCoverageBounds.Contains(num7)) && (srcCoverageBounds.Contains(num8) && srcCoverageBounds.Contains(num9)))
                {
                    dstMask.Clear(ColorAlpha8.Opaque);
                    flag = true;
                }
            }
            if (!flag)
            {
                GeometryRelation relation;
                IDirect2DFactory perThread = Direct2DFactory.PerThread;
                using (IRectangleGeometry geometry = perThread.CreateRectangleGeometry(rectangle))
                {
                    base.ThrowIfCancellationRequested();
                    using (IRectangleGeometry geometry2 = perThread.CreateRectangleGeometry(this.srcCoverageBounds))
                    {
                        base.ThrowIfCancellationRequested();
                        relation = geometry.CompareWithGeometry(geometry2, new Matrix3x2Float?((Matrix3x2Float)this.matrix), null);
                        base.ThrowIfCancellationRequested();
                    }
                }
                switch (relation)
                {
                case GeometryRelation.IsContained:
                    dstMask.Clear(ColorAlpha8.Opaque);
                    flag = true;
                    break;

                case GeometryRelation.Disjoint:
                    dstMask.Clear(ColorAlpha8.Transparent);
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                using (IDrawingContext context = DrawingContext.FromSurface(dstMask, FactorySource.PerThread))
                {
                    base.ThrowIfCancellationRequested();
                    context.Clear(null);
                    context.AntialiasMode = AntialiasMode.PerPrimitive;
                    using (context.UseTranslateTransform((float)-renderOffset.X, (float)-renderOffset.Y, MatrixMultiplyOrder.Prepend))
                    {
                        using (context.UseTransformMultiply((Matrix3x2Float)this.matrix, MatrixMultiplyOrder.Prepend))
                        {
                            context.FillRectangle(this.srcCoverageBounds, whiteBrush);
                        }
                    }
                }
            }
        }