Exemple #1
0
        public MaterialSet ProvideNext(ProviderContext context)
        {
            var materialSet = currentIndex % 2 == 0 ? MaterialSet1 : MaterialSet2;

            currentIndex++;
            return(materialSet);
        }
        public MaterialSet ProvideNext(ProviderContext context)
        {
            if (currentIndex > context.CycleLength)
            {
                currentIndex = 0;
            }

            var         position                = 1.0 / context.CycleLength * currentIndex;
            var         gradientStepSpan        = GradientStepData.Sum(step => step.Offset);
            var         additivestepPercentage  = 0d;
            MaterialSet interpolatedMaterialSet = Palette.Red;

            if (position >= 1)
            {
                currentIndex++;
                return(GradientStepData.Last().MaterialSet);
            }
            for (var x = 0; x <= GradientStepData.Count - 2; x++)
            {
                var stepPercentage            = GradientStepData[x].Offset / gradientStepSpan;
                var stepProgression           = position - additivestepPercentage;
                var stepProgressionPercentage = stepProgression / stepPercentage;

                if (position >= additivestepPercentage && position < (additivestepPercentage + stepPercentage))
                {
                    interpolatedMaterialSet = MediaExtensions.Interpolate(GradientStepData[x].MaterialSet,
                                                                          GradientStepData[x + 1].MaterialSet, stepProgressionPercentage);
                    break;
                }
                additivestepPercentage += stepPercentage;
            }
            currentIndex++;
            return(interpolatedMaterialSet);
        }
        public IMaterialProvider ProvideNext(ProviderContext context)
        {
            switch (CyclicalMode)
            {
            case CyclicalBehavior.Repeat:
            {
                if (currentIndex > MaterialProviderSequence.Count - 1)
                {
                    currentIndex = 0;
                }
                if (currentIndex < 0)
                {
                    currentIndex = MaterialProviderSequence.Count - 1;
                }

                var currentSet = MaterialProviderSequence[currentIndex];
                if (Reverse)
                {
                    currentIndex--;
                }
                else
                {
                    currentIndex++;
                }
                return(currentSet);
            }

            case CyclicalBehavior.Mirror:
            {
                if (currentIndex > MaterialProviderSequence.Count - 1)
                {
                    currentIndex    = MaterialProviderSequence.Count - 2;
                    mirrorDirection = MirrorDirection.Backward;
                }
                else if (currentIndex < 0)
                {
                    currentIndex    = 1;
                    mirrorDirection = MirrorDirection.Forward;
                }
                var currentSet = MaterialProviderSequence[currentIndex];

                switch (mirrorDirection)
                {
                case MirrorDirection.Forward:
                    currentIndex++;
                    break;

                case MirrorDirection.Backward:
                    currentIndex--;
                    break;
                }
                return(currentSet);
            }

            default:
                throw new NotSupportedException($"Cyclical Mode {CyclicalMode} is not supported.");
            }
        }
 public void Reset(ProviderContext context)
 {
     if (Reverse)
     {
         currentIndex = context.CycleLength - 1;
     }
     else
     {
         currentIndex = 0;
     }
 }
Exemple #5
0
 public void Reset(ref ProviderContext context)
 {
     if (Reverse)
     {
         context.ProviderIndex = context.CycleLength - 1;
     }
     else
     {
         context.ProviderIndex = 0;
     }
 }
Exemple #6
0
 public void Reset(ProviderContext context)
 {
     currentIndex = 0;
 }
 public MaterialSet ProvideNext(ProviderContext context)
 {
     throw new NotSupportedException(
               "ProvideNext cannot be used on a IDataAwareMaterialProvider. Use ProvideNextDataAware.");
 }
 public void Reset(ProviderContext context)
 {
 }
 public MaterialSet ProvideNext(ProviderContext context)
 {
     return(MaterialSet);
 }