CPMarkup
org.cosplay.CPMarkup
case class CPMarkup(fg: CPColor, bg: Option[CPColor], elements: Seq[CPMarkupElement]) extends Serializable
Markup specification that can be used to convert a sequence of characters to the sequence of pixels based on this specification.
Each specification has mandatory default foreground and optional background colors. It also has a list of markup elements (potentially empty) where each element has opening and closing tag and a function that takes a character and returns pixel.
Here's an example of defining the markup:
val markup = CPMarkup(
C_GREEN,
C_BLACK.?,
Seq(
CPMarkupElement("<$", "$>", _&&(C_RED, C_WHITE)),
CPMarkupElement("{#", "#}", _&&(C_BLUE, C_YELLOW)),
CPMarkupElement("(?", "?)", _&&(C_BLACK, C_WHITE))
)
)
Once defined this markup can be used to convert a string ito sequence of pixels and then create an image:
val pxs = markup.process("text <$ red on white (? black on white ?)$> {# blue on yellow #}")
val img = CPArrayImage(pxs, bgPx, align = -1) // Left-aligned image.
Value parameters
- bg
-
Default optional background color.
- elements
-
Markup elements. Can be empty.
- fg
-
Default foreground color.
Attributes
- See also
-
CPArrayImage.apply method for creating an image from the list of pixel representing text.
- Source
- CPMarkup.scala
- Graph
-
- Supertypes
-
trait Producttrait Equalstrait Serializableclass Objecttrait Matchableclass Any
Members list
In this article