2D rendering pane. Canvas is synonymous with screen, i.e. it is an object that allows to draw on the screen. Canvas has the dimension of the current scene or, if scene doesn't provide its own dimension, the size of the terminal. Note that this behavior means that canvas can change its size from frame to frame if the current scene does not provide its own dimension and the terminal size is changing. One can generally draw outside of canvas dimensions and any such pixels will be simply ignored.
For each game frame, the game engine creates a new empty canvas for all scene objects to draw on with the dimension set as described above. This canvas is available to scene objects via CPSceneObjectContext.getCanvas method. Game engine then compares previous canvas and this one to determine which areas of the terminal need redrawing.
You can also create the canvas object outside game loop using companion object methods. Such "off-line" canvas is convenient when one needs to draw something off the screen and then capture that drawing as an image, for example, during scene initialization out of the game loop.
Canvas (0,0)
coordinate point is located in the top left corner. X-axis goes to the right and Y-axis points down. Every drawn pixel on the canvas also has a Z-index or depth. Pixel with larger or equal Z-index visually overrides the pixel with the smaller Z-index. Pixels with coordinates outside of the current canvas dimensions are ignored.
ASCII-based graphics are vastly different from the traditional raster-based graphics. Since ASCII-based drawing uses printable characters from ASCII character set that are displayed on basic text terminal most differences are obvious but some are more subtle and unexpected. For example, while straight vertical and horizontal lines are easy to implement many curved lines are much trickier to draw. Specifically, circles and ellipses, for example, are hard to do properly in automated way. Moreover, many complex curves need to be done manually, especially if they are dynamically redrawn on each frame update.
This class provides many methods for basic line and rectangular drawing, circle and polyline, anti-aliasing, "color" fill in, and much more. Most functions have multiple overridden variants with different parameters so that they can be easily used in different contexts. Note also that this class deals primarily with line ASCII art and has only few functions like antialiasing for the solid ASCII art.
One of the useful techniques of obtaining a complex "drawn-on-canvas" images is to create a new canvas object at the scene's start (see CPLifecycle.onStart method), draw all necessary ASCII art on it and then capture the image using one of the capture()
methods in this class. Once image is obtained you can use it with any image-based sprites to display it.
There are many online tutorials for ASCII art that are highly recommended, including from:
See also the following resources for general ASCII art collections:
Value parameters
- clip
-
Clipping region.
- pane
-
Underlying z-pane.
Attributes
- See also
- Example
-
See CPCanvasExample class for the example of using canvas.
- Companion
- object
- Source
- CPCanvas.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Value members
Concrete methods
Antialiases solid ascii-art canvas region. Works only
for solid ascii-art.
Antialiases solid ascii-art canvas region. Works only
for solid ascii-art.
The antialiasing algorithm is based on implementation described at https://codegolf.stackexchange.com/questions/5450/anti-aliasing-ascii-art
Value parameters
- dim
-
Dimension of the region.
- isBlank
-
Predicate defining whether a particular pixel should be considered as a blank.
- x
-
X-coordinate of the top level corner of the region.
- y
-
Y-coordinate of the top level corner of the region.
Attributes
- Source
- CPCanvas.scala
Antialiases solid ASCII-art canvas region. Works only
for solid ASCII-art.
Antialiases solid ASCII-art canvas region. Works only
for solid ASCII-art.
The antialiasing algorithm is based on implementation described at https://codegolf.stackexchange.com/questions/5450/anti-aliasing-ascii-art
Value parameters
- isBlank
-
Predicate defining whether a particular pixel should be considered as a blank.
- rect
-
Region to antialias.
Attributes
- Source
- CPCanvas.scala
Antialiasing solid ASCII-art canvas region. Works only
for solid ASCII-art.
Antialiasing solid ASCII-art canvas region. Works only
for solid ASCII-art.
The antialiasing algorithm is based on implementation described at https://codegolf.stackexchange.com/questions/5450/anti-aliasing-ascii-art
Value parameters
- isBlank
-
Predicate defining whether a particular pixel should be considered as a blank.
- x1
-
X-coordinate of the top left corner for the region.
- x2
-
X-coordinate of the bottom right corner for the region.
- y1
-
Y-coordinate of the top left corner for the region.
- y2
-
Y-coordinate of the bottom right corner for the region.
Attributes
- Source
- CPCanvas.scala
Gets a mutable array of pixels representing the art line.
Gets a mutable array of pixels representing the art line.
Art-style drawings use characters from the "`'.,/\|_-
character set (unless modified by pixel producing function whenever it is available as a parameter). Art-style drawing typically provide smoother gradients for curved lines. ART_BLOCK style uses only |\/_
characters while ART_SMOOTH uses all of the "'.`,/\|_-
characters. ART_SMOOTH style is less performant then ART_BLOCK.
The following illustrates the difference between non-art and art-style drawings using a line vector example:
non-art ART_BLOCK ART_SMOOTH
+------------+ +-------------+ +-------------+
| ***** | | ____ | | ____ |
| ** | | ___/ | | _,-' |
| *** | | __/ | | ,-' |
+------------+ +-------------+ +-------------+
Value parameters
- ax
-
X-coordinate of the start point.
- ay
-
Y-coordinate of the start point.
- bx
-
X-coordinate of the end point.
- by
-
Y-coordinate of the end point.
- pxf
-
Pixel producing function.
- style
-
Art style. The default value is ART_BLOCK.
- z
-
Z-index of the drawing. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Captures given rectangular canvas region as an image. This method will capture only "visible" image of the given region.
Captures given rectangular canvas region as an image. This method will capture only "visible" image of the given region.
Value parameters
- x1
-
X-coordinate of the top left corner of the region.
- x2
-
X-coordinate of the bottom right corner of the region.
- y1
-
Y-coordinate of the top left corner of the region.
- y2
-
Y-coordinate of the bottom right corner of the region.
Attributes
- Source
- CPCanvas.scala
Captures given rectangular canvas region as an image. This method will capture only "visible" image of the given region.
Captures given rectangular canvas region as an image. This method will capture only "visible" image of the given region.
Value parameters
- x1
-
X-coordinate of the top left corner of the region.
- y1
-
Y-coordinate of the top left corner of the region.
Attributes
- Source
- CPCanvas.scala
Captures given rectangular canvas region as an image. This method will capture only "visible" image of the given region.
Captures given rectangular canvas region as an image. This method will capture only "visible" image of the given region.
Value parameters
- rect
-
Rectangular region to capture.
Attributes
- Source
- CPCanvas.scala
Captures entire canvas as an image. This method will capture only "visible" image of the given region.
Captures entire canvas as an image. This method will capture only "visible" image of the given region.
Attributes
- Source
- CPCanvas.scala
Captures given rectangular canvas region as an image. This method will capture only specified Z-index layers replacing pixels on other layers with CPPixel.XRAY in the resulting image.
Captures given rectangular canvas region as an image. This method will capture only specified Z-index layers replacing pixels on other layers with CPPixel.XRAY in the resulting image.
Value parameters
- x1
-
X-coordinate of the top left corner of the region.
- x2
-
X-coordinate of the bottom right corner of the region.
- y1
-
Y-coordinate of the top left corner of the region.
- y2
-
Y-coordinate of the bottom right corner of the region.
- zdx
-
Z-indexes to capture.
Attributes
- Source
- CPCanvas.scala
Captures given rectangular canvas region as an image. This method will capture only specified z-index layers replacing pixels on other layers with CPPixel.XRAY in the resulting image.
Captures given rectangular canvas region as an image. This method will capture only specified z-index layers replacing pixels on other layers with CPPixel.XRAY in the resulting image.
Value parameters
- dim
-
Dimension of the region to capture.
- x1
-
X-coordinate of the top left corner of the region.
- y1
-
Y-coordinate of the top left corner of the region.
- zdx
-
Z-indexes to capture.
Attributes
- Source
- CPCanvas.scala
Captures given rectangular canvas region as an image. This method will capture only specified z-index layers replacing pixels on other layers with CPPixel.XRAY in the resulting image.
Captures given rectangular canvas region as an image. This method will capture only specified z-index layers replacing pixels on other layers with CPPixel.XRAY in the resulting image.
Value parameters
- rect
-
Rectangular region to capture.
- zdx
-
Z-indexes to capture.
Attributes
- Source
- CPCanvas.scala
Produces mutable array of pixels representing the circle.
Produces mutable array of pixels representing the circle.
Value parameters
- densFactor
-
Density factor defines "granularity" of drawing. Values below
1.0
allow to compensate for discreetness of ASCII graphics. Typically, value of0.5
is a good default. - fillGaps
-
Whether or not to fill potential gaps in circle drawing. Filling the gaps slows down the drawing but produces a better looking circle.
- pxf
-
Pixel producer function.
- radius
-
Radius of the circle in characters.
- x
-
X-coordinate of the circle center.
- xFactor
-
Horizontal squishing factor. Values below 1.0 will squish the circle horizontally. Values above 1.0 will stretch the circle horizontally. X-factor of
2.0
and Y-factor of1.0
typically produce correct circle using 1x2 monospace font. - y
-
Y-coordinate of the circle center.
- yFactor
-
Vertical squishing factor. Values below 1.0 will squish the circle vertically. Values above 1.0 will stretch the circle vertically. X-factor of
2.0
and Y-factor of1.0
typically produce correct circle using 1x2 monospace font. - z
-
Z-index of the drawing. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Copies one rectangular areas in this canvas to another location in the same canvas.
Copies one rectangular areas in this canvas to another location in the same canvas.
Value parameters
- destX
-
New X-coordinate of the top left corner.
- destY
-
New Y-coordinate of the top left corner.
- x1
-
X-coordinate of the top left corner of the area to copy.
- x2
-
X-coordinate of the bottom right corner of the area to copy.
- y1
-
Y-coordinate of the top left corner of the area to copy.
- y2
-
Y-coordinate of the bottom right corner of the area to copy.
Attributes
- Source
- CPCanvas.scala
Copies one rectangular areas in this canvas to another location in the same canvas.
Copies one rectangular areas in this canvas to another location in the same canvas.
Value parameters
- destX
-
New X-coordinate of the top left corner.
- destY
-
New Y-coordinate of the top left corner.
- dim
-
Dimension of the area to copy.
- x1
-
X-coordinate of the top left corner of the area to copy.
- y1
-
Y-coordinate of the top left corner of the area to copy.
Attributes
- Source
- CPCanvas.scala
Copies one rectangular areas in this canvas to another location in the same canvas.
Copies one rectangular areas in this canvas to another location in the same canvas.
Value parameters
- destX
-
New X-coordinate of the top left corner.
- destY
-
New Y-coordinate of the top left corner.
- rect
-
Rectangular shape to copy.
Attributes
- Source
- CPCanvas.scala
Draws an art line.
Draws an art line.
Art-style drawings use characters from the "`'.,/\|_-
character set (unless modified by pixel producing function whenever it is available as a parameter). Art-style drawing typically provide smoother gradients for curved lines. ART_BLOCK style uses only |\/_
characters while ART_SMOOTH uses all of the "'.`,/\|_-
characters. ART_SMOOTH style is less performant then ART_BLOCK.
The following illustrates the difference between non-art and art-style drawings using a line vector example:
non-art ART_BLOCK ART_SMOOTH
+------------+ +-------------+ +-------------+
| ***** | | ____ | | ____ |
| ** | | ___/ | | _,-' |
| *** | | __/ | | ,-' |
+------------+ +-------------+ +-------------+
Value parameters
- ax
-
X-coordinate of the start point.
- ay
-
Y-coordinate of the start point.
- bx
-
X-coordinate of the end point.
- by
-
Y-coordinate of the end point.
- pxf
-
Pixel producing function.
- style
-
Art style to use. Default value is ART_BLOCK.
- z
-
Z-index of the drawing. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws an art-style polyline.
Draws an art-style polyline.
Art-style drawings use characters from the "`'.,/\|_-
character set (unless modified by pixel producing function whenever it is available as a parameter). Art-style drawing typically provide smoother gradients for curved lines. ART_BLOCK style uses only |\/_
characters while ART_SMOOTH uses all of the "'.`,/\|_-
characters. ART_SMOOTH style is less performant then ART_BLOCK.
The following illustrates the difference between non-art and art-style drawings using a line vector example:
non-art ART_BLOCK ART_SMOOTH
+------------+ +-------------+ +-------------+
| **** | | ___ | | ___ |
| ** | | ___/ | | _,-' |
| *** | | __/ | | ,-' |
+------------+ +-------------+ +-------------+
Value parameters
- pts
-
Points of the polyline.
- pxf
-
Pixel producing function.
- style
-
Art style to use. Default value is ART_BLOCK.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws art-style vector.
Draws art-style vector.
Art-style drawings use characters from the "`'.,/\|_-
character set (unless modified by pixel producing function whenever it is available as a parameter). Art-style drawing typically provide smoother gradients for curved lines. ART_BLOCK style uses only |\/_
characters while ART_SMOOTH uses all of the "'.`,/\|_-
characters. ART_SMOOTH style is less performant then ART_BLOCK.
The following illustrates the difference between non-art and art-style drawings using a line vector example:
non-art ART_BLOCK ART_SMOOTH
+------------+ +-------------+ +-------------+
| ***** | | ____ | | ____ |
| ** | | ___/ | | _,-' |
| *** | | __/ | | ,-' |
+------------+ +-------------+ +-------------+
Value parameters
- deg
-
Angle of vector in degrees [0..360].
- len
-
Length of the vector.
- pxf
-
Pixel producer function.
- style
-
Art-style to draw the vector with. Default is ART_BLOCK.
- x
-
X-coordinate of the start point.
- xFactor
-
Horizontal squishing factor. Values below 1.0 will squish the vector horizontally. Values above 1.0 will stretch the vector horizontally.
- y
-
Y-coordinate of the start point.
- yFactor
-
Vertical squishing factor. Values below 1.0 will squish the vector vertically. Values above 1.0 will stretch the vector vertically.
- z
-
Z-index of the drawn vector. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a border.
Draws a border.
Value parameters
- bottom
-
Bottom size pixel.
- left
-
Left side pixel.
- leftBottom
-
Left bottom corner pixel.
- leftTop
-
Left top corner pixel.
- right
-
Right side line pixel.
- rightBottom
-
Right bottom corner pixel.
- rightTop
-
Right top corner pixel.
- skin
-
Skin function that takes global X and Y coordinates as well as default pixel at that location and returns the skinned pixel.
- title
-
Title of the border. Default is no border.
- titleX
-
X-coordinate of the title. Default is -1.
- titleY
-
Y-coordinate of the title. Default is -1.
- top
-
Top line pixel.
- x1
-
X-coordinate of the top left corner.
- x2
-
X-coordinate of the bottom right corner.
- y1
-
Y-coordinate of the top left corner.
- y2
-
Y-coordinate of the bottom right corner.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a circle.
Draws a circle.
Value parameters
- densFactor
-
Density factor defines "granularity" of drawing. Values below
1.0
allow to compensate for discreetness of ASCII graphics. Typically, value of0.5
is a good default. - fillGaps
-
Whether or not to fill potential gaps in circle drawing. Filling the gaps slows down the drawing but produces a better looking circle.
- pxs
-
Sequence of pixels to use in drawing the circle.
- radius
-
Radius of the circle in characters.
- x
-
X-coordinate of the circle center.
- xFactor
-
Horizontal squishing factor. Values below 1.0 will squish the circle horizontally. Values above 1.0 will stretch the circle horizontally. X-factor of
2.0
and Y-factor of1.0
typically produce correct circle using 1x2 monospace font. - y
-
Y-coordinate of the circle center.
- yFactor
-
Vertical squishing factor. Values below 1.0 will squish the circle vertically. Values above 1.0 will stretch the circle vertically. X-factor of
2.0
and Y-factor of1.0
typically produce correct circle using 1x2 monospace font. - z
-
Z-index of the drawing. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a circle with a single pixel returning its final shape.
Draws a circle with a single pixel returning its final shape.
Value parameters
- densFactor
-
Density factor defines "granularity" of drawing. Values below
1.0
allow to compensate for discreetness of ASCII graphics. Typically, value of0.5
is a good default. - fillGaps
-
Whether or not to fill potential gaps in circle drawing. Filling the gaps slows down the drawing but produces a better looking circle.
- px
-
Pixel to draw a circle with.
- radius
-
Radius of the circle in characters.
- x
-
X-coordinate of the circle center.
- xFactor
-
Horizontal squishing factor. Values below 1.0 will squish the circle horizontally. Values above 1.0 will stretch the circle horizontally. X-factor of
2.0
and Y-factor of1.0
typically produce correct circle using 1x2 monospace font. - y
-
Y-coordinate of the circle center.
- yFactor
-
Vertical squishing factor. Values below 1.0 will squish the circle vertically. Values above 1.0 will stretch the circle vertically. X-factor of
2.0
and Y-factor of1.0
typically produce correct circle using 1x2 monospace font. - z
-
Z-index of the drawing. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a circle returning its final shape returning its final shape.
Draws a circle returning its final shape returning its final shape.
Value parameters
- densFactor
-
Density factor defines "granularity" of drawing. Values below
1.0
allow to compensate for discreetness of ASCII graphics. Typically, value of0.5
is a good default. - fillGaps
-
Whether or not to fill potential gaps in circle drawing. Filling the gaps slows down the drawing but produces a better looking circle.
- pxf
-
Pixel producer function.
- radius
-
Radius of the circle in characters.
- x
-
X-coordinate of the circle center.
- xFactor
-
Horizontal squishing factor. Values below 1.0 will squish the circle horizontally. Values above 1.0 will stretch the circle horizontally. X-factor of
2.0
and Y-factor of1.0
typically produce correct circle using 1x2 monospace font. - y
-
Y-coordinate of the circle center.
- yFactor
-
Vertical squishing factor. Values below 1.0 will squish the circle vertically. Values above 1.0 will stretch the circle vertically. X-factor of
2.0
and Y-factor of1.0
typically produce correct circle using 1x2 monospace font. - z
-
Z-index of the drawing. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws given image.
Draws given image.
Value parameters
- img
-
Image to draw.
- x
-
X-coordinate of the top left corner.
- y
-
Y-coordinate of the top left corner.
- z
-
Z-index to draw the given image at. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a line.
Draws a line.
Value parameters
- ax
-
X-coordinate of the start point.
- ay
-
Y-coordinate of the start point.
- bx
-
X-coordinate of the end point.
- by
-
Y-coordinate of the end point.
- px
-
Pixel to use to draw the line.
- z
-
Z-index of the drawing. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws the line with custom endpoints.
Draws the line with custom endpoints.
Value parameters
- ax
-
X-coordinate of the start point.
- ay
-
Y-coordinate of the start point.
- bx
-
X-coordinate of the end point.
- by
-
Y-coordinate of the end point.
- endPx
-
End pixel.
- linePx
-
Line pixel.
- startPx
-
Start pixel.
- z
-
Z-index of the drawing. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a line.
Draws a line.
Value parameters
- ax
-
X-coordinate of the start point.
- ay
-
Y-coordinate of the start point.
- bx
-
X-coordinate of the end point.
- by
-
Y-coordinate of the end point.
- pxs
-
Sequence of pixels to use to draw this line.
- z
-
Z-index of the drawing. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a line.
Draws a line.
Value parameters
- ax
-
X-coordinate of the start point.
- ay
-
Y-coordinate of the start point.
- bx
-
X-coordinate of the end point.
- by
-
Y-coordinate of the end point.
- pxf
-
Pixel producing function.
- z
-
Z-index of the drawing. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a single pixel.
Draws a single pixel.
Value parameters
- px
-
Pixel to draw.
- x
-
X-coordinate of the pixel.
- y
-
Y-coordinate of the pixel.
- z
-
Z-index for this pixel. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a single pixel.
Draws a single pixel.
Value parameters
- px
-
Pixel to draw.
- xy
-
Xy-coordinate tuple of the pixel.
- z
-
Z-index for this pixel. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a pixel.
Draws a pixel.
Value parameters
- bg
-
Pixel optional background color. Default value is
None
. - char
-
Pixel character.
- fg
-
Pixel foreground color.
- x
-
X-coordinate of the pixel.
- y
-
Y-coordinate of the pixel.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws pixels.
Draws pixels.
Value parameters
- len
-
Number of pixel to draw.
- pxf
-
Pixel producing function.
- x
-
X-coordinate of the start point.
- y
-
Y-coordinate of the start point.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws pixels.
Draws pixels.
Value parameters
- pxs
-
Pixels to draw.
- x
-
X-coordinate of the start point.
- y
-
Y-coordinate of the start point.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a polyline.
Draws a polyline.
Value parameters
- pts
-
Points of polyline.
- px
-
Pixel to use to draw a polyline with.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a polyline.
Draws a polyline.
Value parameters
- pts
-
Points of polyline.
- pxs
-
Pixel producing function.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a polyline.
Draws a polyline.
Value parameters
- pts
-
Points of the polyline.
- pxf
-
Pixel producing function.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a rectangle.
Draws a rectangle.
Value parameters
- px
-
Pixel to use for drawing.
- x1
-
X-coordinate of the left top corner.
- x2
-
X-coordinate of the right bottom corner.
- y1
-
Y-coordinate of the left top corner.
- y2
-
Y-coordinate of the right bottom corner.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a rectangle.
Draws a rectangle.
Value parameters
- dim
-
Dimension of the rectangle.
- px
-
Pixel to use for drawing.
- x1
-
X-coordinate of the left top corner.
- y1
-
Y-coordinate of the left top corner.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a rectangle.
Draws a rectangle.
Value parameters
- px
-
Pixel to draw the rectangle with.
- rect
-
Shape of rectangle to draw.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a rectangle.
Draws a rectangle.
Value parameters
- pxf
-
Pixel producing function.
- x1
-
X-coordinate of the left top corner.
- x2
-
X-coordinate of the right bottom corner.
- y1
-
Y-coordinate of the left top corner.
- y2
-
Y-coordinate of the right bottom corner.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a rectangle.
Draws a rectangle.
Value parameters
- dim
-
Dimension of the rectangle.
- pxf
-
Pixel producing function.
- x1
-
X-coordinate of the top left corner.
- y1
-
Y-coordinate of the top left corner.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws rectangle.
Draws rectangle.
Value parameters
- pxf
-
Pixel producing function.
- rect
-
Rectangle shape to draw.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws rectangle with specific pixels for lines and corners.
Draws rectangle with specific pixels for lines and corners.
Value parameters
- bottom
-
Bottom size pixel.
- left
-
Left side pixel.
- leftBottom
-
Left bottom corner pixel.
- leftTop
-
Left top corner pixel.
- right
-
Right side line pixel.
- rightBottom
-
Right bottom corner pixel.
- rightTop
-
Right top corner pixel.
- skin
-
Skin function that takes global X and Y coordinates as well as default pixel at that location and returns the skinned pixel.
- top
-
Top line pixel.
- x1
-
X-coordinate of the left top corner.
- x2
-
X-coordinate of the right bottom corner.
- y1
-
Y-coordinate of the left top corner.
- y2
-
Y-coordinate of the right bottom corner.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws rectangle with specific pixels for lines and corners.
Draws rectangle with specific pixels for lines and corners.
Value parameters
- bottom
-
Bottom size pixel.
- dim
-
Dimension of the rectangle.
- left
-
Left side pixel.
- leftBottom
-
Left bottom corner pixel.
- leftTop
-
Left top corner pixel.
- right
-
Right side line pixel.
- rightBottom
-
Right bottom corner pixel.
- rightTop
-
Right top corner pixel.
- top
-
Top line pixel.
- x1
-
X-coordinate of the top left corner.
- y1
-
Y-coordinate of the top left corner.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws rectangle with specific pixels for lines and corners.
Draws rectangle with specific pixels for lines and corners.
Value parameters
- bottom
-
Bottom size pixel.
- left
-
Left side pixel.
- leftBottom
-
Left bottom corner pixel.
- leftTop
-
Left top corner pixel.
- rect
-
Rectangle shape.
- right
-
Right side line pixel.
- rightBottom
-
Right bottom corner pixel.
- rightTop
-
Right top corner pixel.
- top
-
Top line pixel.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a single color border for a given rectangle.
Draws a single color border for a given rectangle.
Value parameters
- bg
-
An optional background color to be used for all border pixels.
- chars
-
A sequence of character in the following order: top, top left border, left, bottom left corner, bottom, bottom right corner, right, top right corner.
- fg
-
A foreground color to be used for all border pixels.
- rect
-
A rectangle to draw a border around.
- skin
-
Skin function that takes global X and Y coordinates as well as default pixel at that location and returns the skinned pixel. Default value is the function that returns the same pixel.
- title
-
Title of the border. Default is no border.
- titleX
-
X-coordinate of the title. Default is -1.
- titleY
-
Y-coordinate of the title. Default is -1.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a border using shorter set of parameters.
Draws a border using shorter set of parameters.
Value parameters
- corner
-
Pixel for corners,
- hor
-
Pixel for horizontal lines.
- skin
-
Skin function that takes X and Y coordinates as well as default pixel at that location and returns the skinned pixel.
- title
-
Title of the border. Default is no border.
- titleX
-
X-coordinate of the title. Default is -1.
- titleY
-
Y-coordinate of the title. Default is -1.
- ver
-
Pixel for vertical lines.
- x1
-
X-coordinate of the top left corner.
- x2
-
X-coordinate of the bottom right corner.
- y1
-
Y-coordinate of the top left corner.
- y2
-
Y-coordinate of the bottom right corner.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws given string using system font.
Draws given string using system font.
Value parameters
- bg
-
Optional background color. Default value is
None
. - fg
-
Foreground color.
- str
-
String to draw.
- x
-
X-coordinate of the first character.
- y
-
Y-coordinate of the first character.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws given styled string.
Draws given styled string.
Value parameters
- ss
-
Styled string to draw.
- x
-
X-coordinate of the first character.
- y
-
Y-coordinate of the first character.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a vector with a single pixel.
Draws a vector with a single pixel.
Value parameters
- deg
-
Angle of vector in degrees [0..360].
- len
-
Length of the vector.
- px
-
Single pixel to draw vector with.
- x
-
X-coordinate of the start point.
- y
-
Y-coordinate of the start point.
- z
-
Z-index of the drawn vector. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a vector.
Draws a vector.
Value parameters
- deg
-
Angle of vector in degrees [0..360].
- len
-
Length of the vector.
- pxs
-
Sequence of pixels to use for drawing.
- x
-
X-coordinate of the start point.
- xFactor
-
Horizontal squishing factor. Values below 1.0 will squish the vector horizontally. Values above 1.0 will stretch the vector horizontally.
- y
-
Y-coordinate of the start point.
- yFactor
-
Vertical squishing factor. Values below 1.0 will squish the vector vertically. Values above 1.0 will stretch the vector vertically.
- z
-
Z-index of the drawn vector. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Draws a vector.
Draws a vector.
Value parameters
- deg
-
Angle of vector in degrees [0..360].
- len
-
Length of the vector.
- pxf
-
Pixel producer function.
- x
-
X-coordinate of the start point.
- xFactor
-
Horizontal squishing factor. Values below 1.0 will squish the vector horizontally. Values above 1.0 will stretch the vector horizontally.
- y
-
Y-coordinate of the start point.
- yFactor
-
Vertical squishing factor. Values below 1.0 will squish the vector vertically. Values above 1.0 will stretch the vector vertically.
- z
-
Z-index of the drawn vector. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Fills in bordered area with a pixel. This is also known as "bucket tool".
Fills in bordered area with a pixel. This is also known as "bucket tool".
Value parameters
- isBorder
-
Border predicate.
- pxf
-
Fill in pixel producer.
- x
-
X-coordinate of the start point.
- y
-
Y-coordinate of the start point.
Attributes
- Source
- CPCanvas.scala
Fills the rectangular shape with given pixel.
Fills the rectangular shape with given pixel.
Value parameters
- px
-
Pixel to fill in with.
- x1
-
X-coordinate of the top left corner of the shape.
- x2
-
X-coordinate of the bottom right corner of the shape.
- y1
-
Y-coordinate of the top left corner of the shape.
- y2
-
Y-coordinate of the bottom right corner of the shape.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Fills the rectangular shape with given pixel.
Fills the rectangular shape with given pixel.
Value parameters
- dim
-
Dimension of the rectangle to fill in.
- px
-
Pixel to fill in with.
- x1
-
X-coordinate of the top left corner of the shape.
- y1
-
Y-coordinate of the top left corner of the shape.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Fills the rectangular shape.
Fills the rectangular shape.
Value parameters
- dim
-
Dimension of the rectangle to fill in.
- pxf
-
Fill in pixel producing function.
- x1
-
X-coordinate of the top left corner of the shape.
- y1
-
Y-coordinate of the top left corner of the shape.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Fills the rectangular shape.
Fills the rectangular shape.
Value parameters
- dim
-
Dimension of the rectangle to fill in.
- pxs
-
Pixels to use for filling in.
- x1
-
X-coordinate of the top left corner of the shape.
- y1
-
Y-coordinate of the top left corner of the shape.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Fills the rectangular shape.
Fills the rectangular shape.
Value parameters
- px
-
Pixel to use for filling in.
- rect
-
Rectangle shape to fill in.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Fills the rectangular shape.
Fills the rectangular shape.
Value parameters
- pxf
-
Fill in pixel producing function.
- x1
-
X-coordinate of the top left corner of the shape.
- x2
-
X-coordinate of the bottom right corner of the shape.
- y1
-
Y-coordinate of the top left corner of the shape.
- y2
-
Y-coordinate of the bottom right corner of the shape.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Fills the rectangular shape.
Fills the rectangular shape.
Value parameters
- pxf
-
Fill in pixel producing function.
- rect
-
Rectangular shape to fill in.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Fills the rectangular shape.
Fills the rectangular shape.
Value parameters
- pxs
-
Pixels to use for filling in.
- x1
-
X-coordinate of the top left corner of the shape.
- x2
-
X-coordinate of the bottom right corner of the shape.
- y1
-
Y-coordinate of the top left corner of the shape.
- y2
-
Y-coordinate of the bottom right corner of the shape.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Fills the rectangular shape.
Fills the rectangular shape.
Value parameters
- pxs
-
Pixels to use for filling in.
- rect
-
Rectangular shape to fill in.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Gets clipping region for this canvas. Note that it is available only for information purpose since all functions in this class automatically handle the clipping.
Gets clipping region for this canvas. Note that it is available only for information purpose since all functions in this class automatically handle the clipping.
Attributes
- Source
- CPCanvas.scala
Gets a pixel at given XY-coordinate.
Gets a pixel at given XY-coordinate.
Value parameters
- x
-
X-coordinate.
- y
-
Y-coordinate.
Attributes
- Returns
-
Pixel at given coordinate.
- Source
- CPCanvas.scala
Inverses color of the pixel at given XY-coordinate.
Inverses color of the pixel at given XY-coordinate.
Value parameters
- x
-
X-coordinate.
- y
-
Y-coordinate.
Attributes
- Source
- CPCanvas.scala
Tests whether or not given XY-coordinates are within this canvas.
Tests whether or not given XY-coordinates are within this canvas.
Value parameters
- x
-
X-coordinate to test.
- y
-
Y-coordinate to test.
Attributes
- Source
- CPCanvas.scala
Gets a mutable array of pixels representing a line.
Gets a mutable array of pixels representing a line.
Value parameters
- ax
-
X-coordinate of the start point.
- ay
-
Y-coordinate of the start point.
- bx
-
X-coordinate of the end point.
- by
-
Y-coordinate of the end point.
- pxf
-
Pixel producing function.
- z
-
Z-index of the drawing. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Gets a mutable array of pixels representing a polyline.
Gets a mutable array of pixels representing a polyline.
Value parameters
- pts
-
Points of the polyline.
- pxf
-
Pixel producing function.
- z
-
Z-index. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Produces mutable array of pixels representing the vector.
Produces mutable array of pixels representing the vector.
Value parameters
- deg
-
Angle of vector in degrees [0..360].
- len
-
Length of the vector.
- pxf
-
Pixel producer function.
- x
-
X-coordinate of the start point.
- xFactor
-
Horizontal squishing factor. Values below 1.0 will squish the vector horizontally. Values above 1.0 will stretch the vector horizontally.
- y
-
Y-coordinate of the start point.
- yFactor
-
Vertical squishing factor. Values below 1.0 will squish the vector vertically. Values above 1.0 will stretch the vector vertically.
- z
-
Z-index of the drawn vector. Pixel with the larger or equal Z-index overrides the pixel with the smaller one.
Attributes
- Source
- CPCanvas.scala
Concrete fields
Dimension of this canvas.
Height of this canvas (shortcut API).
Height of this canvas as float (shortcut API).
Height of this canvas.
Rectangle object (shape) for this canvas.
Width of this canvas (shortcut API).
Width of this canvas as float (shortcut API).
Width of this canvas.
X-coordinate of the center point of this canvas.
X-coordinate of the center point of this canvas as a float.
Maximum X-coordinate of this canvas.
Maximum X-coordinate of this canvas as a float.
Minimum X-coordinate of this canvas (always zero).
Minimum X-coordinate of this canvas (always zero) as a float.
Y-coordinate of the center point of this canvas.
Y-coordinate of the center point of this canvas as a float.
Maximum Y-coordinate of this canvas.
Maximum Y-coordinate of this canvas as a float.
Minimum Y-coordinate of this canvas (always zero).
Minimum Y-coordinate of this canvas (always zero) as a float.