Skip to content

Commit

Permalink
fix: fix angle calculation problem with linear gradient.
Browse files Browse the repository at this point in the history
  • Loading branch information
simaQ committed Oct 25, 2018
1 parent 59b4667 commit 4adbb84
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/graphic/util/style-parse.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const Util = require('../../util/common');

function _mod(n, m) {
return ((n % m) + m) % m;
}

function _addStop(steps, gradient) {
Util.each(steps, item => {
item = item.split(':');
Expand All @@ -11,7 +15,7 @@ function _addStop(steps, gradient) {
function _parseLineGradient(color, shape, context) {
const arr = color.split(' ');
let angle = arr[0].slice(2, arr[0].length - 1);
angle = (angle * Math.PI) / 180;
angle = _mod((parseFloat(angle) * Math.PI) / 180, Math.PI * 2);
const steps = arr.slice(1);

const { minX, minY, maxX, maxY } = shape.getBBox();
Expand Down

0 comments on commit 4adbb84

Please sign in to comment.