Skip to content

Commit 5fc192b

Browse files
committed
Fix applying gradient types to items w/ gradients
This restores the previous logic which I removed in error. If the shape already has certain gradient types applied, it would previously not set origin, destination, or radial, but the gradient would unconditionally be applied, reading from those variables anyways.
1 parent 37ad1d3 commit 5fc192b

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

src/helper/style-path.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -272,20 +272,21 @@ const applyGradientTypeToSelection = function (gradientType, bitmapMode, applyTo
272272
itemColor2 = getColorStringForTransparent(itemColor1);
273273
}
274274

275-
let origin;
276-
let destination;
277-
let radial = false;
278-
279275
switch (gradientType) {
280276
case GradientTypes.RADIAL: {
281277
const hasRadialGradient = hasGradient && itemColor.gradient.radial;
282278
if (!hasRadialGradient) {
283279
changed = true;
284280
const halfLongestDimension = Math.max(item.bounds.width, item.bounds.height) / 2;
285281

286-
origin = item.position;
287-
destination = item.position.add(new paper.Point(halfLongestDimension, 0));
288-
radial = true;
282+
item[itemColorProp] = {
283+
gradient: {
284+
stops: [itemColor1, itemColor2],
285+
radial: true
286+
},
287+
origin: item.position,
288+
destination: item.position.add(new paper.Point(halfLongestDimension, 0))
289+
};
289290
}
290291
break;
291292
}
@@ -295,8 +296,13 @@ const applyGradientTypeToSelection = function (gradientType, bitmapMode, applyTo
295296
if (!hasHorizontalGradient) {
296297
changed = true;
297298

298-
origin = item.bounds.leftCenter;
299-
destination = item.bounds.rightCenter;
299+
item[itemColorProp] = {
300+
gradient: {
301+
stops: [itemColor1, itemColor2]
302+
},
303+
origin: item.bounds.leftCenter,
304+
destination: item.bounds.rightCenter
305+
};
300306
}
301307
break;
302308
}
@@ -306,21 +312,17 @@ const applyGradientTypeToSelection = function (gradientType, bitmapMode, applyTo
306312
if (!hasVerticalGradient) {
307313
changed = true;
308314

309-
origin = item.bounds.topCenter;
310-
destination = item.bounds.bottomCenter;
315+
item[itemColorProp] = {
316+
gradient: {
317+
stops: [itemColor1, itemColor2]
318+
},
319+
origin: item.bounds.topCenter,
320+
destination: item.bounds.bottomCenter
321+
};
311322
}
312323
break;
313324
}
314325
}
315-
316-
item[itemColorProp] = {
317-
gradient: {
318-
stops: [itemColor1, itemColor2],
319-
radial
320-
},
321-
origin,
322-
destination
323-
};
324326
}
325327
return changed;
326328
};

0 commit comments

Comments
 (0)