Package-level declarations

Types

Link copied to clipboard
abstract class AffineTransform

Represents an Affine Transformation that supports 3D.

Link copied to clipboard

Represents an Affine Transformation that supports only 2D.

Link copied to clipboard
interface Canvas : CommonCanvas

All rendering operations are done using Canvases. A canvas represents an "infinite", 2-D surface that can be "drawn" onto. Despite this, there is a size associated with each Canvas that indicates its clipping region. The framework manages Canvases and makes them available to Views during View.render.

Link copied to clipboard
class Color(val red: UByte, val green: UByte, val blue: UByte, val opacity: Float = 1.0f)

Represents an RGBA color.

Link copied to clipboard
class ColorPaint(val color: Color) : Paint

A basic Paint consisting of a single Color.

Link copied to clipboard

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.

Link copied to clipboard
interface Font

Represents a font used to render text. NOTE: this interface is only intended to be implemented by the framework. This ensures that instances always represent a loaded Font that can be used to render text without issue.

Link copied to clipboard
class FontInfo(var size: Int = 12, var style: Font.Style = Style.Normal, var weight: Int = Normal, var families: List<String> = emptyList())
Link copied to clipboard
interface FontLoader

Provides a mechanism to load or lookup Fonts.

Link copied to clipboard
sealed class GradientPaint(val colors: List<GradientPaint.Stop>) : Paint

A gradient Paint that transitions between a list of Stops.

Link copied to clipboard
Link copied to clipboard
class HslColor(hue: Measure<Angle>, val saturation: Float, val lightness: Float, val opacity: Float = 1.0f)

Represents an HSL color.

Link copied to clipboard
class HsvColor(hue: Measure<Angle>, val saturation: Float, val value: Float, val opacity: Float = 1.0f)

Represents an HSV color.

Link copied to clipboard
class ImagePaint(val image: Image, val size: Size = image.size, val opacity: Float = 1.0f) : Paint

A Paint that produces a repeating fill with the given Image.

Link copied to clipboard
class InnerShadow(val horizontal: Double = 0.0, val vertical: Double = 0.0, val blurRadius: Double = 0.0, val color: Color = Black) : Shadow
Link copied to clipboard
class LinearGradientPaint(val colors: List<GradientPaint.Stop>, val start: Point, val end: Point) : GradientPaint

A linear gradient Paint that transitions between a list of Stops.

Link copied to clipboard
class OuterShadow(val horizontal: Double = 0.0, val vertical: Double = 0.0, val blurRadius: Double = 0.0, val color: Color = Black) : Shadow
Link copied to clipboard
abstract class Paint

Used to fill regions when drawing shapes on a Canvas.

Link copied to clipboard

A Canvas used within PatternPaint that does not support perspective rendering. This is done because support for patterns with perspective is very inconsistent for Web.

Link copied to clipboard
class PatternPaint(val bounds: Rectangle, val transform: AffineTransform2D = Identity, val opacity: Float = 1.0f, val paint: PatternCanvas.() -> Unit) : Paint

A Paint that repeats the contents of its Canvas horizontally and vertically within a shape.

Link copied to clipboard

Represents a 3D transform similar to an AffineTransform, but it does not guarantee the preservation of parallel lines. These transforms are used whenever a perspective projection is needed to properly render an item.

Link copied to clipboard
class RadialGradientPaint(val colors: List<GradientPaint.Stop>, val start: Circle, val end: Circle) : GradientPaint

A radial gradient Paint that transitions between a list of Stops.

Link copied to clipboard
interface Renderable

Created by Nicholas Eddy on 2/28/19.

Link copied to clipboard
interface Renderer

Created by Nicholas Eddy on 10/23/17.

Link copied to clipboard
sealed class Shadow(val horizontal: Double, val vertical: Double, val blurRadius: Double, val color: Color)
Link copied to clipboard
class Stroke(val fill: Paint = ColorPaint(Black), val thickness: Double = 1.0, val dashes: DoubleArray? = null, val dashOffset: Double = 0.0, val lineJoint: Stroke.LineJoint? = null, val lineCap: Stroke.LineCap? = null)

Strokes are used to outline regions when drawing shapes on a Canvas.

Link copied to clipboard
class SweepGradientPaint(val colors: List<GradientPaint.Stop>, val center: Point, val rotation: Measure<Angle> = 0 * degrees) : GradientPaint

A Paint based on sweeping a "line" around a center point, through a series of Stops to form what looks like a cone.

Link copied to clipboard
interface TextMetrics

Provides a mechanism to measure the size of various types of text.

Inherited properties

Link copied to clipboard

The height to which the Canvas will clip by default.

Link copied to clipboard

Creates a new ColorPaint from the given Color.

Link copied to clipboard
Link copied to clipboard

The width to which the Canvas will clip by default.

Functions

Link copied to clipboard
fun checkerPaint(checkerSize: Size, firstColor: Color? = null, secondColor: Color? = null): PatternPaint

Creates a PatternPaint that draws a checkered pattern.

Link copied to clipboard
fun horizontalStripedPaint(rowHeight: Double, evenRowColor: Color? = null, oddRowColor: Color? = null): PatternPaint

Creates a PatternPaint that draws an alternating horizontal striped pattern.

Link copied to clipboard
fun lerp(start: Color, end: Color, fraction: Float): Color

Picks a Color that is fraction within the range [start, end] inclusive using linear interpolation.

Link copied to clipboard
fun stripedPaint(stripeWidth: Double, evenRowColor: Color? = null, oddRowColor: Color? = null, transform: AffineTransform2D = Identity): PatternPaint

Creates a PatternPaint that draws an alternating horizontal striped pattern.

Link copied to clipboard
fun verticalStripedPaint(colWidth: Double, evenRowColor: Color? = null, oddRowColor: Color? = null): PatternPaint

Creates a PatternPaint that draws an alternating vertical striped pattern.

Inherited functions

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

Return the angle this transform would apply.

Link copied to clipboard
fun Color.darker(percent: Float = 0.5f): Color

Makes this Color darker by the given percent.

fun HslColor.darker(percent: Float = 0.5f): HslColor

Makes this color darker by the given percent.

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
Link copied to clipboard
@JvmName(name = "callPoint")
inline fun AffineTransform.invoke(points: List<Point>): List<Vector3D>
@JvmName(name = "callPoint")
inline fun AffineTransform2D.invoke(points: List<Point>): List<Point>

Transforms the given points.

Link copied to clipboard
fun Color.lighter(percent: Float = 0.5f): Color

Makes this Color lighter by the given percent.

fun HslColor.lighter(percent: Float = 0.5f): HslColor

Makes this color lighter by the given percent.

Link copied to clipboard
infix fun Color.opacity(value: Float): Color

Creates a new Color like this one except with the given opacity.

Creates a new color like this one except with the given opacity.

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
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
Link copied to clipboard
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.