Rename getRotatedColor to getSecondaryColor

This function is used to generate a "secondary" color for gradients.
It will soon do things other than rotate the hue.
This commit is contained in:
adroitwhiz 2020-06-16 12:27:31 -04:00
parent 4f86762737
commit 92ac312ad8
4 changed files with 11 additions and 11 deletions

View file

@ -13,7 +13,7 @@ import {clearSelectedItems} from '../reducers/selected-items';
import {changeGradientType} from '../reducers/fill-mode-gradient-type';
import {clearSelection} from '../helper/selection';
import FillTool from '../helper/bit-tools/fill-tool';
import {getRotatedColor, MIXED} from '../helper/style-path';
import {generateSecondaryColor, MIXED} from '../helper/style-path';
class BitFillMode extends React.Component {
constructor (props) {
@ -69,13 +69,13 @@ class BitFillMode extends React.Component {
let color2 = this.props.color2;
if (gradientType !== this.props.styleGradientType) {
if (this.props.styleGradientType === GradientTypes.SOLID) {
color2 = getRotatedColor(color);
color2 = generateSecondaryColor(color);
this.props.onChangeFillColor(color2, 1);
}
this.props.changeGradientType(gradientType);
}
if (this.props.color2 === MIXED) {
color2 = getRotatedColor();
color2 = generateSecondaryColor();
this.props.onChangeFillColor(color2, 1);
}
this.tool = new FillTool(this.props.onUpdateImage);

View file

@ -13,7 +13,7 @@ import ColorIndicatorComponent from '../components/color-indicator.jsx';
import {applyColorToSelection,
applyGradientTypeToSelection,
applyStrokeWidthToSelection,
getRotatedColor,
generateSecondaryColor,
swapColorsInSelection,
MIXED} from '../helper/style-path';
@ -97,7 +97,7 @@ const makeColorIndicator = (label, isStroke) => {
if (this.props.gradientType === GradientTypes.SOLID && gradientType !== GradientTypes.SOLID) {
// Generate color 2 and change to the 2nd swatch when switching from solid to gradient
if (!hasSelectedItems) {
this.props.onChangeColor(getRotatedColor(this.props.color), 1);
this.props.onChangeColor(generateSecondaryColor(this.props.color), 1);
}
this.props.onChangeColorIndex(1);
}

View file

@ -5,7 +5,7 @@ import bindAll from 'lodash.bindall';
import Modes from '../lib/modes';
import GradientTypes from '../lib/gradient-types';
import FillTool from '../helper/tools/fill-tool';
import {getRotatedColor, MIXED} from '../helper/style-path';
import {generateSecondaryColor, MIXED} from '../helper/style-path';
import {changeFillColor, changeFillColor2, DEFAULT_COLOR} from '../reducers/fill-style';
import {changeMode} from '../reducers/modes';
@ -73,13 +73,13 @@ class FillMode extends React.Component {
let fillColor2 = this.props.fillColor2;
if (gradientType !== this.props.fillStyleGradientType) {
if (this.props.fillStyleGradientType === GradientTypes.SOLID) {
fillColor2 = getRotatedColor(fillColor);
fillColor2 = generateSecondaryColor(fillColor);
this.props.onChangeFillColor(fillColor2, 1);
}
this.props.changeGradientType(gradientType);
}
if (this.props.fillColor2 === MIXED) {
fillColor2 = getRotatedColor(fillColor);
fillColor2 = generateSecondaryColor(fillColor);
this.props.onChangeFillColor(fillColor2, 1);
}
this.tool = new FillTool(

View file

@ -48,7 +48,7 @@ const getColorStringForTransparent = function (colorToMatch) {
};
// Returns a color shift by 72 of the given color, DEFAULT_COLOR if the given color is null, or null if it is MIXED.
const getRotatedColor = function (firstColor) {
const generateSecondaryColor = function (firstColor) {
if (firstColor === MIXED) return null;
const color = new paper.Color(firstColor);
if (!firstColor || color.alpha === 0) return DEFAULT_COLOR;
@ -262,7 +262,7 @@ const applyGradientTypeToSelection = function (gradientType, applyToStroke, text
let itemColor2;
if (!hasGradient || !itemColor.gradient.stops[1]) {
// If item color is solid or a gradient that has no 2nd color, set the 2nd color based on the first color
itemColor2 = getRotatedColor(itemColor1);
itemColor2 = generateSecondaryColor(itemColor1);
} else if (itemColor.gradient.stops[1].color.alpha === 0) {
// Gradient has 2nd color which is transparent
itemColor2 = null;
@ -600,7 +600,7 @@ export {
applyStrokeWidthToSelection,
createGradientObject,
getColorsFromSelection,
getRotatedColor,
generateSecondaryColor,
MIXED,
styleBlob,
styleShape,