CommonCanvas

Common functionality for all canvas types. This interface was separated from Canvas to simplify the implementation of PatternCanvas. This allows the former and Canvas to have different levels of support for perspective rendering. This might be avoidable if Kotlin supported self-types, since the Canvas API has references to context lambdas that refer to Canvas. This might eventually work as self references and allow the interfaces to be merged again.

See also

Inheritors

Properties

Link copied to clipboard
abstract var size: Size

The size to which the Canvas will clip to by default. A View's Canvas won't clip if View.clipCanvasToBounds == false

Inherited properties

Link copied to clipboard

The height to which the Canvas will clip by default.

Link copied to clipboard

The width to which the Canvas will clip by default.

Functions

Link copied to clipboard
abstract fun circle(circle: Circle, fill: Paint)

Fills a circle.

abstract fun circle(circle: Circle, stroke: Stroke, fill: Paint? = null)

Fills and outlines a circle.

Link copied to clipboard
abstract fun ellipse(ellipse: Ellipse, fill: Paint)

Fills an ellipse.

abstract fun ellipse(ellipse: Ellipse, stroke: Stroke, fill: Paint? = null)

Fills and outlines an ellipse.

Link copied to clipboard
open fun image(image: Image, at: Point, opacity: Float = 1.0f, radius: Double = 0.0, source: Rectangle = Rectangle(size = image.size))
abstract fun image(image: Image, destination: Rectangle = Rectangle(size = image.size), opacity: Float = 1.0f, radius: Double = 0.0, source: Rectangle = Rectangle(size = image.size))

Draws an image.

Link copied to clipboard
abstract fun rect(rectangle: Rectangle, fill: Paint)

Fills a rectangle.

abstract fun rect(rectangle: Rectangle, stroke: Stroke, fill: Paint? = null)

Fills and outlines a rectangle.

abstract fun rect(rectangle: Rectangle, radius: Double, fill: Paint)

Fills a rounded rectangle.

abstract fun rect(rectangle: Rectangle, radius: Double, stroke: Stroke, fill: Paint? = null)

Fills and outlines a rounded rectangle.

Link copied to clipboard
abstract fun text(text: StyledText, at: Point = Origin, textSpacing: TextSpacing = default)

Draws styled text.

open fun text(text: String, at: Point = Origin, fill: Paint, textSpacing: TextSpacing = default)

Draws unwrapped plain text in the default Font.

abstract fun text(text: String, font: Font?, at: Point, fill: Paint, textSpacing: TextSpacing = default)

Draws unwrapped plain text.

Link copied to clipboard
abstract fun wrapped(text: StyledText, at: Point = Origin, width: Double, indent: Double = 0.0, alignment: TextAlignment = Start, lineSpacing: Float = 1.0f, textSpacing: TextSpacing = default)

Draws wrapped styled text.

abstract fun wrapped(text: String, at: Point = Origin, width: Double, fill: Paint, font: Font? = null, indent: Double = 0.0, alignment: TextAlignment = Start, lineSpacing: Float = 1.0f, textSpacing: TextSpacing = default)

Draws wrapped plain text.

Inherited functions

Link copied to clipboard
abstract fun arc(center: Point, radius: Double, sweep: Measure<Angle>, rotation: Measure<Angle>, fill: Paint)

Fills an arc centered at the given point and swept by the given angle.

abstract fun arc(center: Point, radius: Double, sweep: Measure<Angle>, rotation: Measure<Angle>, stroke: Stroke, fill: Paint? = null)

Fills and outlines an arc centered at the given point and swept by the given angle.

Link copied to clipboard
inline fun Renderer.arc(center: Point, radius: Double, sweep: Measure<Angle>, rotation: Measure<Angle>, color: Color)

Fills an arc centered at the given point and swept by the given angle.

inline fun Renderer.arc(center: Point, radius: Double, sweep: Measure<Angle>, rotation: Measure<Angle>, stroke: Stroke, color: Color)

Fills and outlines an arc centered at the given point and swept by the given angle.

Link copied to clipboard
inline fun CommonCanvas.circle(circle: Circle, color: Color)

Fills a circle.

inline fun CommonCanvas.circle(circle: Circle, stroke: Stroke, color: Color)

Fills and outlines a circle.

Link copied to clipboard
abstract fun clear()

Clear contents

