A. 실시간 대수 그래프 그리기
Input element에 LaTeX 문법으로 대수식을 적으면 실시간으로 캔버스에 그 그래프가 그려지도록 합니다.
- 실행 결과
- 코드 보기
<html>
<head>
<script
src="https://www.mathcore.co.kr/api/libs/latest/helper.js"
defer
onload="onLoadHelper();"
></script>
<script>
async function onLoadHelper() {
await mathcore.helper.load("math2d", {
key: "TESTKEY"
});
const math2d = new mathcore.math2d.Math2D();
math2d.render("math2d");
const input = document.getElementById("input");
input.value = "y=e^{2x-1}";
const algebraric = math2d.objectManager.factory.algebraric(input.value);
input.addEventListener("input", (e) => {
algebraric.expr = e.target.value;
});
}
</script>
</head>
<body>
<div id="math2d"></div>
<input id="input" type="text"></input>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
display: flex;
flex-direction: column;
overflow: hidden;
}
#math2d {
position: relative;
flex: 1;
height: 100%;
}
input {
height: 60px;
margin-top: 10px;
padding: 0 20px;
font-size: 17px;
font-family: 'KaTeX';
}
</style>
</body>
</html>