d3.path.quadraticCurveTo()函數用於通過特定控製點從當前點將二次貝塞爾曲線段繪製到特定點。
用法:
path.quadraticCurveTo(cpx, cpy, x, y)
參數:它采用上麵給出和下麵描述的四個參數。
- cpx:它是二次控製點的x坐標。
- cpy:它是二次控製點的y坐標。
- x:它是終點的x坐標。
- y:它是終點的y坐標。
範例1:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" path1tent=
"width=device-width,initial-scale=1.0">
<script src=
"https://d3js.org/d3.v4.min.js">
</script>
<style>
h1 {
color:green;
}
svg {
background-color:#f2f2f2;
}
.path2 {
stroke:#000;
}
</style>
</head>
<body>
<div>
<h1>GeeksforGeeks</h1>
<b>D3.js | Path.quadraticCurveTo() Function</b>
<br><br>
<svg width="100" height="100">
<path class="path2">
</svg>
</div>
<script>
// Creating a path
var path = d3.path();
path.moveTo(50, 50);
path.quadraticCurveTo(95, 0, 50, 90)
// Closing the path
path.closePath();
path.quadraticCurveTo(5, 0, 50, 90)
// Closing the path
path.closePath();
d3.select(".path2").attr("d", path);
</script>
</body>
</html>
輸出:
範例2:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" path1tent=
"width=device-width,initial-scale=1.0">
<script src=
"https://d3js.org/d3.v4.min.js">
</script>
<style>
h1 {
color:green;
}
svg {
background-color:#f2f2f2;
}
.path2 {
stroke:#000;
}
</style>
</head>
<body>
<div>
<h1>GeeksforGeeks</h1>
<b>D3.js | Path.quadraticCurveTo() Function</b>
<br><br>
<svg width="100" height="100">
<path class="path2">
</svg>
</div>
<script>;
// Creating a path
var path = d3.path();
path.moveTo(10, 10);
path.quadraticCurveTo(95, 0, 50, 90)
// Closing the path
path.closePath();
d3.select(".path2").attr("d", path);
</script>
</body>
</html>
輸出:
相關用法
- HTML canvas quadraticCurveTo()用法及代碼示例
- PHP imagecreatetruecolor()用法及代碼示例
- p5.js year()用法及代碼示例
- d3.js d3.utcTuesdays()用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP Ds\Sequence last()用法及代碼示例
- PHP array_udiff_uassoc()用法及代碼示例
- PHP geoip_continent_code_by_name()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- PHP GmagickPixel setcolor()用法及代碼示例
- PHP opendir()用法及代碼示例
- PHP cal_to_jd()用法及代碼示例
- d3.js d3.bisectLeft()用法及代碼示例
- PHP stream_get_transports()用法及代碼示例
注:本文由純淨天空篩選整理自tarun007大神的英文原創作品 D3.js quadraticCurveTo() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。