나는 요소에 착수하기로 하루를 결심했으며, 지금까지는 그것이 작동하도록 악몽이었습니다. 내가 원하는 것은 사인 그래프를 그릴뿐입니다. 그래서 좋은 독서 후에 나는 아직도 기원을 얻지도 못하고 음모를 얻지도 못합니다. 아래는 내가 시도한 것입니다 (처음으로 그 태그를 사용하여 내 무지를 용서할 수 있습니다). 나를 궁금하게 만드는 것은 the guy here이지만 코드는 나처럼 초보자에게는 이해하기 어렵다.HTML5 캔버스로 플로팅
HTML
<!DOCTYPE html>
<html>
<head>
<title>Graphing</title>
<link type="text/css" rel="Stylesheet" href="graph.css" />
<script type="text/JavaScript" src="graph.js" ></script>
</head>
<body>
<canvas id="surface">Canvas not Supported</canvas>
</body>
</html>
의 범위 이후 CSS
#surface
{
width:300;
height:225;
border: dotted #FF0000 1px;
}
에 javscript
window.onload = function()
{
var canvas = document.getElementById("surface");
var context = canvas.getContext("2d");
arr = [0,15, 30,45,60, 90,105, 120, 135, 150, 165, 180 ];
var x=0;
var y = 0;
for(i=0; i<arr.length; i++)
{
angle = arr[i]*(Math.PI/180); //radians
sine = Math.sin(angle);
context.moveTo(x,y);
context.lineTo(angle,sine);
context.stroke();
//set current varibles for next move
x = angle;
y = sine;
}
}
여기에서이 답변을 확인하십시오. 계속 진행할 수있는 내용이 있어야합니다. http://stackoverflow.com/questions/6032998/how-to-draw-a-curve-that-could-move-to-left-with -canvas –
코드를 제외한 일부 html 요소로 jsfiddle을 생성 할 수있었습니다. 여기를 보아라. http://jsfiddle.net/franktudor/4wv9r/ –
글쎄, 'sin'의 도메인은 -1과 1 사이입니다. 그래서 당신은 점만 볼 수 있습니다. –