Plasma effect: Difference between revisions

Content added Content deleted
(added FreeBASIC)
(→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details)
Line 499: Line 499:
=={{header|Kotlin}}==
=={{header|Kotlin}}==
{{trans|Java}}
{{trans|Java}}
<lang scala>// version 1.1.1
<lang scala>// version 1.1.2


import java.awt.*
import java.awt.*
Line 509: Line 509:
private var hueShift = 0.0f
private var hueShift = 0.0f
private val img: BufferedImage
private val img: BufferedImage

init {
init {
val dim = Dimension(640, 640)
val dim = Dimension(640, 640)
Line 533: Line 533:
value += 4.0 // shift range from -4 .. 4 to 0 .. 8
value += 4.0 // shift range from -4 .. 4 to 0 .. 8
value /= 8.0 // bring range down to 0 .. 1
value /= 8.0 // bring range down to 0 .. 1
if (value < 0.0 || value > 1.0) throw RuntimeException("Hue value out of bounds")
if (value < 0.0 || value > 1.0) throw RuntimeException("Hue value out of bounds")
buffer[y][x] = value.toFloat()
buffer[y][x] = value.toFloat()
}
}