var Canvas = function (el, parameter) {
this.canvas = document.getElementById(el);
this.width = canvas.width;
this.height = canvas.height;
this.pen = canvas.getContext('2d');
parameter = parameter || {};
if (Object.prototype.toString.call(parameter) !== '[object Object]') {
throw new Error('Parameter must be a Object.')
} else {
var fillStyle = parameter.fillStyle || 'yellow';
var strokeStyle = parameter.strokeStyle || 'black';
var lineWidth = parameter.lineWidth || 1;
}
this.pen.fillStyle = fillStyle;
this.pen.strokeStyle = strokeStyle;
this.pen.lineWidth = lineWidth;
};
Canvas.prototype.clearRect = function (x, y, width, height) {
if (!x) {
this.pen.clearRect(0, 0, this.width, this.height);
} else {
this.pen.clearRect(x, y, width, height
canvas绘制星星
最新推荐文章于 2024-04-15 13:20:28 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)