예제 #1
0
 public Matrix(FlashMatrix m)
 {
     if (m == null)
     {
         m = new FlashMatrix();
     }
     native = m;
 }
예제 #2
0
        void InitMatrix(double angle)
        {
            angle = (angle % 360) * Const.DEGTORAD;
            var m = new FlashMatrix();

            m.createGradientBox(_rect.Width, _rect.Height, angle, _rect.X, _rect.Y);
            _transform = new Matrix(m);
            //PrintMatrix("Init", _transform);
        }
예제 #3
0
 public void Multiply(Matrix matrix, MatrixOrder order)
 {
     if (matrix == null)
     {
         throw new ArgumentNullException("matrix");
     }
     if (order == MatrixOrder.Append)
     {
         native.concat(matrix.native);
     }
     else
     {
         var m = matrix.native.clone();
         m.concat(native);
         native = m;
     }
 }
예제 #4
0
        public void RotateAt(float angle, PointF point, MatrixOrder order)
        {
            if ((order < MatrixOrder.Prepend) || (order > MatrixOrder.Append))
            {
                throw new ArgumentException("order");
            }

            angle *= (float)(Math.PI / 180.0); // degrees to radians
            float cos = (float)Math.Cos(angle);
            float sin = (float)Math.Sin(angle);
            float e4  = -point.X * cos + point.Y * sin + point.X;
            float e5  = -point.X * sin - point.Y * cos + point.Y;

            float[] m = Elements;

            //Status status;
            if (order == MatrixOrder.Prepend)
            {
                native = new FlashMatrix(
                    cos * m[0] + sin * m[2],
                    cos * m[1] + sin * m[3],
                    -sin * m[0] + cos * m[2],
                    -sin * m[1] + cos * m[3],
                    e4 * m[0] + e5 * m[2] + m[4],
                    e4 * m[1] + e5 * m[3] + m[5]);
            }
            else
            {
                native = new FlashMatrix(
                    m[0] * cos + m[1] * -sin,
                    m[0] * sin + m[1] * cos,
                    m[2] * cos + m[3] * -sin,
                    m[2] * sin + m[3] * cos,
                    m[4] * cos + m[5] * -sin + e4,
                    m[4] * sin + m[5] * cos + e5);
            }
        }
예제 #5
0
 public Matrix(float m11, float m12, float m21, float m22, float dx, float dy)
 {
     native = new FlashMatrix(m11, m12, m21, m22, dx, dy);
 }
예제 #6
0
 public Matrix()
 {
     native = new FlashMatrix();
 }
예제 #7
0
 public void Dispose()
 {
     native = null;
     GC.SuppressFinalize(this);
 }
예제 #8
0
 public virtual void drawWithQuality(IBitmapDrawable source, Matrix matrix = null, ColorTransform colorTransform = null, string blendMode = null, Rectangle clipRect = null, bool smoothing = false, string quality = null)
 {
     draw(source, matrix, colorTransform, blendMode, clipRect, smoothing);
 }
예제 #9
0
        public virtual void draw(IBitmapDrawable source, Matrix matrix = null, ColorTransform colorTransform = null, string blendMode = null, Rectangle clipRect = null, bool smoothing = false)
        {
            var sourceDisplayObject = source as DisplayObject;

            if (sourceDisplayObject != null)
            {
                if (clipRect != null)
                {
                    this.width  = (int)clipRect.width;
                    this.height = (int)clipRect.height;
                }
                else
                {
                    this.width  = (int)sourceDisplayObject.width;
                    this.height = (int)sourceDisplayObject.height;
                }

                if (matrix != null)
                {
                    sourceDisplayObject.transform.matrix = matrix;
                }

                if (colorTransform != null)
                {
                    sourceDisplayObject.transform.colorTransform = colorTransform;
                }

                RenderingContext2D       ctx;
                CanvasRenderingContext2D result;
                if (_internalImage.FastAs <CanvasRenderingContext2D>() != null)
                {
                    ctx    = new RenderingContext2D((CanvasRenderingContext2D)_internalImage);
                    result = (CanvasRenderingContext2D)_internalImage;
                }
                else
                {
                    var canvas = new HTMLCanvasElement();
                    canvas.Width  = this.width;
                    canvas.Height = this.height;
                    var context2d = canvas.GetContext(CanvasTypes.CanvasContext2DType.CanvasRenderingContext2D);
                    ctx = new RenderingContext2D(context2d);
                    this.drawSelf(context2d, 0, 0, this.width, this.height);
                    result = context2d;
                }

                ctx.ctx.Save();
                if (clipRect != null)
                {
                    ctx.ctx.Rect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
                    ctx.ctx.Clip();
                }

                if (matrix != null)
                {
                    ctx.SetTransform(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
                }

                if (blendMode != null)
                {
                    ctx.blendMode = blendMode;
                }

                sourceDisplayObject.draw(ctx);
                internalImage = result;
                ctx.ctx.Restore();
            }
        }