arc.cornerRadius()函數用於設置圓角的拐角半徑。如果半徑未指定,則返回當前角半徑訪問器,其中默認值至:
function cornerRadius() { return 0; }
用法:
arc.cornerRadius([radius]);
參數:該函數接受如上所述和以下描述的單個參數。
- radius:此參數采用一個數字,該數字確定角的半徑。
返回值:這個函數返回電弧發生器。
範例1:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport"
content="width=device-width,
initial-scale=1.0"/>
<!--Fetching from CDN of D3.js -->
<script src=
"https://d3js.org/d3.v6.min.js">
</script>
</head>
<body>
<div style="width:300px; height:300px;">
<center>
<h1 style="color:green">
GeeksforGeeks
</h1>
<h2>
arc.cornerRadius()
</h2>
</center>
<svg width="300" height="300">
</svg>
</div>
<script>
var svg = d3.select("svg")
.append("g")
.attr("transform", "translate(150,200)");
// An arc generator created
var arc = d3.arc()
.outerRadius(-5)
.innerRadius(150)
.startAngle(0)
// Use of cornerRadius Function
.cornerRadius(6666)
.endAngle(1);
svg.append("path")
.attr("class", "arc")
.attr("d", arc);
let p = document.querySelector(".arc");
p.style.fill="green";
</script>
</body>
</html>
輸出:
範例2:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport"
content="width=device-width,
initial-scale=1.0"/>
<!--Fetching from CDN of D3.js -->
<script src=
"https://d3js.org/d3.v6.min.js">
</script>
</head>
<body>
<div style="width:300px; height:300px;">
<center>
<h1 style="color:green">
GeeksforGeeks
</h1>
<h2>
arc.cornerRadius()
</h2>
</center>
<svg width="300" height="300">
</svg>
</div>
<script>
var svg = d3.select("svg")
.append("g")
.attr("transform", "translate(120,200)");
// An arc generated
var arc = d3.arc()
.outerRadius(140)
.innerRadius(200)
.startAngle(0)
// Use of cornerRadius Function
.cornerRadius(20)
.endAngle(1);
svg.append("path")
.attr("class", "arc")
.attr("d", arc);
let p = document.querySelector(".arc");
p.style.fill="green";
</script>
</body>
</html>
輸出:
相關用法
- PHP Ds\Set xor()用法及代碼示例
- p5.js value()用法及代碼示例
- d3.js d3.sum()用法及代碼示例
- p5.js pan()用法及代碼示例
- PHP max( )用法及代碼示例
- d3.js d3.mean()用法及代碼示例
- PHP ord()用法及代碼示例
- d3.js d3.min()用法及代碼示例
- p5.js nfs()用法及代碼示例
- p5.js nf()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- p5.js nfc()用法及代碼示例
- p5.js nfp()用法及代碼示例
- d3.js now()用法及代碼示例
- PHP Ds\Set last()用法及代碼示例
- PHP Ds\Set add()用法及代碼示例
注:本文由純淨天空篩選整理自tarun007大神的英文原創作品 D3.js arc.cornerRadius() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。