Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend: SpecialColor translation #2854

Merged
merged 23 commits into from
Nov 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use simpletimemark
Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com>
  • Loading branch information
j10a1n15 committed Oct 28, 2024
commit 6936badd510135df6a7e0dc5640def6d274a64e6
6 changes: 3 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/utils/SpecialColor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ object SpecialColor {
private const val RADIX = 10
private const val MIN_CHROMA_SECS = 1
private const val MAX_CHROMA_SECS = 60
private var startTime: Long = -1
private var startTime = SimpleTimeMark.farPast()

@Deprecated("", ReplaceWith("this.toChromaColor()"))
fun specialToChromaRGB(special: String): Int {
if (startTime < 0) startTime = System.currentTimeMillis()
if (startTime.isFarPast()) startTime = SimpleTimeMark.now()

val (b, g, r, a, chroma) = decompose(special)
val (hue, sat, bri) = Color.RGBtoHSB(r, g, b, null)

val adjustedHue = if (chroma > 0) (hue + ((System.currentTimeMillis() - startTime) / 1000f / chromaSpeed(chroma) % 1)).let {
val adjustedHue = if (chroma > 0) (hue + (startTime.passedSince().inWholeMilliseconds / 1000f / chromaSpeed(chroma) % 1)).let {
if (it < 0) it + 1f else it
} else hue

Expand Down
Loading