2017-03-06 4 views

答えて

0

あなたは、線や円を描くようにHTML5 Canvasを使用することができます。

Exmaple:

function drawCircle(ctx, x, y, r){ 
 
    ctx.beginPath(); 
 
    ctx.arc(x,y,r,0,2*Math.PI); 
 
    ctx.fillStyle = 'white'; 
 
    ctx.fill(); 
 
    ctx.stroke(); 
 
} 
 

 
function drawLine(ctx, fromX, fromY, toX, toY){ 
 
    ctx.moveTo(fromX,fromY); 
 
    ctx.lineTo(toX,toY); 
 
    ctx.stroke(); 
 
} 
 

 
function drawCircleAndLine(ctx, fromX, fromY, toX, toY, r){ 
 
\t drawLine(ctx, fromX, fromY, toX, toY); 
 
\t drawCircle(ctx, fromX, fromY, r); 
 
    drawCircle(ctx, toX, toY, r); 
 

 
} 
 

 
var c = document.getElementById("myCanvas"); 
 
var ctx = c.getContext("2d"); 
 

 
//Defines your node here 
 
drawCircleAndLine(ctx, 300, 100, 400, 200, 40); 
 
drawCircleAndLine(ctx, 300, 100, 200, 200, 40); 
 
drawCircleAndLine(ctx, 400, 200, 500, 300, 40); 
 
drawCircleAndLine(ctx, 200, 200, 100, 300, 40);
<canvas id="myCanvas" width="600" height="400" style="border:1px solid #d3d3d3;"> 
 
Your browser does not support the HTML5 canvas tag.</canvas>

JSフィドル:https://jsfiddle.net/5cp4pzL9/

+0

ありがとうございます.. – Shahnawaz

0
margin-left: 100px; 
height: 109px; 
background-color: red; 
width: 3px; 
-ms-transform: rotate(20deg); 
/* -webkit-transform: rotate(20deg); */ 
transform: rotate(29deg); 
+0

このコードスニペットは、([説明を含む]問題を解決できるがhttp://meta.stackexchange.com/質問/ 114762/explain-entire-code-based-answers)は本当にあなたの投稿の質を向上させるのに役立ちます。将来読者の質問に答えていることを覚えておいてください。そうした人々はあなたのコード提案の理由を知らないかもしれません。 –

関連する問題