mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-07 04:39:06 +02:00
Merge pull request #2648 from chartjs/fix/2607
Don't use translates and rotates for drawing rotated rectangles
This commit is contained in:
commit
464adcc94b
@ -88,12 +88,14 @@ module.exports = function(Chart) {
|
|||||||
ctx.strokeRect(x - size, y - size, 2 * size, 2 * size);
|
ctx.strokeRect(x - size, y - size, 2 * size, 2 * size);
|
||||||
break;
|
break;
|
||||||
case 'rectRot':
|
case 'rectRot':
|
||||||
ctx.translate(x, y);
|
|
||||||
ctx.rotate(Math.PI / 4);
|
|
||||||
size = 1 / Math.SQRT2 * radius;
|
size = 1 / Math.SQRT2 * radius;
|
||||||
ctx.fillRect(-size, -size, 2 * size, 2 * size);
|
ctx.beginPath();
|
||||||
ctx.strokeRect(-size, -size, 2 * size, 2 * size);
|
ctx.moveTo(x - size, y);
|
||||||
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
ctx.lineTo(x, y + size);
|
||||||
|
ctx.lineTo(x + size, y);
|
||||||
|
ctx.lineTo(x, y - size);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.fill();
|
||||||
break;
|
break;
|
||||||
case 'cross':
|
case 'cross':
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
|
@ -189,20 +189,26 @@ describe('Point element tests', function() {
|
|||||||
name: 'setFillStyle',
|
name: 'setFillStyle',
|
||||||
args: ['rgba(0, 255, 0)']
|
args: ['rgba(0, 255, 0)']
|
||||||
}, {
|
}, {
|
||||||
name: 'translate',
|
name: 'beginPath',
|
||||||
args: [10, 15]
|
args: []
|
||||||
}, {
|
}, {
|
||||||
name: 'rotate',
|
name: 'moveTo',
|
||||||
args: [Math.PI / 4]
|
args: [10 - 1 / Math.SQRT2 * 2, 15]
|
||||||
}, {
|
}, {
|
||||||
name: 'fillRect',
|
name: 'lineTo',
|
||||||
args: [-1 / Math.SQRT2 * 2, -1 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2],
|
args: [10, 15 + 1 / Math.SQRT2 * 2]
|
||||||
}, {
|
}, {
|
||||||
name: 'strokeRect',
|
name: 'lineTo',
|
||||||
args: [-1 / Math.SQRT2 * 2, -1 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2],
|
args: [10 + 1 / Math.SQRT2 * 2, 15],
|
||||||
}, {
|
}, {
|
||||||
name: 'setTransform',
|
name: 'lineTo',
|
||||||
args: [1, 0, 0, 1, 0, 0],
|
args: [10, 15 - 1 / Math.SQRT2 * 2],
|
||||||
|
}, {
|
||||||
|
name: 'closePath',
|
||||||
|
args: []
|
||||||
|
}, {
|
||||||
|
name: 'fill',
|
||||||
|
args: [],
|
||||||
}, {
|
}, {
|
||||||
name: 'stroke',
|
name: 'stroke',
|
||||||
args: []
|
args: []
|
||||||
|
Loading…
Reference in New Issue
Block a user