Lerp() public static method

public static Lerp ( Color a, Color b, float t ) : Color
a Color
b Color
t float
return Color
 // Start is called before the first frame update
 void Start()
 {
     if (!_progressStorageService.HasSaves())
     {
         ContinueButton.interactable = false;
         ContinueText.color          = Color.Lerp(ContinueText.color, new Color(0, 0, 0, 0), 0.5f);
         IconImage.color             = Color.Lerp(IconImage.color, new Color(0, 0, 0, 0), 0.5f);
         _progressStorageService.Destroy();
     }
 }
Ejemplo n.º 2
0
    void newAgent()
    {
        AgentPosition = new Vector3(AgentX, AgentY, AgentZ);
        float currentDistance3d = Vector3.Distance(TargetPosition, AgentPosition);
        float t = currentDistance3d / beginDistance3d;

        Agent = Instantiate(Prefab, AgentPosition, rotation);
        Agent.GetComponent <MeshRenderer>().material.color = Color.Lerp(Color.red, Color.green, t);
        cellCount++;
        Agent.transform.SetParent(paths[runTimes].transform);
    }
Ejemplo n.º 3
0
        bool UpdateSkinColor([NotNull] MutationTracker tracker, bool force = false)
        {
            if (GComp == null || InitialGraphics == null)
            {
                return(false);
            }

            var colorationAspect = tracker.Pawn.GetAspectTracker()?.GetAspect <Aspects.ColorationAspect>();

            if (colorationAspect != null && colorationAspect.IsFullOverride)
            {
                var color = colorationAspect.ColorSet.skinColor;
                if (color.HasValue)
                {
                    Pawn.story.hairColor = color.Value;
                    return(true);
                }
            }

            var highestInfluence = Pawn.GetHighestInfluence();
            var curMorph         = Pawn.def.GetMorphOfRace();

            if (highestInfluence == null)
            {
                if (Pawn.story.SkinColor == InitialGraphics.SkinColor && !force)
                {
                    return(false); // If there is not influence or if the highest influence is that of their current race do nothing.
                }
                else
                {
                    GComp.ColorChannels["skin"].first = InitialGraphics.SkinColor;
                    return(true);
                }
            }


            float lerpVal    = tracker.GetDirectNormalizedInfluence(highestInfluence);
            var   baseColor  = curMorph?.GetSkinColorOverride(tracker.Pawn) ?? InitialGraphics.SkinColor;
            var   morphColor = highestInfluence.GetSkinColorOverride(tracker.Pawn) ?? InitialGraphics.SkinColor;

            if (!force && baseColor == morphColor)
            {
                return(false); // If they're the same color don't do anything.
            }

            var col = Color.Lerp(baseColor, morphColor, Mathf.Sqrt(lerpVal)); // Blend the 2 by the normalized colors.

            GComp.ColorChannels["skin"].first = col;

            return(true);
        }
Ejemplo n.º 4
0
    private void ProcessTexture(Texture2D texture, string outputPath, bool compress)
    {
        if (thumbnailBackgroundTexture)
        {
            var texturePixels    = texture.GetPixels();
            var backgroundPixels = thumbnailBackgroundTexture.GetPixels();
            for (var i = 0; i < texturePixels.Length; i++)
            {
                texturePixels[i] = Color.Lerp(backgroundPixels[i], texturePixels[i], texturePixels[i].a);
            }
            texture.SetPixels(texturePixels);
        }

        if (thumbnailForegroundTexture)
        {
            var texturePixels    = texture.GetPixels();
            var foregroundPixels = thumbnailForegroundTexture.GetPixels();
            for (var i = 0; i < texturePixels.Length; i++)
            {
                texturePixels[i] = Color.Lerp(texturePixels[i], foregroundPixels[i], foregroundPixels[i].a);
            }
            texture.SetPixels(texturePixels);
        }

        if (compress)
        {
            var quantize = new WuQuantizer();
            var bitmap   = new Bitmap(128, 128);
            var index    = 0;
            foreach (var pixel in texture.GetPixels())
            {
                var x = index % 128;
                var y = 127 - index / 128;
                bitmap.SetPixel(x, y, System.Drawing.Color.FromArgb(
                                    Mathf.CeilToInt(Mathf.Clamp(pixel.a * 255, 0, 255)),
                                    Mathf.CeilToInt(Mathf.Clamp(pixel.r * 255, 0, 255)),
                                    Mathf.CeilToInt(Mathf.Clamp(pixel.g * 255, 0, 255)),
                                    Mathf.CeilToInt(Mathf.Clamp(pixel.b * 255, 0, 255))
                                    ));
                index++;
            }

            var image = quantize.QuantizeImage(bitmap);
            image.Save(outputPath);
        }
        else
        {
            File.WriteAllBytes(outputPath, texture.EncodeToPNG());
        }
    }
Ejemplo n.º 5
0
    internal void UpdateObservedState()
    {
        if (Node.ObservedState == GlobeNodeObservedState.Visited)
        {
            gameObject.SetActive(true);

            if (!OtherRegion)
            {
                Icon.color = Color.white;
            }
            else
            {
                Icon.color = Color.cyan;
            }

            foreach (var nextNode in NextNodes)
            {
                if (nextNode.Node.ObservedState == GlobeNodeObservedState.Hidden)
                {
                    nextNode.gameObject.SetActive(true);
                    if (!nextNode.OtherRegion)
                    {
                        nextNode.Icon.color = Color.grey;
                    }
                    else
                    {
                        nextNode.Icon.color = Color.Lerp(Color.cyan, Color.gray, 0.5f);
                    }
                }
                else
                {
                    nextNode.gameObject.SetActive(true);

                    if (!nextNode.OtherRegion)
                    {
                        nextNode.Icon.color = Color.white;
                    }
                    else
                    {
                        nextNode.Icon.color = Color.cyan;
                    }
                }

                // Визуализируем коннекторы
                foreach (var connector in Connectors)
                {
                    connector.gameObject.SetActive(false);

                    if (connector.gameObject1 == gameObject || connector.gameObject2 == gameObject)
                    {
                        connector.gameObject.SetActive(true);
                    }
                }
            }
        }
        else
        {
            gameObject.SetActive(false);
            foreach (var nextNode in NextNodes)
            {
                if (nextNode.Node.ObservedState == GlobeNodeObservedState.Visited)
                {
                    gameObject.SetActive(true);

                    if (!OtherRegion)
                    {
                        Icon.color = Color.grey;
                    }
                    else
                    {
                        Icon.color = Color.Lerp(Color.cyan, Color.gray, 0.5f);
                    }

                    // Визуализируем коннекторы
                    foreach (var connector in Connectors)
                    {
                        connector.gameObject.SetActive(false);

                        if (connector.gameObject1 == gameObject || connector.gameObject2 == gameObject)
                        {
                            connector.gameObject.SetActive(true);
                        }
                    }
                }
            }
        }
    }