Package-level declarations

Types

Link copied to clipboard

Implementation of Kanvas which wraps a native Android Canvas.

Link copied to clipboard
Link copied to clipboard
class CGContextKanvas(unmanagedContext: <Error class: unknown class>, width: Double, height: Double)

It is the calling code's responsibility to ensure that unmanagedContext outlives this object.

Link copied to clipboard
sealed class Clip

Describes an area to be included or excluded in future draw calls.

Link copied to clipboard
data class Font(val names: List<String>)

Fonts are provided as a list of family names, in descending priority.

Link copied to clipboard
class HtmlKanvas(element: HTMLCanvasElement, scalingFactor: Float = 1.0f) : Kanvas, IsPointInPath
Link copied to clipboard
Link copied to clipboard
interface IsPointInPath
Link copied to clipboard
interface Kanvas

Something to draw on. Implementations are not required to be safe across multiple threads.

Link copied to clipboard
abstract class KanvasView(context: Context, attrs: AttributeSet? = null) : View

Base class for custom Views implemented using Krayon.

Link copied to clipboard
sealed class Paint

A descriptor for how shapes should be painted.

Link copied to clipboard
class PaintCache(context: Context, initial: Map<Paint, Paint> = emptyMap())
Link copied to clipboard
class Path
Link copied to clipboard
Link copied to clipboard
interface PathBuilder<out P>

Interface used by a PathTypeMarker to generate platform types for Path instances.

Link copied to clipboard
interface PathTypeMarker<P : Any>

Used to bridge the gap between a Path and the platform type required by a Kanvas.

Link copied to clipboard
abstract class RelativePathBuilder<P> : PathBuilder<P>

Handles relative path building when the underlying output type can't.

Link copied to clipboard
class ScaledIsPointInPath(scalingFactor: Float = 1.0f) : IsPointInPath

Unlike other platforms, Android doesn't provide an actual way of checking if a point is contained in a path. Android does, however, allow you to intersect paths. As such, check if a very small rectangle around the actual touch point overlaps with the path.

Link copied to clipboard
sealed class Transform

Represents a transformation. Usually, these will boil down to matrix operations.

Properties

Link copied to clipboard
const val DEFAULT_MITER_LIMIT: Float = 4.0f

Default chosen to match SVG. See https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit

Link copied to clipboard
const val monospace: String
Link copied to clipboard
const val sansSerif: String
Link copied to clipboard
const val serif: String

Functions

Link copied to clipboard
fun addFontAssociation(fontName: String, @FontRes fontRes: Int)

Associate a Font.name to a FontRes id. As a best-practice, do this up front for any fonts that might be used, as calls to addFontAssociation are cheap and the behavior for missing associations is expensive (Resources.getIdentifier).

Link copied to clipboard
fun AndroidKanvas(context: Context, canvas: Canvas, scalingFactor: Float = 1.0f, paintCache: PaintCache = PaintCache(context)): AndroidKanvas

Create an AndroidKanvas.

Link copied to clipboard

Converts a pivoted rotate into an ordered transformation of translate, rotate, translate.

Converts a pivoted scale into an ordered transformation of translate, scale, translate.

Converts a bi-direction skew into an ordered transformation of horizontal skew and vertical skew.

Link copied to clipboard
Link copied to clipboard
inline fun Kanvas.withClip(clip: Clip, actions: Kanvas.() -> Unit)

Invokes actions inside of a Kanvas.pushClip/Kanvas.pop pair.

Link copied to clipboard
inline fun Kanvas.withTransform(transform: Transform, actions: Kanvas.() -> Unit)

Invokes actions inside of a Kanvas.pushTransform/Kanvas.pop pair.