mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-23 05:52:42 -05:00
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:
parent
4f86762737
commit
92ac312ad8
4 changed files with 11 additions and 11 deletions
|
@ -13,7 +13,7 @@ import {clearSelectedItems} from '../reducers/selected-items';
|
||||||
import {changeGradientType} from '../reducers/fill-mode-gradient-type';
|
import {changeGradientType} from '../reducers/fill-mode-gradient-type';
|
||||||
import {clearSelection} from '../helper/selection';
|
import {clearSelection} from '../helper/selection';
|
||||||
import FillTool from '../helper/bit-tools/fill-tool';
|
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 {
|
class BitFillMode extends React.Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
|
@ -69,13 +69,13 @@ class BitFillMode extends React.Component {
|
||||||
let color2 = this.props.color2;
|
let color2 = this.props.color2;
|
||||||
if (gradientType !== this.props.styleGradientType) {
|
if (gradientType !== this.props.styleGradientType) {
|
||||||
if (this.props.styleGradientType === GradientTypes.SOLID) {
|
if (this.props.styleGradientType === GradientTypes.SOLID) {
|
||||||
color2 = getRotatedColor(color);
|
color2 = generateSecondaryColor(color);
|
||||||
this.props.onChangeFillColor(color2, 1);
|
this.props.onChangeFillColor(color2, 1);
|
||||||
}
|
}
|
||||||
this.props.changeGradientType(gradientType);
|
this.props.changeGradientType(gradientType);
|
||||||
}
|
}
|
||||||
if (this.props.color2 === MIXED) {
|
if (this.props.color2 === MIXED) {
|
||||||
color2 = getRotatedColor();
|
color2 = generateSecondaryColor();
|
||||||
this.props.onChangeFillColor(color2, 1);
|
this.props.onChangeFillColor(color2, 1);
|
||||||
}
|
}
|
||||||
this.tool = new FillTool(this.props.onUpdateImage);
|
this.tool = new FillTool(this.props.onUpdateImage);
|
||||||
|
|
|
@ -13,7 +13,7 @@ import ColorIndicatorComponent from '../components/color-indicator.jsx';
|
||||||
import {applyColorToSelection,
|
import {applyColorToSelection,
|
||||||
applyGradientTypeToSelection,
|
applyGradientTypeToSelection,
|
||||||
applyStrokeWidthToSelection,
|
applyStrokeWidthToSelection,
|
||||||
getRotatedColor,
|
generateSecondaryColor,
|
||||||
swapColorsInSelection,
|
swapColorsInSelection,
|
||||||
MIXED} from '../helper/style-path';
|
MIXED} from '../helper/style-path';
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ const makeColorIndicator = (label, isStroke) => {
|
||||||
if (this.props.gradientType === GradientTypes.SOLID && gradientType !== GradientTypes.SOLID) {
|
if (this.props.gradientType === GradientTypes.SOLID && gradientType !== GradientTypes.SOLID) {
|
||||||
// Generate color 2 and change to the 2nd swatch when switching from solid to gradient
|
// Generate color 2 and change to the 2nd swatch when switching from solid to gradient
|
||||||
if (!hasSelectedItems) {
|
if (!hasSelectedItems) {
|
||||||
this.props.onChangeColor(getRotatedColor(this.props.color), 1);
|
this.props.onChangeColor(generateSecondaryColor(this.props.color), 1);
|
||||||
}
|
}
|
||||||
this.props.onChangeColorIndex(1);
|
this.props.onChangeColorIndex(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import bindAll from 'lodash.bindall';
|
||||||
import Modes from '../lib/modes';
|
import Modes from '../lib/modes';
|
||||||
import GradientTypes from '../lib/gradient-types';
|
import GradientTypes from '../lib/gradient-types';
|
||||||
import FillTool from '../helper/tools/fill-tool';
|
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 {changeFillColor, changeFillColor2, DEFAULT_COLOR} from '../reducers/fill-style';
|
||||||
import {changeMode} from '../reducers/modes';
|
import {changeMode} from '../reducers/modes';
|
||||||
|
@ -73,13 +73,13 @@ class FillMode extends React.Component {
|
||||||
let fillColor2 = this.props.fillColor2;
|
let fillColor2 = this.props.fillColor2;
|
||||||
if (gradientType !== this.props.fillStyleGradientType) {
|
if (gradientType !== this.props.fillStyleGradientType) {
|
||||||
if (this.props.fillStyleGradientType === GradientTypes.SOLID) {
|
if (this.props.fillStyleGradientType === GradientTypes.SOLID) {
|
||||||
fillColor2 = getRotatedColor(fillColor);
|
fillColor2 = generateSecondaryColor(fillColor);
|
||||||
this.props.onChangeFillColor(fillColor2, 1);
|
this.props.onChangeFillColor(fillColor2, 1);
|
||||||
}
|
}
|
||||||
this.props.changeGradientType(gradientType);
|
this.props.changeGradientType(gradientType);
|
||||||
}
|
}
|
||||||
if (this.props.fillColor2 === MIXED) {
|
if (this.props.fillColor2 === MIXED) {
|
||||||
fillColor2 = getRotatedColor(fillColor);
|
fillColor2 = generateSecondaryColor(fillColor);
|
||||||
this.props.onChangeFillColor(fillColor2, 1);
|
this.props.onChangeFillColor(fillColor2, 1);
|
||||||
}
|
}
|
||||||
this.tool = new FillTool(
|
this.tool = new FillTool(
|
||||||
|
|
|
@ -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.
|
// 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;
|
if (firstColor === MIXED) return null;
|
||||||
const color = new paper.Color(firstColor);
|
const color = new paper.Color(firstColor);
|
||||||
if (!firstColor || color.alpha === 0) return DEFAULT_COLOR;
|
if (!firstColor || color.alpha === 0) return DEFAULT_COLOR;
|
||||||
|
@ -262,7 +262,7 @@ const applyGradientTypeToSelection = function (gradientType, applyToStroke, text
|
||||||
let itemColor2;
|
let itemColor2;
|
||||||
if (!hasGradient || !itemColor.gradient.stops[1]) {
|
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
|
// 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) {
|
} else if (itemColor.gradient.stops[1].color.alpha === 0) {
|
||||||
// Gradient has 2nd color which is transparent
|
// Gradient has 2nd color which is transparent
|
||||||
itemColor2 = null;
|
itemColor2 = null;
|
||||||
|
@ -600,7 +600,7 @@ export {
|
||||||
applyStrokeWidthToSelection,
|
applyStrokeWidthToSelection,
|
||||||
createGradientObject,
|
createGradientObject,
|
||||||
getColorsFromSelection,
|
getColorsFromSelection,
|
||||||
getRotatedColor,
|
generateSecondaryColor,
|
||||||
MIXED,
|
MIXED,
|
||||||
styleBlob,
|
styleBlob,
|
||||||
styleShape,
|
styleShape,
|
||||||
|
|
Loading…
Reference in a new issue