Exemple #1
0
 public static void ApplyTint(this ColorMatrix mat, ColorAlpha col)
 {
     mat.Matrix00 *= (float)col.R;
     mat.Matrix11 *= (float)col.G;
     mat.Matrix22 *= (float)col.B;
     mat.Matrix33 *= (float)col.A;
 }
 public SkinSubBaker(Wearable skin)
 {
     if (skin.Type != WearableType.Skin)
     {
         throw new ArgumentException(nameof(skin));
     }
     m_SkinColor           = GetSkinColor(skin);
     m_RosyComplexionColor = GetRosyComplexionColor(skin);
     m_LipPinknessColor    = GetLipPinknessColor(skin);
     m_LipstickColor       = GetLipstickColor(skin);
     m_BlushColor          = GetBlushColor(skin);
     m_OutershadowColor    = GetOuterShadowColor(skin);
     m_InnershadowColor    = GetInnerShadowColor(skin);
     m_EyelinerColor       = GetEyelinerColor(skin);
     m_NailpolishColor     = GetNailPolishColor(skin);
     m_Innershadow         = skin.GetParamValueOrDefault(709, 0);
     m_Outershadow         = skin.GetParamValueOrDefault(707, 0);
     skin.Textures.TryGetValue(AvatarTextureIndex.HeadBodypaint, out m_HeadTextureId);
     skin.Textures.TryGetValue(AvatarTextureIndex.UpperBodypaint, out m_UpperTextureId);
     skin.Textures.TryGetValue(AvatarTextureIndex.LowerBodypaint, out m_LowerTextureId);
     if (m_HeadTextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
     {
         m_HeadTextureId = UUID.Zero;
     }
     if (m_UpperTextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
     {
         m_UpperTextureId = UUID.Zero;
     }
     if (m_LowerTextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
     {
         m_LowerTextureId = UUID.Zero;
     }
 }
        private static ColorAlpha GetLipPinknessColor(Wearable skin)
        {
            double     value;
            ColorAlpha color = ColorAlpha.FromRgba(220, 115, 115, 0);

            /* Lip pinkness */
            if (skin.Params.TryGetValue(117, out value))
            {
                color.A = value.LimitRange(0, 1) * 0.5;
            }

            return(color);
        }
        private static ColorAlpha GetRosyComplexionColor(Wearable skin)
        {
            double     value;
            ColorAlpha color = ColorAlpha.FromRgba(198, 71, 71, 0);

            /* Rosy complextion */
            if (skin.Params.TryGetValue(116, out value))
            {
                color.A = value.LimitRange(0, 1);
            }

            return(color);
        }
        public HairSubBaker(Wearable hair)
        {
            if (hair.Type != WearableType.Hair)
            {
                throw new ArgumentException(nameof(hair));
            }

            hair.Textures.TryGetValue(AvatarTextureIndex.Hair, out m_HairTextureId);
            if (m_HairTextureId == AppearanceInfo.AvatarTextureData.DefaultAvatarTextureID)
            {
                m_HairTextureId = UUID.Zero;
            }

            m_HairColor = (ColorAlpha)GetHairColor(hair);
        }
        private static ColorAlpha GetEyelinerColor(Wearable skin)
        {
            double     value;
            ColorAlpha color = EyelinerColors[0];

            if (skin.Params.TryGetValue(714, out value))
            {
                color = CalcColor(value, EyelinerColors);
            }

            if (!skin.Params.TryGetValue(703, out value))
            {
                value = 0;
            }
            color.A *= value * 0.1;

            return(color);
        }
        private static ColorAlpha GetBlushColor(Wearable skin)
        {
            double     value;
            ColorAlpha color = BlushColors[0];

            if (skin.Params.TryGetValue(705, out value))
            {
                color = CalcColor(value, BlushColors);
            }

            if (!skin.Params.TryGetValue(711, out value))
            {
                value = 0;
            }
            color.A *= value * 0.3;

            return(color);
        }
        private static ColorAlpha GetLipstickColor(Wearable skin)
        {
            double value;

            /* Limp pinkness */
            if (!skin.Params.TryGetValue(700, out value))
            {
                value = 0.25;
            }
            ColorAlpha color = CalcColor(value, LipstickColors);

            if (!skin.Params.TryGetValue(701, out value))
            {
                value = 0;
            }
            color.A *= value * 0.2;

            return(color);
        }
Exemple #9
0
 public static Color ToDrawing(this ColorAlpha color)
 {
     return(Color.FromArgb(color.A_AsByte, color.R_AsByte, color.G_AsByte, color.B_AsByte));
 }
Exemple #10
0
 public static void DrawColorKeyed(this Graphics gfx, Rectangle bakeRectangle, Image baseBake, ColorAlpha color, double val)
 {
     using (var attrs = new ImageAttributes())
     {
         var mat = new ColorMatrix();
         mat.Matrix00 = 0;
         mat.Matrix11 = 0;
         mat.Matrix22 = 0;
         mat.Matrix33 = 0;
         mat.Matrix40 = (float)color.R;
         mat.Matrix41 = (float)color.G;
         mat.Matrix42 = (float)color.B;
         mat.Matrix43 = (float)color.A;
         int v = (int)(val * 255);
         attrs.SetColorMatrix(mat);
         attrs.SetColorKey(Color.FromArgb(0), Color.FromArgb(v, v, v));
         gfx.DrawImage(baseBake, bakeRectangle, 0, 0, baseBake.Width, baseBake.Height, GraphicsUnit.Pixel, attrs);
     }
 }
Exemple #11
0
 public static void DrawTinted(this Graphics gfx, Rectangle bakeRectangle, Image baseBake, ColorAlpha color)
 {
     using (var attrs = new ImageAttributes())
     {
         var mat = new ColorMatrix();
         mat.ApplyTint(color);
         attrs.SetColorMatrix(mat);
         gfx.DrawImage(baseBake, bakeRectangle, 0, 0, baseBake.Width, baseBake.Height, GraphicsUnit.Pixel, attrs);
     }
 }