Scoop API

scoop:scoop.ui:0.1.0

src/text/draw.scoop

Selected production source · src/text/draw.scoop

1package scoop.ui.text
3import scoop.graphics.Rect
4import scoop.graphics.Point
5import scoop.graphics.text.TextLayout
6import scoop.graphics.text.drawText
7import scoop.ui.*
9/** Paints an owned layout with the same source-over recording path as paragraph controls. */
10public 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.paintBounds
17 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.0
24 ),
25 revision
26 ) { paint -> paint.canvas.drawText(layout, origin) }
29/** Retain source-over text commands without introducing an offscreen compositing layer. */
30internal fun SceneContext.drawTextLayer(
31 key: PaintKey,
32 bounds: Rect,
33 revision: Long,
34 block: (PaintContext) -> Unit
35) {
36 if (retainsTextDrawing)
37 drawRecording(key, bounds, revision, 1.0, PaintComposition.SourceOver, block)
38 else
39 draw(block)