当前位置: 首页 > 工具软件 > EaselJS > 使用案例 >

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

解晟睿
2023-12-01

我对画架和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.

 类似资料: