mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-22 21:42:30 -05:00
Revert the code that converted a transparent-to-transparent gradient to a transparent solid color on select, because that was causing the bug where when you switched gradient twice with trans-trans, it became black-white. Instead, leave the color as a trans-trans gradient, but treat it as if its solid when switching colors. Its starting to keep track of a lot of secret state, which seems brittle...
This commit is contained in:
parent
c62093febe
commit
84da7aa842
1 changed files with 8 additions and 13 deletions
|
@ -298,7 +298,11 @@ const applyGradientTypeToSelection = function (gradientType, applyToStroke, text
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasGradient) {
|
// If this is a stroke, we don't display it as having a gradient in the color picker
|
||||||
|
// if there's no stroke width. Then treat it as if it doesn't have a gradient.
|
||||||
|
let hasDisplayGradient = hasGradient;
|
||||||
|
if (applyToStroke) hasDisplayGradient = hasGradient && item.strokeWidth > 0;
|
||||||
|
if (!hasDisplayGradient) {
|
||||||
const noColorOriginally = !itemColor ||
|
const noColorOriginally = !itemColor ||
|
||||||
(itemColor.gradient &&
|
(itemColor.gradient &&
|
||||||
itemColor.gradient.stops &&
|
itemColor.gradient.stops &&
|
||||||
|
@ -329,18 +333,18 @@ const applyGradientTypeToSelection = function (gradientType, applyToStroke, text
|
||||||
// If the item's gradient type differs from the gradient type we want to apply, then we change it
|
// If the item's gradient type differs from the gradient type we want to apply, then we change it
|
||||||
switch (gradientType) {
|
switch (gradientType) {
|
||||||
case GradientTypes.RADIAL: {
|
case GradientTypes.RADIAL: {
|
||||||
const hasRadialGradient = hasGradient && itemColor.gradient.radial;
|
const hasRadialGradient = hasDisplayGradient && itemColor.gradient.radial;
|
||||||
gradientTypeDiffers = !hasRadialGradient;
|
gradientTypeDiffers = !hasRadialGradient;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GradientTypes.HORIZONTAL: {
|
case GradientTypes.HORIZONTAL: {
|
||||||
const hasHorizontalGradient = hasGradient && !itemColor.gradient.radial &&
|
const hasHorizontalGradient = hasDisplayGradient && !itemColor.gradient.radial &&
|
||||||
Math.abs(itemColor.origin.y - itemColor.destination.y) < 1e-8;
|
Math.abs(itemColor.origin.y - itemColor.destination.y) < 1e-8;
|
||||||
gradientTypeDiffers = !hasHorizontalGradient;
|
gradientTypeDiffers = !hasHorizontalGradient;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GradientTypes.VERTICAL: {
|
case GradientTypes.VERTICAL: {
|
||||||
const hasVerticalGradient = hasGradient && !itemColor.gradient.radial &&
|
const hasVerticalGradient = hasDisplayGradient && !itemColor.gradient.radial &&
|
||||||
Math.abs(itemColor.origin.x - itemColor.destination.x) < 1e-8;
|
Math.abs(itemColor.origin.x - itemColor.destination.x) < 1e-8;
|
||||||
gradientTypeDiffers = !hasVerticalGradient;
|
gradientTypeDiffers = !hasVerticalGradient;
|
||||||
break;
|
break;
|
||||||
|
@ -470,15 +474,6 @@ const getColorsFromSelection = function (selectedItems, bitmapMode) {
|
||||||
const strokeColor2String = secondary;
|
const strokeColor2String = secondary;
|
||||||
let strokeGradientType = gradientType;
|
let strokeGradientType = gradientType;
|
||||||
|
|
||||||
if (strokeGradientType !== GradientTypes.SOLID &&
|
|
||||||
item.strokeColor.gradient.stops.length === 2 &&
|
|
||||||
item.strokeColor.gradient.stops[0].color.alpha === 0 &&
|
|
||||||
item.strokeColor.gradient.stops[1].color.alpha === 0) {
|
|
||||||
// Clear the gradient if both colors are transparent
|
|
||||||
item.strokeColor = null;
|
|
||||||
strokeGradientType = GradientTypes.SOLID;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the item's stroke width is 0, pretend the stroke color is null
|
// If the item's stroke width is 0, pretend the stroke color is null
|
||||||
if (!item.strokeWidth) {
|
if (!item.strokeWidth) {
|
||||||
strokeColorString = null;
|
strokeColorString = null;
|
||||||
|
|
Loading…
Reference in a new issue