0

i have following code:

[
    {
      lineDash: [0, 0],
      strokeStyle: '#909090',
      lineWidth: lineWidth,
    },
    {
      lineDash: [0, 0],
      strokeStyle: '#e5e5e5',
      lineWidth: lineWidth -10,
    },
    {
      lineDash: [0, 0],
      strokeStyle: '#909090',
      lineWidth: lineWidth -26,
    },
    {
      lineDash: [20, 14],
      strokeStyle: '#ffffff',
      lineWidth: 3,
    },
  ].forEach(function(entry) {

    ctx.beginPath();

    ctx.lineWidth = entry.lineWidth;
    ctx.strokeStyle = entry.strokeStyle;
    ctx.setLineDash(entry.lineDash);
}

Setting lineWidth and strokeStyle works fine, but setLineWidth doesn't in Firefox and i get no error in console. In Chrome, it works. If i say instead of 'ctx.setLineDash(entry.lineDash);' 'ctx.setLineDash(entry.lineDash[0], entry.lineDash[1]);', Firefox console says 'TypeError: Argument 1 of CanvasRenderingContext2D.setLineDash can't be converted to a sequence.' and Chrome console means 'Uncaught TypeError: The 1st argument is neither an array, nor does it have indexed properties'.

Do you know how to solve this problem? Thanks in advance!

1 Answer 1

0

Know, i know the fault: [0, 0] doesn't make a line (0 line, 0 space between!?). I have to set the first value to any number over 0 and let the other 0. Then, it's a solid line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.