Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Colour-bars-Display/Kotlin/colour-bars-display.kotlin
Normal file
25
Task/Colour-bars-Display/Kotlin/colour-bars-display.kotlin
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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)
|
||||
isVisible = 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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue