Skip to main content
Known Participant
November 23, 2020
Question

line to line

  • November 23, 2020
  • 3 replies
  • 552 views

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();

    This topic has been closed for replies.

    3 replies

    kglad
    Community Expert
    Community Expert
    November 23, 2020

    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();

    Yigal0D4BAuthor
    Known Participant
    November 24, 2020

    it is work

    thanks

    kglad
    Community Expert
    Community Expert
    November 24, 2020

    you're welcome 

    Yigal0D4BAuthor
    Known Participant
    November 23, 2020

    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?

     

    Legend
    November 23, 2020

    Only if you want to see it.

    Legend
    November 23, 2020

    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