我想绘制任何(随机)曲线,给定:
- 起点
- 终点
- 曲线长度
我怎么能做这种受画布边界限制的事情,加上曲线不能交叉。我试图找到一些解决方案,但我无法弄清楚。谢谢你的时间。
这是我想要完成的更详细的视图:
这是画在画布上的二次曲线。一切安好。问题是,如何在没有所有点的情况下绘制这个,只需以像素为单位的固定长度、随机点、受画布大小和不交叉的限制。
代码可能如下所示:
function fixedCurve( A, B, length ){
for(int i = A; i < B; i++){
//Calculate random point with propper distance to get first base point, random direction could be calculated before loop.
//Basicly this loop should calculate integrate of the curve and draw it each step.
}
}