Copy link to clipboard
Copied
i am trying to draw line in adobe animate html5
i wrote this code, but it is not work
var c = stage.document.getElementById("canvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.moveTo(30,67);
ctx.lineTo(45,78);
ctx.stroke();
Copy link to clipboard
Copied
try:
var s = new createjs.Shape();
stage.addChild(s);
var g = s.graphics;
g.setStrokeStyle(10);
g.beginStroke("#00ff00");
g.moveTo(30,67);
g.lineTo(45,78);
g.endStroke();
Copy link to clipboard
Copied
it is work
thanks
Copy link to clipboard
Copied
you're welcome
Copy link to clipboard
Copied
No. You can't barge in and start drawing on Animate's canvas element using the low-level browser API. Animate owns the canvas, and anything you try to draw on it that way will be immediately clobbered. You have to use the CreateJS API to tell it what you want to draw.
https://www.createjs.com/docs/easeljs/classes/Graphics.html
Copy link to clipboard
Copied
Thanks
i wote:
var g = new createjs.Graphics(); g.setStrokeStyle(1); g.beginStroke("#000000"); g.beginFill("red"); g.drawCircle(0,0,30);
but nothing happend.
do i have to do addchild?
Copy link to clipboard
Copied
Only if you want to see it.