public override SolidColorBrush GetMaterial(
            Swatch materialSet)
        {
            var material1 = materialSet.GetMaterial(Luminosity1);
            var material2 = materialSet.GetMaterial(Luminosity2);

            var avgLumIndex = (Luminosity1.LuminosityIndex + Luminosity2.LuminosityIndex) / 2d;
            var finalLum    = new Luminosity((int)avgLumIndex.Round(), Luminosity1.IsAccent);

            var interpolatedMaterial = material1.Brush.Color.Blend(material2.Brush.Color, Progression);

            var finalColor = interpolatedMaterial.WithOpacity(Opacity);

            var m1Identity = material1.Identity;

            //TODO should the finalLum's isAccent be m1Identity's or Luminosity1.Isaccent? was m1Identity.
            var finalIdentity = new MaterialIdentity(
                m1Identity.SwatchClassifier,
                finalLum,
                Opacity);

            var finalMaterial = new SolidColorBrush(
                finalColor)
                                .SetIdentity(
                finalIdentity);

            return(finalMaterial);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="this"></param>
        /// <param name="opacity"></param>
        /// <returns></returns>
        public static MaterialBrush WithOpacity(
            this MaterialBrush @this,
            double opacity)
        {
            @this.IsNotNull(nameof(@this));

            if (opacity.IsNotWithin((0d, 1d)))
            {
                throw new ArgumentOutOfRangeException(
                          nameof(opacity),
                          opacity,
                          "The opacity parameter must be between 0 and 1, inclusively.");
            }

            var color = @this
                        .Brush
                        .Color
                        .WithOpacity(
                opacity);

            var identity = new MaterialIdentity(
                @this.Identity.SwatchClassifier,
                @this.Identity.Luminosity,
                opacity);

            return(new MaterialBrush(color.ToSCB(), identity));

            //return MaterialBrush.Create(
            //  color,
            //  identity);
        }
Ejemplo n.º 3
0
        public static SolidColorBrush SetIdentity(
            [NotNull] this SolidColorBrush @this,
            [CanBeNull] MaterialIdentity materialIdentity)
        {
            @this.IsNotNull(nameof(@this));

            if ((@this.CanFreeze && @this.IsFrozen) || @this.IsSealed)
            {
                //@this.Changed += (s, args) =>
                //{

                //};
                var cloned = @this.Clone();

                cloned.SetValue(
                    MDH.IdentityProperty,
                    materialIdentity);

                cloned.Freeze();

                return(cloned);
            }
            else
            {
                //@this.Changed += (s, args) =>
                //{

                //};

                var existingIdentity = @this.GetIdentity();
                if (existingIdentity != null)
                {
                    if (!existingIdentity.Equals(materialIdentity))
                    {
                    }
                }
                @this.SetValue(
                    MDH.IdentityProperty,
                    materialIdentity);

                if (@this.CanFreeze)
                {
                    @this.Freeze();
                }

                return(@this);
            }
        }
Ejemplo n.º 4
0
 public static void SetIdentity(DependencyObject @this, MaterialIdentity value)
 {
     @this.Set(IdentityProperty, value);
 }