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 HTML5
The path() method is used for creating a path element for the specified jqxDraw widget.
Syntax:
var path = Instance.path(path, attributes);
Parameters: This method accepts two parameters that are illustrated below:
- path: This path parameter accepts some line commands such as “MoveTo: M x,y”, “LineTo: L x,y”, “Cubic curve: C x1,y1,x2,y2,x,y”, and “Close path: Z”
- attributes: This is the specified attribute.
Return values: This method returns the path 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 path() Method.
<!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 path() Method</ h3 >
< div id = "jqx_Draw"
style = "height:200px; width:700px;" >
</ div >
< input type = "button" id = "Button" style = "padding:5px 15px; margin-top:40px;" value = "Create the path element" >
< div id = "log" ></ div >
< script type = "text/javascript" >
$(document).ready(function () {
$('#jqx_Draw').jqxDraw({
renderEngine: 'HTML5'
});
var Instance =
$('#jqx_Draw').jqxDraw('getInstance');
$("#Button").click(function () {
// Creating a path with Supported
// line commands
// MoveTo: M x,y (Here, M 150, 150)
// LineTo: L x,y (Here, L 250, 270)
// Cubic curve: C x1,y1,x2,y2,x,y
// (Here, C 250, 220 280, 270 250, 250)
// Close path: Z
// Parameter for filling with green color
var path = Instance.path(
"M 150, 150 L 250, 270 C 250, 220 280, 270 250, 250", {
fill: 'green'
});
Instance.refresh();
});
});
</ script >
</ center >
</ body >
</ html >
|
Output:
Reference: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxdraw/jquery-draw-api.htm