Interface Canvas


  • public interface Canvas
    A drawing surface clipped to a section's bounds. Coordinates are local with (0,0) at the section's top-left; out-of-range writes are silently discarded, and writes mutate the back buffer without emitting escape codes.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Rect bounds()  
      void clear()
      Fills the entire canvas with spaces in the default style.
      Canvas clip​(Rect sub)
      Returns a further-clipped sub-canvas whose origin is the given rectangle's top-left.
      void fill​(Rect area, char c, Style style)
      Fills a local rectangle with a character and style.
      int height()  
      void put​(int x, int y, char c)
      Writes a character with the default style.
      void put​(int x, int y, char c, Style style)
      Writes a character with an explicit style.
      void put​(int x, int y, java.lang.String text)
      Writes a single line of text with the default style, truncated at the right edge.
      void put​(int x, int y, java.lang.String text, Style style)
      Writes a single line of text, truncated at the right edge.
      void putCodePoint​(int x, int y, int codePoint)
      Writes a Unicode code point, including supplementary characters, with the default style.
      void putCodePoint​(int x, int y, int codePoint, Style style)
      Writes a Unicode code point, including supplementary characters, with an explicit style.
      int width()  
    • Method Detail

      • width

        int width()
        Returns:
        the canvas width in columns
      • height

        int height()
        Returns:
        the canvas height in rows
      • bounds

        Rect bounds()
        Returns:
        the local bounds: origin (0,0) with this canvas's width and height
      • put

        void put​(int x,
                 int y,
                 char c)
        Writes a character with the default style.
        Parameters:
        x - the local column
        y - the local row
        c - the character to write
      • put

        void put​(int x,
                 int y,
                 char c,
                 Style style)
        Writes a character with an explicit style.
        Parameters:
        x - the local column
        y - the local row
        c - the character to write
        style - the style to apply
      • putCodePoint

        void putCodePoint​(int x,
                          int y,
                          int codePoint)
        Writes a Unicode code point, including supplementary characters, with the default style.
        Parameters:
        x - the local column
        y - the local row
        codePoint - the Unicode code point to write
      • putCodePoint

        void putCodePoint​(int x,
                          int y,
                          int codePoint,
                          Style style)
        Writes a Unicode code point, including supplementary characters, with an explicit style.
        Parameters:
        x - the local column
        y - the local row
        codePoint - the Unicode code point to write
        style - the style to apply
      • put

        void put​(int x,
                 int y,
                 java.lang.String text)
        Writes a single line of text with the default style, truncated at the right edge.
        Parameters:
        x - the local column of the first character
        y - the local row
        text - the text to write
      • put

        void put​(int x,
                 int y,
                 java.lang.String text,
                 Style style)
        Writes a single line of text, truncated at the right edge.
        Parameters:
        x - the local column of the first character
        y - the local row
        text - the text to write
        style - the style to apply
      • fill

        void fill​(Rect area,
                  char c,
                  Style style)
        Fills a local rectangle with a character and style.
        Parameters:
        area - the local rectangle to fill
        c - the character to fill with
        style - the style to apply
      • clear

        void clear()
        Fills the entire canvas with spaces in the default style.
      • clip

        Canvas clip​(Rect sub)
        Returns a further-clipped sub-canvas whose origin is the given rectangle's top-left.
        Parameters:
        sub - the local rectangle to clip to
        Returns:
        the sub-canvas