Greyscale bars/Display: Difference between revisions
Content deleted Content added
Added Kotlin |
→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details |
||
Line 692:
=={{header|Kotlin}}==
{{trans|Java}}
<lang scala>// version 1.
import
import java.awt.
import javax.swing.JFrame
class GreyBars
private val w: Int
private val h: Int
Line 706 ⟶ 707:
setSize(w, h)
defaultCloseOperation = JFrame.EXIT_ON_CLOSE
}
Line 723 ⟶ 724:
colorGap *= -1.0
}
val ystart = columnHeight * run
var xstart = 0
for (i in 0 until columnCount) {
val iColor = Math.round(colorComp).toInt()
val nextColor = Color(iColor, iColor, iColor)
g.color = nextColor
g.fillRect(xstart, ystart, columnWidth, columnHeight)
xstart += columnWidth
colorComp += colorGap
|