Canvas2dCanvas

KiteCanvas backed by a browser-side CanvasRenderingContext2D. Pure Kotlin/JS + DOM: no Compose for Web, no Skia/WASM bundle.

The right choice for in-browser PDF viewers that want minimal bundle size and to inherit whatever rendering acceleration the browser already provides for <canvas>.

Honest scope:

  • Path operations, gradients, blend modes (all 16), clipping, transparency groups, soft masks: ✅ rendered via the standard Canvas2D API.

  • Embedded image XObjects: ⚠️ JPEG / JP2 are decoded asynchronously by the browser (HTMLImageElement.src = …), which doesn't fit the renderer's synchronous draw pass. v1 paints placeholders for image XObjects; an async render path is roadmapped.

Constructors

Link copied to clipboard
constructor(ctx: CanvasRenderingContext2D)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open override fun applySoftMask(kind: SoftMask.Kind, maskBBox: Rectangle, maskCtm: Matrix, render: () -> Unit, renderMask: (KiteCanvas) -> Unit)
Link copied to clipboard
open override fun beginPage(widthPt: Double, heightPt: Double, deviceCtm: Matrix)
Link copied to clipboard
open override fun beginTransparencyGroup(bbox: Rectangle, ctm: Matrix, isolated: Boolean, knockout: Boolean, alpha: Double, blendMode: BlendMode)
Link copied to clipboard
open override fun drawGlyphs(glyphs: List<TextGlyph>, fontSize: Double, unitsPerEm: Int, hasOutlines: Boolean, fontSpec: FontSpec, textToDevice: Matrix, color: RgbColor, alpha: Double, blendMode: BlendMode)
Link copied to clipboard
open override fun drawImage(image: ImageXObject, ctm: Matrix, alpha: Double)
Link copied to clipboard
open override fun endPage()
Link copied to clipboard
open override fun endTransparencyGroup()
Link copied to clipboard
open override fun fillPath(path: KitePath, ctm: Matrix, color: RgbColor, evenOdd: Boolean, alpha: Double, blendMode: BlendMode)
Link copied to clipboard
open override fun fillShading(shading: KiteShading, ctm: Matrix, clipPath: KitePath?, alpha: Double, blendMode: BlendMode)
Link copied to clipboard
open override fun popClip()
Link copied to clipboard
open override fun pushClip(path: KitePath, ctm: Matrix, evenOdd: Boolean)
Link copied to clipboard
open override fun strokePath(path: KitePath, ctm: Matrix, color: RgbColor, lineWidth: Double, alpha: Double, blendMode: BlendMode, dashArray: List<Double>?, dashPhase: Double, lineCap: Int, lineJoin: Int, miterLimit: Double)