Exemplo n.º 1
0
        private void SetValue(int indexInNineValues, float value)
        {
            var nineValues = new float[9];

            control.GetValues(nineValues);
            nineValues[indexInNineValues] = value;
            control.SetValues(nineValues);
        }
Exemplo n.º 2
0
        public static void SetValues(this AG.Matrix dest, Matrix m)
        {
            var v = new float[9];

            dest.GetValues(v);
            v [AG.Matrix.MtransX] = (float)m.OffsetX;
            v [AG.Matrix.MtransY] = (float)m.OffsetY;
            v [AG.Matrix.MskewX]  = (float)m.M21;
            v [AG.Matrix.MskewY]  = (float)m.M12;
            v [AG.Matrix.MscaleX] = (float)m.M11;
            v [AG.Matrix.MscaleY] = (float)m.M22;
            dest.SetValues(v);
        }
Exemplo n.º 3
0
        public static Matrix ToXwt(this AG.Matrix value)
        {
            var m = new float[9];

            value.GetValues(m);
            return(new Matrix(
                       m [AG.Matrix.MscaleX],
                       m [AG.Matrix.MskewY],
                       m [AG.Matrix.MskewX],
                       m [AG.Matrix.MscaleY],
                       m [AG.Matrix.MtransX],
                       m [AG.Matrix.MtransY]));
        }
Exemplo n.º 4
0
 private float GetValue(Matrix matrix, int whichValue)
 {
     matrix.GetValues(m_MatrixValues);
     return m_MatrixValues[whichValue];
 }
Exemplo n.º 5
0
 protected float GetValue(Matrix matrix, int whichValue)
 {
     matrix.GetValues(matrixValues);
     return matrixValues[whichValue];
 }
Exemplo n.º 6
0
        droidGraphics.LinearGradient CreateLinearGradient(LinearGradientBrush xamBrush,
                                                          droidGraphics.RectF pathBounds,
                                                          droidGraphics.Matrix stretchMatrix)
        {
            if (Path == null)
            {
                return(null);
            }

            int[]   colors  = new int[xamBrush.GradientStops.Count];
            float[] offsets = new float[xamBrush.GradientStops.Count];

            for (int index = 0; index < xamBrush.GradientStops.Count; index++)
            {
                colors[index]  = ConvertColor(xamBrush.GradientStops[index].Color);
                offsets[index] = (float)xamBrush.GradientStops[index].Offset;
            }

            droidGraphics.Shader.TileMode tilemode = droidGraphics.Shader.TileMode.Clamp;

            switch (xamBrush.SpreadMethod)
            {
            case GradientSpreadMethod.Pad:
                tilemode = droidGraphics.Shader.TileMode.Clamp;
                break;

            case GradientSpreadMethod.Refect:
                tilemode = droidGraphics.Shader.TileMode.Mirror;
                break;

            case GradientSpreadMethod.Repeat:
                tilemode = droidGraphics.Shader.TileMode.Repeat;
                break;
            }

            // pathBounds has already been stretched
            using (droidGraphics.RectF xformedBounds = new droidGraphics.RectF(pathBounds))
            {
                if (xamBrush.Transform != null)
                {
                    // But the brush transform offsets needs to be stretched
                    droidGraphics.Matrix transform = xamBrush.Transform.GetNativeObject() as droidGraphics.Matrix;

                    float[] stretchValues = new float[9];
                    stretchMatrix.GetValues(stretchValues);

                    float[] transformValues = new float[9];
                    transform.GetValues(transformValues);

                    // Scale x-offset by stretch
                    transformValues[2] *= stretchValues[0];

                    // Scale y-offset by stretch
                    transformValues[5] *= stretchValues[4];

                    using (droidGraphics.Matrix matx = new droidGraphics.Matrix())
                    {
                        matx.SetValues(transformValues);

                        float[] a2 = new float[9];
                        matx.GetValues(a2);

                        matx.MapRect(xformedBounds);
                    }
                }

                return(new droidGraphics.LinearGradient((float)xamBrush.StartPoint.X * xformedBounds.Width() + xformedBounds.Left,
                                                        (float)xamBrush.StartPoint.Y * xformedBounds.Height() + xformedBounds.Top,
                                                        (float)xamBrush.EndPoint.X * xformedBounds.Width() + xformedBounds.Left,
                                                        (float)xamBrush.EndPoint.Y * xformedBounds.Height() + xformedBounds.Top,
                                                        colors, offsets, tilemode));
            }
        }