Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the spell error which makes the gradientTransform doesn't work #7059

Merged
merged 6 commits into from
Jun 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@
ctx.lineJoin = decl.strokeLineJoin;
ctx.miterLimit = decl.strokeMiterLimit;
if (stroke.toLive) {
if (stroke.gradientUnits === 'percentage' || stroke.gradientTrasnform || stroke.patternTransform) {
if (stroke.gradientUnits === 'percentage' || stroke.gradientTransform || stroke.patternTransform) {
// need to transform gradient in a pattern.
// this is a slow process. If you are hitting this codepath, and the object
// is not using caching, you should consider switching it on.
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/text.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@
handleFiller: function(ctx, property, filler) {
var offsetX, offsetY;
if (filler.toLive) {
if (filler.gradientUnits === 'percentage' || filler.gradientTrasnform || filler.patternTransform) {
if (filler.gradientUnits === 'percentage' || filler.gradientTransform || filler.patternTransform) {
// need to transform gradient in a pattern.
// this is a slow process. If you are hitting this codepath, and the object
// is not using caching, you should consider switching it on.
Expand Down
97 changes: 97 additions & 0 deletions test/visual/generic_rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,5 +361,102 @@
height: 100,
});

function gradientStroke(canvas, callback) {
var line = new fabric.Line([10, 10, 200, 200], {
stroke: new fabric.Gradient({
type: 'linear',
coords: {
x1: 20,
y1: 0,
x2: 80,
y2: 0,
},
colorStops: [
{
offset: 0,
color: 'green',
},
{
offset: 0.4,
color: 'cyan',
},
{
offset: 1,
color: 'red',
},
],
gradientTransform: [1, 0, 0, 1, 50, 0]
}),
strokeWidth: 20,
});
canvas.add(
line
);
canvas.renderAll();
callback(canvas.lowerCanvasEl);

}

tests.push({
test: 'Use the gradient strokeStyle for line(other shape is ok)',
code: gradientStroke,
golden: 'gradientStroke.png',
newModule: 'Gradient stroke',
percentage: 0.09,
width: 300,
height: 300,
});

function textGradientFill(canvas, callback) {
var text = new fabric.Text('Some Text', {
fontSize: 40,
left: 25,
top: -25,
fontWeight: 'bold',
fill: new fabric.Gradient({
type: 'radial',
coords: {
x1: 0,
y1: 0,
r1: 100,
x2: 0,
y2: 0,
r2: 50
},
colorStops: [
{
offset: 0,
color: 'white',
},
{
offset: 0.5,
color: 'indianred',
},
{
offset: 1,
color: 'green',
},
],
gradientTransform: [1, 0, 0, 1, 50, 50]
})
});
canvas.add(
text
);
canvas.renderAll();
callback(canvas.lowerCanvasEl);

}

tests.push({
test: 'Use the gradient fillStyle for text',
code: textGradientFill,
golden: 'textGradientFill.png',
newModule: 'Text gradient fill',
percentage: 0.09,
width: 300,
height: 100,
});

tests.forEach(visualTestLoop(QUnit));
})();
Binary file added test/visual/golden/gradientStroke.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/visual/golden/textGradientFill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.