畫箭揚程曲線,我試圖提取低於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