Open In App

jQWidgets jqxDraw text() Method

Last Updated : 31 Jan, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

jQWidgets is a JavaScript framework for making web-based applications for PC and mobile devices. It is a very powerful, optimized, platform-independent, and widely supported framework. The jqxDraw is a small jQuery-based plugin that is used to draw shapes and texts using VML, SVG, and HTML.

The text() method is used for creating a text element for the specified jqxDraw widget.

Syntax:

renderer.text(
    text, x, y, width, height, angle, 
    attributes, clip, halign, valign, rotateAround
); 

Parameters: This method accepts some parameters that are illustrated below:

  • text: This is the specified text element.
  • x: This is the x-coordinate for the text element.
  • y: This is the y-coordinate for the text element.
  • width: This is the width of the text element.
  • height: This is the height of the text element.
  • angle: This is the angle for the rotation of the text element.
  • attributes: This is the specified attribute for the text element.
  • clip: This says whether the clipping of the text element is required or not.
  • halign: This is the horizontal alignment of the text element.
  • valign: This is the vertical alignment of the text element.
  • rotateAround: This is the orientation around which rotation is being done.

Return values: This method returns the text element object.

Linked Files: Download jQWidgets from the given link. In the HTML file, locate the script files in the downloaded folder.

<link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<script type=”text/javascript” src=”scripts/jquery.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxdraw.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqx-all.js”></script>

Example: The below example illustrates the jQWidgets jqxDraw text() Method.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <link rel="stylesheet" href=
          "jqwidgets/styles/jqx.base.css" 
          type="text/css" />
    <script type="text/javascript" src=
            "scripts/jquery-1.11.1.min.js">
    </script>
    <script type="text/javascript" src=
            "jqwidgets/jqxcore.js">
    </script>
    <script type="text/javascript" src=
            "jqwidgets/jqxdraw.js">
    </script>
    <script type="text/javascript" src=
            "jqwidgets/jqx-all.js">
    </script>
</head>
  
<body>
    <center>
        <h1 style="color:green;">
            GeeksforGeeks
        </h1>
        <h3>jQWidgets jqxDraw text() Method</h3>
        <div id="jqx_Draw" 
             style="height:200px; width:280px;">
        </div>
        <input type="button" id="Button" 
               style="padding:5px 10px; margin-top:5px;" 
               value="Create a text element">
        <div id="log"></div>
        <script type="text/javascript">
            $(document).ready(function () {
                $('#jqx_Draw').jqxDraw();
                var Instance = 
                    $('#jqx_Draw').jqxDraw('getInstance');
                $("#jqx_Draw").jqxButton();
                $("#Button").click(function () {
                    Instance.text(
                        "GFG is a CS Portal",
                        60, 50, 50, 60, 30,
                        { fill: 'green' }, false,
                        'top', 'top', 'left');
                    Instance.refresh();
                });
            });
        </script>
    </center>
</body>
  
</html>


Output:

jQWidgets jqxDraw text() Method

jQWidgets jqxDraw text() Method

Reference: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxdraw/jquery-draw-api.htm



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads