scoop:scoop.ui:0.1.0
src/text/draw.scoop
Selected production source · src/text/draw.scoop
1
package scoop.ui.text3
import scoop.graphics.Rect4
import scoop.graphics.Point5
import scoop.graphics.text.TextLayout6
import scoop.graphics.text.drawText7
import scoop.ui.*9
/** Paints an owned layout with the same source-over recording path as paragraph controls. */10
public fun SceneContext.drawTextLayout(11
key: PaintKey,12
layout: TextLayout,13
revision: Long,14
origin: Point = Point(0.0, 0.0)15
) {16
val bounds = layout.paintBounds17
drawTextLayer(18
key,19
Rect(20
bounds.x + origin.x - 1.0,21
bounds.y + origin.y - 1.0,22
bounds.width + 2.0,23
bounds.height + 2.024
),25
revision26
) { paint -> paint.canvas.drawText(layout, origin) }27
}29
/** Retain source-over text commands without introducing an offscreen compositing layer. */30
internal fun SceneContext.drawTextLayer(31
key: PaintKey,32
bounds: Rect,33
revision: Long,34
block: (PaintContext) -> Unit35
) {36
if (retainsTextDrawing)37
drawRecording(key, bounds, revision, 1.0, PaintComposition.SourceOver, block)38
else39
draw(block)40
}