Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Colour-bars-Display/Scala/colour-bars-display-1.scala
Normal file
16
Task/Colour-bars-Display/Scala/colour-bars-display-1.scala
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import java.awt.Color
|
||||
import scala.swing._
|
||||
|
||||
class ColorBars extends Component {
|
||||
override def paintComponent(g:Graphics2D)={
|
||||
val colors=List(Color.BLACK, Color.RED, Color.GREEN, Color.BLUE, Color.MAGENTA, Color.CYAN, Color.YELLOW, Color.WHITE)
|
||||
val colCount=colors.size
|
||||
val deltaX=size.width.toDouble/colCount
|
||||
for(x <- 0 until colCount){
|
||||
val startX=(deltaX*x).toInt
|
||||
val endX=(deltaX*(x+1)).toInt
|
||||
g.setColor(colors(x))
|
||||
g.fillRect(startX, 0, endX-startX, size.height)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
new MainFrame(){
|
||||
title="Color bars"
|
||||
visible=true
|
||||
preferredSize=new Dimension(640, 320)
|
||||
contents=new ColorBars()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue