Skip to content

KBE3D / KBCore / Cesium / writeTextToCanvas

函数: writeTextToCanvas()

writeTextToCanvas(text: string, options?: { font?: string; fill?: boolean; stroke?: boolean; fillColor?: Color; strokeColor?: Color; strokeWidth?: number; backgroundColor?: Color; padding?: number; }): HTMLCanvasElement | undefined

Writes the given text into a new canvas. The canvas will be sized to fit the text. If text is blank, returns undefined.

参数

text

string

The text to write.

options?

Object with the following properties:

font?

string

The CSS font to use.

fill?

boolean

Whether to fill the text.

stroke?

boolean

Whether to stroke the text.

fillColor?

Color

The fill color.

strokeColor?

Color

The stroke color.

strokeWidth?

number

The stroke width.

backgroundColor?

Color

The background color of the canvas.

padding?

number

The pixel size of the padding to add around the text.

返回

HTMLCanvasElement | undefined

A new canvas with the given text drawn into it. The dimensions object from measureText will also be added to the returned canvas. If text is blank, returns undefined.

KBE3D @3.0.0 Copyright © 2024-present KBE3D