ReaderTheme

class ReaderTheme(val background: RgbColor, val mapColor: (RgbColor) -> RgbColor, val images: ReaderImages)(source)

A reading theme: a page background plus a mapColor transform applied to every text / vector / border / CSS-background colour a page paints. Images and gradients pass through untouched, so photos never invert. withImages lets the theme recolour the images that are line art too.

Dark and Sepia keep text readable: a colour with a contrast of 4.5 or more on white paper keeps at least 4.5 on the theme's paper, and a weaker colour keeps the contrast it had (WCAG 2.2, 1.4.3).

Format-neutral: it themes any KiteCanvas (PDF or EPUB). Hand a theme to a rasterizer, or wrap a canvas yourself:

page.renderTo(ReaderTheme.Dark.wrap(canvas), ctm)   // paint background yourself

Two themes are equal when they share the paper colour and the same colour function, so a theme built inline with a lambda that captures nothing stays one cache key across recompositions.

Constructors

Link copied to clipboard
constructor(background: RgbColor, mapColor: (RgbColor) -> RgbColor, images: ReaderImages)
constructor(background: RgbColor, mapColor: (RgbColor) -> RgbColor)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Paper colour behind the page content.

Link copied to clipboard

What the theme does to images: ReaderImages.Unchanged unless withImages says otherwise (#458).

Link copied to clipboard

Maps each content colour a page draws. Identity for Light.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard

This theme, doing images to the images of a page. With ReaderImages.LineArt, a black symbol on white turns as light as the text on dark paper, and a photo keeps its colours:

Link copied to clipboard
fun wrap(canvas: KiteCanvas): KiteCanvas

Decorate canvas so its content colours are themed. Returns it unchanged for Light.