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,
       Option(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.

See also:

CPArrayImage.apply method for creating an image from the list of pixel representing text.

Source:
CPMarkup.scala
trait Product
trait Equals
trait Serializable
class Object
trait Matchable
class Any

Value members

Constructors

def this(fg: CPColor, bg: Option[CPColor], elms: List[(String, String, Char => CPPixel)])

Creates new markup spec with given parameters.

Creates new markup spec with given parameters.

Value parameters:
bg

Default optional background color.

elms

Markup elements as list of tuples. Can be empty.

fg

Default foreground color.

Source:
CPMarkup.scala
def this(fg: CPColor, bg: Option[CPColor], openTag: String, closeTag: String, skin: Char => CPPixel)

Creates new markup spec with a single markup element.

Creates new markup spec with a single markup element.

Value parameters:
bg

Default optional background color.

closeTag

Closing tag.

fg

Default foreground color.

openTag

Open tag.

skin

Character to pixel converter.

Source:
CPMarkup.scala

Concrete methods

def process(in: String): List[CPPixel]

Converts sequence of characters into list of pixels based on this markup. See CPArrayImage.apply method for a convenient way of creating an image from the list of pixel representing text.

Converts sequence of characters into list of pixels based on this markup. See CPArrayImage.apply method for a convenient way of creating an image from the list of pixel representing text.

Value parameters:
in

Input sequence of characters.

See also:

CPArrayImage.apply method for creating an image from the list of pixel representing text.

Source:
CPMarkup.scala

Inherited methods

def productElementNames: Iterator[String]
Inherited from:
Product
def productIterator: Iterator[Any]
Inherited from:
Product