当前位置:网站首页>N-degree Bessel curve
N-degree Bessel curve
2022-06-12 06:07:00 【Rulelur】
n Recursion formula of subbezier curve :
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.translate(10, 10); // Remap... On canvas (0,0) Location , Avoid spillovers
function drawCircle(x, y, color, r = 6) {
ctx.fillStyle = color;
ctx.beginPath();
ctx.arc(x, y, r, 0, 2 * Math.PI);
ctx.fill();
}
function drawPath(path) {
ctx.beginPath();
path.forEach((p, i) => {
if (i) {
ctx.lineTo(p.x, p.y);
} else {
ctx.moveTo(p.x, p.y);
}
});
ctx.stroke();
}
function bezier(pointList, t) {
if (pointList.length === 1) {
return pointList[0];
} else {
// B(t)=(1-t)Bp0p1…pn-1(t) + tBp1p2…pn(t)
var p1 = bezier(pointList.slice(0, -1), t);
var p2 = bezier(pointList.slice(1), t);
var p = {
x: (1 - t) * p1.x + t * p2.x,
y: (1 - t) * p1.y + t * p2.y,
};
return p;
}
}
var startPoint = { x: 0, y: 0 };
var endPoint = { x: 900, y: 0 };
var pointList = [
startPoint,
// In the middle is the control point
{ x: 300, y: 0 },
{ x: 400, y: 100 },
{ x: 600, y: 200 },
{ x: 700, y: 0 },
endPoint,
];
// draw a curve
var path = [];
for (var i = 0; i <= 100; i++) {
path.push(bezier(pointList, i / 100));
}
drawPath(path);
// Red start and end points
[startPoint, endPoint].forEach((p) => {
drawCircle(p.x, p.y, "red");
});
// Blue control point
pointList.slice(1, -1).forEach((p) => {
drawCircle(p.x, p.y, "blue");
});
Final effect

边栏推荐
- User login 【 I 】
- About why GPU early-z reduces overdraw
- China Aquatic Fitness equipment market trend report, technical innovation and market forecast
- Unity3d display FPS script
- RNN model
- Leetcode-1663. Minimum string with given value
- C # converts the hexadecimal code form of text to text (ASCII)
- IBL of directx11 advanced tutorial PBR (3)
- zip 和.items()区别
- Book classification based on Naive Bayes
猜你喜欢

IBL of directx11 advanced tutorial PBR (3)

Why doesn't the database use binary tree, red black tree, B tree and hash table? Instead, a b+ tree is used

Houdini terrain creation

Word vector training based on nnlm

夜神模拟器adb查看log

. Net core - pass Net core will Net to cross platform

Logistic regression model

MySQL master-slave, 6 minutes to master

前台展示LED数字(计算器上数字类型)

Data integration framework seatunnel learning notes
随机推荐
On the normalization of camera rotation interpolation
(UE4 4.27) add globalshder to the plug-in
Guns framework multi data source configuration without modifying the configuration file
Using hidden Markov model to mark part of speech
nRF52832自定義服務與特性
Jpg format and XML format files are separated into different folders
Brief summary of software project architecture
Leetcode-93. Restore IP address
Front desk display LED number (number type on calculator)
dlib 人脸检测
Data integration framework seatunnel learning notes
R语言大作业(四):上海市、东京 1997-2018 年GDP值分析
Leetcode-2048. Next larger numerical balance
Brief introduction to project development process
Quickly master makefile file writing
The application could not be installed: INSTALL_ FAILED_ TEST_ ONLY
IO to IO multiplexing from traditional network
Why doesn't the database use binary tree, red black tree, B tree and hash table? Instead, a b+ tree is used
Redis队列
UE4 4.27 modify the mobile forward pipeline to support cluster multi light source culling