CPStyledString

org.cosplay.CPStyledString
See theCPStyledString companion object

Builder for a styled string rendered using system font.

This utility class provides a builder pattern to built styled (colored) strings that are rendered using a system font. Once styled string is built it can be rendered via CPCanvas.drawStyledString method.

Here's an example of using styled string together with array image to quickly create an image with a styled textual content:

import CPStyledString.styleStr

val lblImg = new CPArrayImage(
   styleStr("[SPACE]", C_WHITE) ++ styleStr("Play|Pause ", C_GREEN) ++
   styleStr("[R]", C_WHITE) ++ styleStr("Rewind ", C_GREEN) ++
   styleStr("[Q]", C_WHITE) ++ styleStr("Quit ", C_GREEN) ++
   styleStr("[CTRL-L]", C_WHITE) ++ styleStr("Log ", C_GREEN) ++
   styleStr("[CTRL-Q]", C_WHITE) ++ styleStr("FPS Overlay", C_GREEN)
).trimBg()

Attributes

See also:
Example:

See CPFontsExample source code for an example of font functionality.

Companion:
object
Source:
CPStyledString.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Constructors

def this(s: String, fgColor: CPColor, bgColor: CPColor)

Creates styled string.

Creates styled string.

Attributes

bgColor

Background color.

fgColor

Foreground color.

s

String.

Source:
CPStyledString.scala
def this(s: String, fgColor: CPColor)

Creates styled string with no background.

Creates styled string with no background.

Attributes

fgColor

Foreground color.

s

String.

Source:
CPStyledString.scala

Concrete methods

def bg(bg: Option[CPColor]): CPStyledString

Sets current background color.

Sets current background color.

Attributes

bg

Background color to set. Use None to remove background color.

Source:
CPStyledString.scala

Sets current background color.

Sets current background color.

Attributes

bg

Background color to set.

Source:
CPStyledString.scala
def build(): Seq[CPPixel]

Finalizes this styled string and renders it into sequence of pixels.

Finalizes this styled string and renders it into sequence of pixels.

Attributes

Source:
CPStyledString.scala

Clears this styled string.

Clears this styled string.

Attributes

Source:
CPStyledString.scala

Sets current foreground color.

Sets current foreground color.

Attributes

fg

Foreground color to set.

Source:
CPStyledString.scala
def fgbg(fg: CPColor, bg: Option[CPColor]): CPStyledString

Sets current foreground and background colors.

Sets current foreground and background colors.

Attributes

bg

Background color to set. Use None to remove background color.

fg

Foreground color to set.

Source:
CPStyledString.scala

Sets current foreground and background colors.

Sets current foreground and background colors.

Attributes

bg

Background color to set.

fg

Foreground color to set.

Source:
CPStyledString.scala
def str(obj: Any): CPStyledString

Adds given object string representation to this style string using current foreground and background colors.

Adds given object string representation to this style string using current foreground and background colors.

Attributes

obj

Object to add.

Source:
CPStyledString.scala