html中画布中怎么画一条直线,使用EaselJS在html5画布中绘制线条

我对画架和HTML5本身非常新颖。我正试图在使用EaselJS的画布上绘制一条线。 X坐标纵坐标固定为100,Y坐标纵坐标从数组列表中获得。我写的代码如下。可以请别人让我知道我哪里出错了?使用EaselJS在html5画布中绘制线条

function myFunction(attachPoint)

{

//Code for canvas creation is written here.[Not shown];

//created a stage.

stage = new createjs.Stage(canvas.domElement());

//3. create some shapes.MagnitudeLessThanTwo is the array where we get the YAxis Coordinates from

alert("The lenght before function is"+MagnitudeLessThanTwo.length);

myShape = new drawLineGraph(MagnitudeLessThanTwo);

//4. finally add that shape to the stage

stage.addChild(myShape);

//5. set up the ticker

if (!createjs.Ticker.hasEventListener("tick")) {

createjs.Ticker.addEventListener("tick", ourTickFunction);

};

};

function drawLineGraph(dataList)

{

this.index=0;//To keep the track of the index of the array from which we get the Y Axis.

var graphics = new createjs.Graphics();

graphics.setStrokeStyle(1);

graphics.beginStroke("white");

graphics.moveTo(50,(dataList[this.index].magnitude)*100);

graphics.lineTo(50,(dataList[(this.index)++].magnitude)*100);

createjs.Shape.call(this,graphics);

this.tick = function() {

graphics.moveTo(100,(dataList[this.index].magnitude)*100);

graphics.lineTo(100,(dataList[(this.index)++].magnitude)*100);

stage.addChild(graphics);

};

};

drawLineGraph.prototype = new createjs.Shape(); //set prototype

drawLineGraph.prototype.constructor = drawLineGraph; //fix constructor pointer

I am getting the following Error.

"Object [object Object] has no method 'isVisible'"- This is inside the EaselJS Library.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值