jQWidgets jqxDraw rect() Method
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 rect() method is used for creating a rectangle element for the specified jqxDraw widget.
Syntax:
var rectElement = renderer.rect(x, y, width, height, attributes);
Parameters: This method accepts five parameters that are illustrated below:
- x: This is the x-coordinate for the rectangle element.
- y: This is the y-coordinate for the rectangle element.
- width: This is the width of the rectangle element.
- height: This is the height of the rectangle element.
- attributes: This is the specified attributes for the rectangle element.
Return values: This method returns the rectangle 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 rect() 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 rect() Method</ h3 >
< div id = "jqx_Draw"
style = "height:200px; width:280px;" >
</ div >
< input type = "button" id = "Button"
style = "padding:5px 15px; margin-top:40px;"
value = "Create a rectangle 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.rect(20, 20, 180, 120,
{ fill: 'green' });
Instance.refresh();
});
});
</ script >
</ center >
</ body >
</ html >
|
Output:
jQWidgets jqxDraw rect() Method
Reference: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxdraw/jquery-draw-api.htm
Last Updated :
31 Jan, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...