Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
41
Task/Pinstripe-Display/Kotlin/pinstripe-display.kotlin
Normal file
41
Task/Pinstripe-Display/Kotlin/pinstripe-display.kotlin
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// version 1.1.0
|
||||
|
||||
import java.awt.*
|
||||
import javax.swing.*
|
||||
|
||||
class ColourPinstripeDisplay(): JPanel() {
|
||||
private companion object {
|
||||
val palette = arrayOf(Color.white, Color.black)
|
||||
}
|
||||
|
||||
private val bands = 4
|
||||
|
||||
init {
|
||||
preferredSize = Dimension(900, 600)
|
||||
}
|
||||
|
||||
protected override fun paintComponent(g: Graphics) {
|
||||
super.paintComponent(g)
|
||||
for (b in 1..bands) {
|
||||
var colIndex = 0
|
||||
val h = height / bands
|
||||
for (x in 0 until width step b) {
|
||||
g.color = palette[colIndex % palette.size]
|
||||
g.fillRect(x, (b - 1) * h, b, h)
|
||||
colIndex++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
SwingUtilities.invokeLater {
|
||||
val f = JFrame()
|
||||
f.defaultCloseOperation = JFrame.EXIT_ON_CLOSE
|
||||
f.title = "PinstripeDisplay"
|
||||
f.add(ColourPinstripeDisplay(), BorderLayout.CENTER)
|
||||
f.pack()
|
||||
f.setLocationRelativeTo(null)
|
||||
f.setVisible(true)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue