yarn
yarn build
使用插件Live Server打开 static/index.html 查看效果
舞台:canva 的生成函数,所返回对象维护了 canvas 的基本信息
const stage = new StageImpl();
stage.setScale(100);
线:通过点的描绘练成线段,以函数作为主要参数
// 二次函数
const er = new LineImpl((x) => x * x, null, stage);
er.draw();
// sin
const sin = new LineImpl((x) => Math.sin(x), null, stage);
sin.setCtx({ strokeStyle: "red" });
sin.draw();
// cos
const cos = new LineImpl((y) => Math.cos(y), null, stage);
cos.draw();
标准网格坐标系:继承于 Line,增加绘制网格,绘制尺度,绘制坐标轴方法
const coordAxis = new CoordAxisImpl(stage);
// 直接构建
coordAxis.build();
// 或者
coordAxis.generateAxis().generateGrid().generateRuling()
向量:一种抽象的数据结构,将于标准坐标系联动
let v = new VectorImpl(-15, -20);
矩阵:一种抽象的数据结构,与向量联动
const m1 = new MatrixImpl([1, 4], [2, 5], [3, 6]);