Edit this page

kendo.drawing.TextInherits from kendo.drawing.Element

Draws a single line of text at the given position.

Example - creating a text

<div id="surface"></div>
<script>
    var draw = kendo.drawing;
    var geom = kendo.geometry;

    var position = new geom.Point(10, 10);
    var text = new draw.Text("Foo", position);

    var surface = draw.Surface.create($("#surface"));
    surface.draw(text);
</script>

Constructor Parameters

content String

The content of the text. Special characters are not supported.

position kendo.geometry.Point

The position of the text upper left corner.

options Object

The configuration options.

Configuration

clip kendo.drawing.Path

The element clipping path. Inherited from Element.clip

cursor String

The element cursor. Inherited from Element.cursor

fill kendo.drawing.FillOptions

The fill options of the text.

font String

The font to use for rendering the text. Accepts the standard CSS font syntax.

Examples of valid font values:

  • Size and family: "2em 'Open Sans', sans-serif"
  • Style, size and family: "italic 2em 'Open Sans', sans-serif"

opacity Number

The element opacity. Inherited from Element.opacity

stroke kendo.drawing.StrokeOptions

The stroke options of the text.

tooltip kendo.drawing.TooltipOptions

The tooltip options of the shape.

transform kendo.geometry.Transformation

The transformation to apply to this element. Inherited from Element.transform

visible Boolean

A flag, indicating if the element is visible. Inherited from Element.visible

Methods

bbox

Returns the bounding box of the element with transformations applied. Inherited from Element.bbox

Returns

kendo.geometry.Rect The bounding box of the element with transformations applied.

clip

Gets or sets the element clipping path. Inherited from Element.clip

Parameters

clip kendo.drawing.Path

The element clipping path.

Returns

kendo.drawing.Path The current element clipping path.

clippedBBox

Returns the bounding box of the element with clipping and transformations applied. Inherited from Element.clippedBBox

Returns

kendo.geometry.Rect The bounding box of the element with clipping transformations applied.

containsPoint

Returns true if the shape contains the specified point.

Parameters

point kendo.geometry.Point

The point that should be checked.

Returns

Boolean value indicating if the shape contains the point.

content

Gets or sets the text content.

Example - change content

<div id="surface"></div>
<script>
    var draw = kendo.drawing;
    var geom = kendo.geometry;

    var position = new geom.Point(10, 10);
    var text = new draw.Text("", position);

    var surface = draw.Surface.create($("#surface"));
    surface.draw(text);

    setInterval(function() {
        text.content(kendo.toString(new Date(), "T"));
    }, 1000);
</script>

Parameters

value String

The new text content to set.

Returns

String The current content of the text.

fill

Sets the text fill.

Parameters

color String

The fill color to set.

opacity Number optional

The fill opacity to set.

Returns

kendo.drawing.Text The current instance to allow chaining.

opacity

Gets or sets the element opacity. Inherited from Element.opacity

If set, the stroke and fill opacity will be multiplied by the element opacity.

Parameters

opacity Number

The element opacity. Ranges from 0 (completely transparent) to 1 (completely opaque).

Returns

Number The current element opacity.

position

Gets or sets the position of the text upper left corner.

Example - change position

<div id="surface"></div>
<script>
    var draw = kendo.drawing;
    var geom = kendo.geometry;

    var position = new geom.Point(10, 10);
    var text = new draw.Text("Foo", position);

    var surface = draw.Surface.create($("#surface"));
    surface.draw(text);

    setTimeout(function() {
        text.position([20, 20]);
    }, 1000);
</script>

Parameters

value kendo.geometry.Point

The new position of the text upper left corner.

Returns

kendo.geometry.Point The current position of the text upper left corner.

stroke

Sets the text stroke.

Parameters

color String

The stroke color to set.

width Number optional

The stroke width to set.

opacity Number optional

The stroke opacity to set.

Returns

kendo.drawing.Text The current instance to allow chaining.

transform

Gets or sets the transformation of the element. Inherited from Element.transform

Parameters

transform kendo.geometry.Transformation

The transformation to apply to the element.

Returns

kendo.geometry.Transformation The current transformation on the element.

visible

Gets or sets the visibility of the element. Inherited from Element.visible

Parameters

visible Boolean

A flag indicating if the element should be visible.

Returns

Boolean true if the element is visible; false otherwise.

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy