Search code examples
javascripthtmlcanvaskineticjs

how can i get a dotted line border in kinetic js?


I'm just looking for a simple dashed line border around my Kinetic.Text() object. I see here in the documentation that lines can be made to be dashes, but it's not clear how to apply this to a border for another element like Text.


Solution

  • Actually this is very possible, just group together text and a dashed line that borders the text. Kind of like this:

    var group = new Kinetic.Group();
    var text = new Kinetic.Text(...);
    var border = new Kinetic.Line({
      dashArray: [...]
      points: [...]
    });
    
    group.add(text);
    group.add(border);
    

    Dash line example: http://www.html5canvastutorials.com/kineticjs/html5-canvas-kineticjs-line-tutorial/