本文整理汇总了Scala中scalafx.scene.paint.Color类的典型用法代码示例。如果您正苦于以下问题:Scala Color类的具体用法?Scala Color怎么用?Scala Color使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Color类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: ScalaFXHelloWorld
//设置package包名称以及导入依赖的类
package my.scalafx
import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.scene.Scene
import scalafx.scene.layout.BorderPane
import scalafx.scene.paint.Color
import scalafx.scene.web.WebView
object ScalaFXHelloWorld extends JFXApp {
val webView = new WebView()
webView.getEngine.loadContent(
"""
<audio controls #player src="http://www.largesound.com/ashborytour/sound/AshboryBYU.mp3" preload="none">
Your browser does not support the audio element.
</audio>
"""
)
stage = new PrimaryStage {
title = "ScalaFX Hello World"
scene = new Scene {
fill = Color.rgb(38, 38, 38)
content = new BorderPane {
center = webView
}
}
}
}
示例2: View
//设置package包名称以及导入依赖的类
package com.hombredequeso.robbierobot.Ui
import javafx.beans.property.SimpleBooleanProperty
import Vm.{RobotViewModel, ViewModel}
import scalafx.scene.paint.Color
import scalafx.scene.shape.{Circle, Rectangle, Shape}
import scalafx.Includes._
object View {
def getContent(
viewModel: ViewModel,
xWindowWidth: Int,
yWindowHeight: Int)
: List[Shape] = {
val robotView = createRobotView(viewModel.robot)
val gridView = createGridView(xWindowWidth,yWindowHeight, viewModel.grid)
gridView :+ robotView
}
private def createRobotView(vm: RobotViewModel) = {
new Circle {
centerX <== vm.xPos
centerY <== vm.yPos
radius = 50
}
}
private def createGridView(
totalX: Int, totalY: Int,
board: Vector[Vector[SimpleBooleanProperty]]
): List[Rectangle] = {
val xCount = board.length
val yCount = board(0).length
val xSize = totalX.toDouble / xCount.toDouble
val ySize = totalY.toDouble / yCount.toDouble
val all = for(
x <- 0 to xCount-1;
y <- 0 to yCount-1
) yield (x,y)
all.map(a => {
val (x1, y1):(Int, Int) = a
val rectX = (x1 * xSize)
val rectY = (y1 * ySize)
new Rectangle {
x = rectX
y = rectY
width = xSize
height = ySize
stroke = Color.Black
fill <== when(board(x1)(y1)) choose Color.Brown otherwise Color.White
}
}).toList
}
}
示例3: SetFormula
//设置package包名称以及导入依赖的类
package scalaExcel.model
import scalafx.scene.paint.Color
import scalaExcel.CellPos
sealed trait ModelMutations
case class SetFormula(pos : CellPos, f: String) extends ModelMutations
case class EmptyCell(pos : Traversable[CellPos]) extends ModelMutations
case class CopyCell(from : CellPos, to : CellPos) extends ModelMutations
case class CutCell(from : CellPos, to : CellPos) extends ModelMutations
case class SetColor(pos : Traversable[CellPos], c: Color) extends ModelMutations
case class SetBackground(pos : Traversable[CellPos], c: Color) extends ModelMutations
case class SetAlign(pos : Traversable[CellPos], align: Alignment) extends ModelMutations
case class SetFormat(pos : Traversable[CellPos], format: ValueFormat) extends ModelMutations
case class SortColumn(x: Int, asc: Boolean) extends ModelMutations
case object Redo extends ModelMutations
case object Undo extends ModelMutations
case object Refresh extends ModelMutations
case class SetSheet(values: Map[(Int,Int),String], styles: Map[(Int,Int), Styles]) extends ModelMutations
case class AddRows(count: Int, index: Int) extends ModelMutations
case class AddColumns(count: Int, index: Int) extends ModelMutations
case class RemoveRows(count: Int, index: Int) extends ModelMutations
case class RemoveColumns(count: Int, index: Int) extends ModelMutations
case class ReorderColumns(permutations: Map[Int, Int]) extends ModelMutations
case object ClearHistory extends ModelMutations