Exemple #1
0
        public TransformModel Copy()
        {
            var copy = new TransformModel();

            copy.SetFromValues(_values, Probability, Color, ColorPosition, IsFinal);
            return(copy);
        }
Exemple #2
0
        private static double[] SolveValues(double angle, TransformModel t)
        {
            var sin   = Math.Sin(angle);
            var cos   = Math.Cos(angle);
            var cos2  = Math.Cos(2.0 * angle);
            var sin2  = Math.Sin(2.0 * angle);
            var cosSq = cos * cos;

            var n1     = t.A * t.D + t.B * t.C + t.A * t.D * cos2 - t.B * t.C * cos2;
            var n2     = 2.0 * t.D * cos - 2.0 * t.C * sin;
            var scaleX = n1 / n2;

            FixNaN(ref scaleX);

            n2 = 2.0 * t.A * cos + 2.0 * t.B * sin;
            var scaleY = n1 / n2;

            FixNaN(ref scaleY);

            n1 = 2.0 * t.B * t.D + t.A * t.D * sin2 - t.B * t.C * sin2;
            n2 = 2.0 * t.B * t.C + 2 * t.A * t.D * cosSq - 2.0 * t.B * t.C * cosSq;
            var shearX = n1 / n2;

            FixNaN(ref shearX);

            n1 = 2.0 * t.A * t.C - t.A * t.D * sin2 + t.B * t.C * sin2;
            var shearY = n1 / n2;

            FixNaN(ref shearY);

            return(new[] { t.E, t.F, scaleX, scaleY, shearX, shearY, angle });
        }
        public static TransformModel[] GetTransformationsFromFlameModel(FlameModel model)
        {
            var length          = model.Coefficients.Count;
            var transformations = new TransformModel[length];
            var hasGradient     = model.GradientPack != null;

            for (var i = 0; i < length; i++)
            {
                var t             = new TransformModel();
                var colorPosition = .5;
                if (hasGradient)
                {
                    colorPosition = model.FunctionColorPositions[i];
                }
                var mif = model.IsFinal;
                t.SetFromCoefficients(model.Coefficients[i], model.Coefficients[i][6], model.FunctionColors[i],
                                      mif.Count != 0 && model.IsFinal[i], colorPosition);
                transformations[i] = t;
            }

            return(transformations);
        }