Link copied to clipboard
inline fun CommonCanvas.ellipse(ellipse: Ellipse, color: Color)

Fills an ellipse.

inline fun CommonCanvas.ellipse(ellipse: Ellipse, stroke: Stroke, color: Color)

Fills and outlines an ellipse.

Link copied to clipboard
abstract fun flush()

Cleans up commits rendering

Link copied to clipboard
abstract fun line(start: Point, end: Point, stroke: Stroke)

Draws a line between the given points.

Link copied to clipboard
abstract fun path(path: Path, stroke: Stroke)
abstract fun path(points: List<Point>, stroke: Stroke)

Draws a line path connecting the given points.

abstract fun path(path: Path, fill: Paint, fillRule: Renderer.FillRule? = null)
abstract fun path(points: List<Point>, fill: Paint, fillRule: Renderer.FillRule? = null)

Fills a line path connecting the given points.

abstract fun path(path: Path, stroke: Stroke, fill: Paint, fillRule: Renderer.FillRule? = null)
abstract fun path(points: List<Point>, stroke: Stroke, fill: Paint, fillRule: Renderer.FillRule? = null)

Fills and outlines a line path connecting the given points.

Link copied to clipboard
inline fun Renderer.path(path: Path, color: Color, fillRule: Renderer.FillRule? = null)
inline fun Renderer.path(points: List<Point>, color: Color, fillRule: Renderer.FillRule? = null)

Fills a line path connecting the given points.

fun Renderer.path(path: Path, stroke: Stroke, color: Color, fillRule: Renderer.FillRule? = null)
inline fun Renderer.path(points: List<Point>, stroke: Stroke, color: Color, fillRule: Renderer.FillRule? = null)

Fills and outlines a line path connecting the given points.

Link copied to clipboard
abstract fun poly(polygon: Polygon, fill: Paint)

Fills a polygon.

abstract fun poly(polygon: Polygon, stroke: Stroke, fill: Paint? = null)

Fills and outlines a polygon.

Link copied to clipboard
inline fun Renderer.poly(polygon: Polygon, color: Color)

Fills a polygon.

inline fun Renderer.poly(polygon: Polygon, stroke: Stroke, color: Color)

Fills and outlines a polygon.

Link copied to clipboard
inline fun CommonCanvas.rect(rectangle: Rectangle, color: Color)

Fills a rectangle.

inline fun CommonCanvas.rect(rectangle: Rectangle, stroke: Stroke, color: Color)

Fills and outlines a rectangle.

inline fun CommonCanvas.rect(rectangle: Rectangle, radius: Double, color: Color)

Fills a rounded rectangle.

inline fun CommonCanvas.rect(rectangle: Rectangle, radius: Double, stroke: Stroke, color: Color)

Fills and outlines a rounded rectangle.

Link copied to clipboard
inline fun CommonCanvas.text(text: String, at: Point = Origin, color: Color)

Draws unwrapped plain text in the default Font.

inline fun CommonCanvas.text(text: String, font: Font?, at: Point = Origin, color: Color)

Draws unwrapped plain text.

Link copied to clipboard
abstract fun wedge(center: Point, radius: Double, sweep: Measure<Angle>, rotation: Measure<Angle>, fill: Paint)

Fills a width centered at the given point and swept by the given angle. Wedges are like arcs with their paths closed at the center point.

abstract fun wedge(center: Point, radius: Double, sweep: Measure<Angle>, rotation: Measure<Angle>, stroke: Stroke, fill: Paint? = null)

Fills and outlines a width centered at the given point and swept by the given angle. Wedges are like arcs with their paths closed at the center point.

Link copied to clipboard
inline fun Renderer.wedge(center: Point, radius: Double, sweep: Measure<Angle>, rotation: Measure<Angle>, color: Color)

Fills a width centered at the given point and swept by the given angle. Wedges are like arcs with their paths closed at the center point.

inline fun Renderer.wedge(center: Point, radius: Double, sweep: Measure<Angle>, rotation: Measure<Angle>, stroke: Stroke, color: Color)

Fills and outlines a width centered at the given point and swept by the given angle. Wedges are like arcs with their paths closed at the center point.

Link copied to clipboard
inline fun CommonCanvas.wrapped(text: String, font: Font? = null, at: Point, width: Double, color: Color)

Draws wrapped plain text.