public void Update() { if (!MultiplierController.isActiveAndEnabled) { return; } if (Config.SmoothTransition) { if (CurrentMultiplier == 1) { BG.color = HSBColor.Lerp(HSBColor.FromColor(Config.One), HSBColor.FromColor(Config.Two), FG.fillAmount).ToColor().ColorWithAlpha(0.25f); FG.color = HSBColor.Lerp(HSBColor.FromColor(Config.One), HSBColor.FromColor(Config.Two), FG.fillAmount).ToColor(); } else if (CurrentMultiplier == 2) { BG.color = HSBColor.Lerp(HSBColor.FromColor(Config.Two), HSBColor.FromColor(Config.Four), FG.fillAmount).ToColor().ColorWithAlpha(0.25f); FG.color = HSBColor.Lerp(HSBColor.FromColor(Config.Two), HSBColor.FromColor(Config.Four), FG.fillAmount).ToColor(); } else if (CurrentMultiplier == 4) { BG.color = HSBColor.Lerp(HSBColor.FromColor(Config.Four), HSBColor.FromColor(Config.Eight), FG.fillAmount).ToColor().ColorWithAlpha(0.25f); FG.color = HSBColor.Lerp(HSBColor.FromColor(Config.Four), HSBColor.FromColor(Config.Eight), FG.fillAmount).ToColor(); } } if (CurrentMultiplier == 8 && Config.RainbowOnMaxMultiplier) { BG.color = HSBColor.ToColor(new HSBColor(Mathf.PingPong(Time.time * 0.5f, 1), 1, 1)); } }
private IEnumerator PrepareColorsForEnergyType(GameplayModifiers.EnergyType type) { yield return(new WaitUntil(() => EnergyPanel != null)); if (type == GameplayModifiers.EnergyType.Battery) { List <Image> batterySegments = EnergyPanel.GetField <List <Image>, GameEnergyUIPanel>("_batteryLifeSegments"); batterySegments[0].color = Config.Low; batterySegments[1].color = HSBColor.Lerp(HSBColor.FromColor(Config.Low), HSBColor.FromColor(Config.Mid), 0.34f).ToColor(); batterySegments[2].color = HSBColor.Lerp(HSBColor.FromColor(Config.Mid), HSBColor.FromColor(Config.High), 0.66f).ToColor(); batterySegments[3].color = Config.High; yield break; } else if (type == GameplayModifiers.EnergyType.Bar) { if (Modifiers.instaFail) { EnergyBar = EnergyPanel.transform.Find("BatteryLifeSegment(Clone)").GetComponent <ImageView>(); EnergyBar.color = Config.High; } else { EnergyBar = EnergyPanel.transform.Find("EnergyBarWrapper/EnergyBar").GetComponent <ImageView>(); EnergyBar.color = Config.Mid; } } EnergyCounter.gameEnergyDidChangeEvent += HandleEnergyDidChange; }
// Update is called once per frame public override void Update() { if (Player != null) { if (HealthBar != null) { HealthBar.fillAmount = Player.Status.DurabilityInPercent * 0.01f; HealthBar.color = HSBColor.ToColor(HSBColor.Lerp(Color.red, Color.green, HealthBar.fillAmount)); } if (DamageIndicator != null) { DamageIndicator.color = new Color(DamageIndicator.color.r, DamageIndicator.color.g, DamageIndicator.color.b, Mathf.Clamp01(1 - (Player.Status.DurabilityInPercent * 0.01f))); } if (InventorySlotBar != null) { InventorySlotObject _slot = Player.Inventory.GetSlotByIndex(0); if (_slot != null) { InventorySlotBar.fillAmount = _slot.AmountInPercent * 0.01f; InventorySlotBar.color = HSBColor.ToColor(HSBColor.Lerp(Color.red, Color.green, InventorySlotBar.fillAmount)); } } } DisplayEntityInfos(); }
void OnDrawGizmos() { if (DrawHistory) { float angleDelta = (AngleRange * 2.0f) / (float)NumIncrements; for (int i = 0; i < m_history.Count; i++) { float startAngle = -AngleRange - m_history[i].riderAngle; float endAngle = AngleRange - m_history[i].riderAngle; for (int increment = 0; increment < NumIncrements; ++increment) { float angle = startAngle + (angleDelta * (float)increment); Quaternion rotation = Quaternion.Euler(new Vector3(0.0f, angle, 0.0f)); Vector3 direction = rotation * Vector3.forward; HSBColor lineColor = HSBColor.Lerp(new HSBColor(Color.green), new HSBColor(Color.red), m_history[i].scores[increment]); Gizmos.color = lineColor.ToColor(); Gizmos.DrawLine(m_history[i].position, m_history[i].position + direction * (i == (HistoryFocus % m_history.Count)? RaycastRange : 0.01f)); if (increment == m_history[i].winner && i == (HistoryFocus % m_history.Count)) { Gizmos.color = Color.magenta; Gizmos.DrawLine(m_history[i].position, m_history[i].position + direction * 1.3f); Debug.Log("Angle: " + angle); } } } } }
public void UpdateCustomerNumber() { customerNumberLabel.text = zoneModel.customers.Count.ToString(); float transparency = .3f; HSBColor red = new HSBColor(new Color(1f, 0f, 0f, transparency)); HSBColor green = new HSBColor(new Color(0f, 1f, 0f, transparency)); icon.color = HSBColor.ToColor(HSBColor.Lerp(green, red, (float)zoneModel.customers.Count / zoneModel.maxQueue)); progressIndicator.color = icon.color; progressIndicator.fillAmount = 0f; //icon.color = Color.Lerp(Color.green, Color.red, (float) zone.customers.Count / zone.maxQueue ); }
public Color LerpColor(Color endColor, float alpha) { HSBColor endColorHSB = HSBColor.FromColor(endColor); endColorHSB.s = 1.0f; endColorHSB.h = colors[activeColor]; HSBColor newColor = HSBColor.FromColor(endColor); newColor.b -= .6f; newColor.s = 1.0f; newColor.h = colors[activeColor]; return(HSBColor.Lerp(newColor, endColorHSB, alpha).ToColor()); }
public override void Apply() { //var f = MathHelper.SmoothStep(0, 1, (float)durationCurrent / StepCountTotal); var f = DurationCurrent / Duration; hsbValueCurrent = HSBColor.Lerp(hsbValueBegin, hsbValueEnd, f); ValueCurrent = hsbValueCurrent.ToColor(); foreach (var material in Materials) { material.color = ValueCurrent; } }
// Update is called once per frame public override void Update() { base.Update(); if (Entity == null) { return; } if (HealthBar != null) { HealthBar.fillAmount = Entity.Status.DurabilityInPercent * 0.01f; HealthBar.color = HSBColor.ToColor(HSBColor.Lerp(Color.red, Color.green, HealthBar.fillAmount)); } }
public void SetColors(Color def, Color?selected = null, Color?abandoned = null) { Color s = (selected == null) ? Color.red : (Color)selected; Color a = (abandoned == null) ? HSBColor.Lerp(HSBColor.FromColor(def), HSBColor.Black, 0.67f).ToColor() : (Color)abandoned; AddColor("default", def); AddColor("selected", s); AddColor("abandoned", a); SetColor("default"); }
private void setColor(float value, float topThreshold, float botThreshold, float topRange, float botRange) { var color = lowColor; if (value > topThreshold) { color = HSBColor.Lerp(lowHSB, hightHSB, (value - topThreshold) / topRange).ToColor(); //color = Color.Lerp(lowColor, hightColor, (value-topThreshold)/topRange); } else if (value < botThreshold) { color = HSBColor.Lerp(lowHSB, hightHSB, (value - botThreshold) / botRange).ToColor(); //color = Color.Lerp(lowColor, hightColor, (value-botThreshold)/botRange); } GL.Color(color); }
private void Update() { if (!canBeUsed) { return; } // The performance impact of this is unmeasured but probably negligable. I do want to find a way to do this without using Update() if (Config.UseFadeDisplayType) { BarComponents[0].color = HSBColor.Lerp( HSBColor.FromColor(Config.StartColor), HSBColor.FromColor(Config.EndColor), SyncController.songTime / SyncController.songLength).ToColor(); } }
void FixedUpdate() { float temperatureDifference = ambientTemperature - CurrentTemperature; CurrentTemperature += temperatureDifference * temperatureDissapationRate * Time.fixedDeltaTime; if (temperatureReadoutText != null) { temperatureReadoutText.color = HSBColor.Lerp(HSBColor.FromColor(Color.green), HSBColor.FromColor(Color.red), GetSafeness()).ToColor(); string text = moduleName + ": " + CurrentTemperature.ToString("0") + "c"; if (GetSafeness() >= 1f) { text += "!!!"; } temperatureReadoutText.text = text; } }
private void HandleEnergyDidChange(float energy) { if (energy == 0.5f) { EnergyBar.color = Config.Mid; } else if (energy > 0.5f) { EnergyBar.color = HSBColor.Lerp( HSBColor.FromColor(Config.Mid), HSBColor.FromColor(Config.High), (energy - 0.5f) * 2).ToColor(); } else if (energy < 0.5f) { EnergyBar.color = HSBColor.Lerp( HSBColor.FromColor(Config.Low), HSBColor.FromColor(Config.Mid), energy * 2).ToColor(); } }
public void Update() { if (lerping) { timer += Time.deltaTime; if (timer >= .49f) { timer = 0.0f; lerping = false; } else { float alpha = timer / .49f; HSBColor endColor = GameManager.Instance.ActiveColorHSB; endColor.b = .5f; HSBColor beginColor = HSBColor.FromColor(this.prevColor); beginColor.b = .5f; spriteRenderer.color = HSBColor.Lerp(beginColor, endColor, alpha).ToColor(); } } }
void OnDrawGizmos() { return; HSBColor red = new HSBColor(Color.red); HSBColor green = new HSBColor(Color.green); for (int y = 0; y < Height; ++y) { for (int x = 0; x < Width; ++x) { float xPos = -m_halfWidth + (CellSize / 2.0f) + x * CellSize; float yPos = (CellSize / 2.0f) + y * CellSize; Color cellColor = HSBColor.Lerp(green, red, Mathf.Clamp01(m_heat[x, y])).ToColor(); cellColor.a = 1.0f; Gizmos.color = cellColor; Gizmos.DrawCube(new Vector3(transform.position.x + xPos, transform.position.y, transform.position.z + yPos), new Vector3(CellSize, 0.001f, CellSize)); } } }
IEnumerator FlashScoreBar(Image scoreBar) { Color darkerColor = scoreBar.color; darkerColor.r *= 0.5f; darkerColor.g *= 0.5f; darkerColor.b *= 0.5f; HSBColor darkColor = HSBColor.FromColor(darkerColor); HSBColor flashColor = HSBColor.FromColor(Color.yellow); HSBColor currentColor = darkColor; bool pingPong = true; float time = 0.0f; while (true) { float elapsedTime = Time.deltaTime * 2.0f; if (pingPong) { time += elapsedTime; } else { time -= elapsedTime; } time = Mathf.Clamp01(time); if (time == 0.0f) { pingPong = true; } else if (time == 1.0f) { pingPong = false; } currentColor = HSBColor.Lerp(darkColor, flashColor, time); scoreBar.color = currentColor.ToColor(); yield return(new WaitForEndOfFrame()); } }
IEnumerator ResetScoreBarColor(Image scoreBar, Color originalColor) { float time = 0.0f; HSBColor startColor = HSBColor.FromColor(scoreBar.color); HSBColor endColor = HSBColor.FromColor(originalColor); HSBColor currentColor = startColor; while (true) { time += Time.deltaTime * 2.0f; time = Mathf.Clamp01(time); currentColor = HSBColor.Lerp(startColor, endColor, time); scoreBar.color = currentColor.ToColor(); if (time >= 0.90f) { scoreBar.color = originalColor; break; } yield return(new WaitForEndOfFrame()); } yield return(null); }
void lightColor() { if (flip || nLeft == 0 || nRight == 0) { sat = 0; } else { sat = 1 - anis; } HSBColor col2 = new HSBColor(hue, sat, 1, 0); HSBColor col1 = HSBColor.FromColor(lightC.color); //Color col = (new HSBColor(hue, sat, 1, 0)).ToColor(); //Color lerpedColor = Color.Lerp(lightC.color, col, Time.deltaTime); Color col = (HSBColor.Lerp(col1, col2, Time.deltaTime)).ToColor(); lightC.color = col; if (flip) { if (hue == 0) { hue = 120f / 360f; } else { hue = 0; } flip = !flip; col1 = col2; col2 = new HSBColor(hue, sat, 1, 0); //Color col = (new HSBColor(hue, sat, 1, 0)).ToColor(); //Color lerpedColor = Color.Lerp(lightC.color, col, Time.deltaTime); col = (HSBColor.Lerp(col1, col2, Time.deltaTime)).ToColor(); lightC.color = col; } }
// These functions are accessible from any Color struct. // (Put this script in the Plugins folder for Javascript access) public static UnityEngine.Color Slerp(this UnityEngine.Color a, UnityEngine.Color b, float t) { return((HSBColor.Lerp(HSBColor.FromColor(a), HSBColor.FromColor(b), t)).ToColor()); }
public float UpdateSteering(float angleToGlobalTarget, float riderAngle) { if (Input.GetKeyDown(KeyCode.PageUp)) { HistoryFocus++; } if (Input.GetKeyDown(KeyCode.PageDown)) { HistoryFocus--; } if (GameTime.Instance.Paused == true) { return(0.0f); } float angleDelta = (AngleRange * 2.0f) / (float)NumIncrements; float startAngle = -AngleRange + riderAngle; float endAngle = AngleRange + riderAngle; // Debug.Log("Angle: " + angleToGlobalTarget); bool previousBlocked = false; float[] scores = new float[NumIncrements]; for (int increment = 0; increment < NumIncrements; ++increment) { float angle = startAngle + (angleDelta * (float)increment); Quaternion rotation = Quaternion.Euler(new Vector3(0.0f, angle, 0.0f)); Vector3 direction = rotation * Vector3.forward; Vector3 targetVec = Quaternion.Euler(new Vector3(0.0f, angleToGlobalTarget, 0.0f)) * Vector3.forward; scores[increment] = 1.0f - Mathf.Pow(Vector3.Dot(targetVec, direction), 4.0f); if (previousBlocked) { scores[increment] += 0.3f; previousBlocked = false; } //TODO: Check out of bounds: // Get offsetX at transform.position.y + direction.y and check to see if further out RaycastHit hitInfo; if (Physics.Raycast(transform.position, direction, out hitInfo, RaycastRange, CollisionLayers.value)) { // Increase the heat from a hit proportional to distance of the hit, so closer obstacles are more dangerous scores[increment] = 1.0f - Mathf.Pow(hitInfo.distance / RaycastRange, 2.0f); previousBlocked = true; if (increment > 0) { scores[increment - 1] += 0.3f; } } } const int kernelSize = 5; const int halfKernelSize = kernelSize / 2; float[] blurredScores = new float[NumIncrements]; // Blur score values for (int increment = 0; increment < NumIncrements; ++increment) { float total = 0.0f; float contributions = 0; for (int otherIncrement = Mathf.Max(increment - halfKernelSize, 0); otherIncrement < Mathf.Min(increment + halfKernelSize, NumIncrements); ++otherIncrement) { total += scores[otherIncrement]; contributions++; } blurredScores[increment] = total / (float)contributions; } int maxIndex = -1; float minScore = 100.0f; for (int increment = 0; increment < NumIncrements; ++increment) { float angle = startAngle + (angleDelta * (float)increment); Quaternion rotation = Quaternion.Euler(new Vector3(0.0f, angle, 0.0f)); Vector3 direction = rotation * Vector3.forward; HSBColor lineColor = HSBColor.Lerp(new HSBColor(Color.green), new HSBColor(Color.red), blurredScores[increment]); //Debug.DrawLine(transform.position, transform.position + direction * RaycastRange, lineColor.ToColor()); if (blurredScores[increment] < minScore) { minScore = blurredScores[increment]; maxIndex = increment; } } float winnerAngle = startAngle + (angleDelta * (float)maxIndex) - riderAngle; Quaternion winnerRotation = Quaternion.Euler(new Vector3(0.0f, winnerAngle, 0.0f)); Vector3 winnerDirection = winnerRotation * Vector3.forward; // Debug.DrawLine(transform.position, transform.position + winnerDirection * 1.3f, Color.magenta); HistoricalSteeringData newData = new HistoricalSteeringData(); newData.position = transform.position; newData.scores = blurredScores; newData.winner = maxIndex; newData.riderAngle = riderAngle; m_history.Insert(0, newData); if (m_history.Count > 10) { m_history.RemoveAt(m_history.Count - 1); } return(winnerDirection.x); }
// These functions are accessible from any Color struct. // (Put this script in the Plugins folder for Javascript access) public static Color Slerp(this Color a, Color b, float t) { return((HSBColor.Lerp(HSBColor.FromColor(a), HSBColor.FromColor(b), t)).ToColor()); }
public void Update() { HealthImage.fillAmount = m_rider.Health; HealthImage.color = HSBColor.Lerp(new HSBColor(Color.red), new HSBColor(Color.green), m_rider.Health).ToColor(); }
public static HSBColor RandomBetween(HSBColor a, HSBColor b) { return(HSBColor.Lerp(a, b, Random.value)); }
// color // public static Color HSBLerp(this Color _from, Color _to, float _f) { return((HSBColor.Lerp(HSBColor.FromColor(_from), HSBColor.FromColor(_to), _f)).ToColor()); }