graphics-2/lab_2/src/main/kotlin/TransferHelper.kt

18 lines
398 B
Kotlin
Raw Normal View History

2025-05-01 18:37:06 +03:00
package org.exampl
import java.awt.Color
object TransferHelper {
private var min = -3000
private var max = 16000
fun setTF(newMin: Int, newMax: Int) {
min = newMin
max = newMax
}
fun transferFunction(value: Short): Color {
val newVal = Math.max(0, Math.min((value - min) * 255 / (max - min), 255))
return Color(newVal, newVal, newVal)
}
2025-05-04 16:26:52 +03:00
}