画箭扬程曲线,我试图提取低于3个箭头。我可以正确绘制顶部,但无法正确绘制其他2个箭头。我使用HTML5 Canvas绘制这些箭头。在HTML5画布
的问题时我包含arcTo电话。由于某些原因,我无法获得正确的曲线。也许我应该使用贝塞尔曲线? 任何人都可以告诉我用什么HTML5/Javascript函数来生成上面的箭头?
你能否提供了如何实现上述箭头头的例子吗?
继承人的的jsfiddle显示怎么回事错误:http://jsfiddle.net/hJX8X/
<canvas id="testCanvas" width="400px" height="400px">
</canvas>
<script type="text/javascript">
<!--
var canvas = document.getElementById("testCanvas");
var dc = canvas.getContext("2d");
// Points which are correct (when I draw straight lines its a perfect arrow
var width = 400;
var height = 100;
var arrowW = 0.35 * width;
var arrowH = 0.75 * height;
var p1 = {x: 0, y: (height-arrowH)/2};
var p2 = {x: (width-arrowW), y: (height-arrowH)/2};
var p3 = {x: (width-arrowW), y: 0};
var p4 = {x: width, y: height/2};
var p5 = {x: (width-arrowW), y: height};
var p6 = {x: (width-arrowW), y: height-((height-arrowH)/2)};
var p7 = {x: 0, y: height-((height-arrowH)/2)};
dc.clearRect(0, 0, canvas.width, canvas.height);
dc.fillStyle = "#FF0000";
dc.beginPath();
dc.moveTo(p1.x, p1.y);
dc.lineTo(p2.x, p2.y);
dc.lineTo(p3.x, p3.y);
dc.moveTo(p3.x, p3.y);
dc.arcTo(p3.x, p3.y, p4.x, p4.y, 50);
dc.moveTo(p4.x, p4.y);
dc.arcTo(p4.x, p4.y, p5.x, p5.y, 50);
dc.moveTo(p5.x, p5.y);
dc.lineTo(p6.x, p6.y);
dc.lineTo(p7.x, p7.y);
dc.closePath();
dc.fill();
/* Draw arrow without curves
dc.moveTo(p1.x, p1.y);
dc.lineTo(p2.x, p2.y);
dc.lineTo(p3.x, p3.y);
dc.lineTo(p4.x, p4.y);
dc.lineTo(p5.x, p5.y);
dc.lineTo(p6.x, p6.y);
dc.lineTo(p7.x, p7.y);
*/
-->
</script>
可以提供@rkmax我已经发布了的jsfiddle预期的结果 – rkmax 2012-01-16 04:05:20
的例子(图)现在证明我的努力,箭头太蹲下 – 2012-01-16 04:12:53