Colour bars/Display: Difference between revisions
Content added Content deleted
m (→{{header|FreeBASIC}}: removed inner For-Next (printed text 5 times)) |
(Added Kotlin) |
||
Line 756: | Line 756: | ||
} |
} |
||
</lang> |
</lang> |
||
=={{header|Kotlin}}== |
|||
{{trans|Java}} |
|||
<lang scala>// version 1.0.6 |
|||
import java.awt.Color |
|||
import java.awt.Graphics |
|||
import javax.swing.JFrame |
|||
class ColorFrame(width: Int, height: Int): JFrame() { |
|||
init { |
|||
defaultCloseOperation = EXIT_ON_CLOSE |
|||
setSize(width, height) |
|||
setVisible(true) |
|||
} |
|||
override fun paint(g: Graphics) { |
|||
val colors = listOf(Color.black, Color.red, Color.green, Color.blue, |
|||
Color.pink, Color.cyan, Color.yellow, Color.white) |
|||
val size = colors.size |
|||
for (i in 0 until size) { |
|||
g.color = colors[i] |
|||
g.fillRect(width / size * i, 0, width / size, height) |
|||
} |
|||
} |
|||
} |
|||
fun main(args: Array<String>) { |
|||
ColorFrame(400, 400) |
|||
}</lang> |
|||
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
=={{header|Mathematica}} / {{header|Wolfram Language}}== |