1

I have a HTML5 canvas on which I have drawn a full fledged table. I have the option to give a background color to the table headers. Although normal background color works, I am unable to apply the linear gradient correctly. I get the linear gradient in this format

background: linear-gradient(55deg, rgb(0, 0, 0) 0%, rgb(128, 0, 128) 50%, rgb(255, 0, 0) 100%);

I have used this available solution, but it doesn't seem to work in all cases. I need to know how to exactly calculate the end points of the gradient line since the canvas linearGradient() expects it that way.

https://jsfiddle.net/LpLr0hxw/2/

  • 1
    You can find a correct version in [html2canvas sources](https://github.com/niklasvh/html2canvas/blob/0b9f34a5bf1cafad260506f5b353aeb8d610612c/src/Gradient.js#L273) https://jsfiddle.net/LpLr0hxw/5 – Kaiido Mar 27 '18 at 08:46
  • This seems to work fine. Thank you so much :) – Behram Buhariwala Mar 27 '18 at 09:09

0 Answers0