Closed Sruimeng closed 3 weeks ago
The updates enhance the TextItem
class by adding a lineCount
property to track the number of text lines, a method to calculate this count, and tweaks to the rendering logic for proper vertical alignment. Changes to TextLayout
accompany these updates, refining the offset computation to consider the line count, ensuring more precise text rendering.
File | Change Summary |
---|---|
.../text-item.ts |
Introduced lineCount property, getLineCount method, and updated setText and renderText methods. |
.../text-layout.ts |
Updated getOffsetY method to include lineCount and lineHeight parameters for accurate offset calculation. |
sequenceDiagram
participant TextItem as TextItem
participant TextLayout as TextLayout
participant Canvas as Canvas
TextItem->>TextItem: setText(value)
TextItem->>TextItem: getLineCount(value)
TextItem-->>TextItem: Update lineCount
TextItem->>Canvas: Prepare text for rendering
TextItem->>TextLayout: getOffsetY(style, lineCount, lineHeight)
TextLayout-->>TextItem: Return calculated offsetY
TextItem-->>Canvas: Render text with updated offset and line count
Once a text sat flat and square,
But lines now counted, floating in air,
With offsets true, they rose anew,
Aligned and shining, a brilliant view.
The canvas smiles, no longer askew,
For code's art paints precision through.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Summary by CodeRabbit