locked
CanvasRenderingContext2D.setLineDash and lineDashOffset missing? RRS feed

  • Question

  • According to the documentation here: http://msdn.microsoft.com/en-us/library/windows/apps/hh825908.aspx

    setLineDash and lineDashOffset functions should be supported, but they don't exist for my CanvasRenderingContext2D object in my HTML5/JS WinStore application at all. I really need them, why they are missing? Is there a possibility to make them working?

    Michal

    Friday, July 12, 2013 4:18 PM

Answers

  • It looks like those methods are relatively new in the html5 spec, and weren't supported in IE10, so that would explain why it doesn't work,  are you working on 8.0 apps or the 8.1 preview?
    • Marked as answer by Michal Pilar Friday, July 12, 2013 6:55 PM
    Friday, July 12, 2013 6:14 PM

All replies

  • Do you have some example code that demonstrates the problem?
    Friday, July 12, 2013 5:18 PM
  • It is simple, standard HTML5/JS project, HTML contains this in one div:

    <canvas id="visCanvas" style=";  width: 600px; height: 60px; bottom: 60px">

    And related Javascript called one second after onload of the page contains:

    var visCanvas = document.getElementById('visCanvas');
    visCanvas.width = parseInt(visCanvas.style.width);
    visCanvas.height = parseInt(visCanvas.style.height);
    var visCanvasCtx = visCanvas.getContext("2d");
    visCanvasCtx.fillStyle = "white";
    var dashList = [12, 3, 3, 3];
    visCanvasCtx.setLineDash(dashList);

    - here it fails on the last line (with 0x800a01b6 exception, i.e. "Object doesn't support property or method"), debuggers shows, that visCanvasCtx object has nearly all methods and properties mentioned in the help page mentioned before, but setLineDash, getLineDash and lineDashOffset are missing.

    I can draw text, rectangles, etc., but cannot use line dashes.


    Edit: style in HTML contains position absolute, this editor always removes this from my post for some reason.

    • Edited by Michal Pilar Friday, July 12, 2013 6:10 PM some editor bug
    Friday, July 12, 2013 6:05 PM
  • It looks like those methods are relatively new in the html5 spec, and weren't supported in IE10, so that would explain why it doesn't work,  are you working on 8.0 apps or the 8.1 preview?
    • Marked as answer by Michal Pilar Friday, July 12, 2013 6:55 PM
    Friday, July 12, 2013 6:14 PM
  • I need it in 8.0. I would expect at least some note in the help, that these methods are not supported yet... Is there some documentation, that shows what is really supported in 8.0? Currently this is very confusing then.
    Friday, July 12, 2013 6:19 PM