abstract class Tessell::Kit::Painter

Overview

绘制契约(issue #15, Painter 实现与宿主必须共同遵守):

  1. z-order:调用顺序即绘制顺序。text 与形状命令可任意交错,后提交者 覆盖先提交者——「先画文字再画不透明覆盖层」必须能盖住文字。 宿主禁止把文本收集后统一放到形状之后上屏(那会把 z-order 变成 「所有形状 → 所有文本」)。
  2. clip:push_clip/pop_clip 同时约束形状与文本;嵌套 clip 取交集。 滚动容器边缘的文本由后端 scissor 裁切,组件不得依赖“只发完全可见 文本”的 workaround。
  3. 文本基线:text(x, baseline_y, ...) 的坐标是基线起点(y-down), 与 Render::TextRenderer 的顶点生成约定一致。

Direct Known Subclasses

Defined in:

tessell/kit/painter.cr

Instance Method Summary

Instance Method Detail

abstract def fill_rect(rect : Rect, color : UInt32) : Nil #

[View source]
abstract def fill_round_rect(rect : Rect, radius : Float32, color : UInt32) : Nil #

[View source]
abstract def image(texture_id : Int32, bounds : Rect, tint : UInt32 = 4294967295_u32, src : Rect | Nil = nil) : Nil #

外部纹理四边形(issue #28):texture_id 来自 Backend#create_texture (独立命名空间);tint 默认全白 = 原样;src 缺省 = 整图(后端按 纹理尺寸换算 uv)。


[View source]
abstract def line(x1 : Float32, y1 : Float32, x2 : Float32, y2 : Float32, color : UInt32, width : Float32 = 1.0_f32) : Nil #

[View source]
abstract def pop_clip : Nil #

[View source]
abstract def push_clip(rect : Rect) : Nil #

[View source]
abstract def stroke_rect(rect : Rect, color : UInt32, width : Float32 = 1.0_f32) : Nil #

[View source]
abstract def stroke_round_rect(rect : Rect, radius : Float32, color : UInt32, width : Float32 = 1.0_f32) : Nil #

[View source]
abstract def text(x : Float32, baseline_y : Float32, text : String, color : UInt32, size : Float32, font_id : Int32 = 0) : Nil #

[View source]