mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-23 14:02:50 -05:00
When a piece of a compound path is selected, treat it as the whole compound path.
This commit is contained in:
parent
21dc3a4b7f
commit
8dbed6ff77
1 changed files with 17 additions and 4 deletions
|
@ -13,7 +13,10 @@ const MIXED = 'scratch-paint/style-path/mixed';
|
||||||
const applyFillColorToSelection = function (colorString) {
|
const applyFillColorToSelection = function (colorString) {
|
||||||
const items = getSelectedLeafItems();
|
const items = getSelectedLeafItems();
|
||||||
let changed = false;
|
let changed = false;
|
||||||
for (const item of items) {
|
for (let item of items) {
|
||||||
|
if (item.parent instanceof paper.CompoundPath) {
|
||||||
|
item = item.parent;
|
||||||
|
}
|
||||||
if (isPGTextItem(item)) {
|
if (isPGTextItem(item)) {
|
||||||
for (const child of item.children) {
|
for (const child of item.children) {
|
||||||
if (child.children) {
|
if (child.children) {
|
||||||
|
@ -61,7 +64,10 @@ const _strokeColorMatch = function (item, incomingColor) {
|
||||||
const applyStrokeColorToSelection = function (colorString) {
|
const applyStrokeColorToSelection = function (colorString) {
|
||||||
const items = getSelectedLeafItems();
|
const items = getSelectedLeafItems();
|
||||||
let changed = false;
|
let changed = false;
|
||||||
for (const item of items) {
|
for (let item of items) {
|
||||||
|
if (item.parent instanceof paper.CompoundPath) {
|
||||||
|
item = item.parent;
|
||||||
|
}
|
||||||
if (isPGTextItem(item)) {
|
if (isPGTextItem(item)) {
|
||||||
if (item.children) {
|
if (item.children) {
|
||||||
for (const child of item.children) {
|
for (const child of item.children) {
|
||||||
|
@ -103,7 +109,10 @@ const applyStrokeColorToSelection = function (colorString) {
|
||||||
const applyStrokeWidthToSelection = function (value, onUpdateSvg) {
|
const applyStrokeWidthToSelection = function (value, onUpdateSvg) {
|
||||||
let changed = false;
|
let changed = false;
|
||||||
const items = getSelectedLeafItems();
|
const items = getSelectedLeafItems();
|
||||||
for (const item of items) {
|
for (let item of items) {
|
||||||
|
if (item.parent instanceof paper.CompoundPath) {
|
||||||
|
item = item.parent;
|
||||||
|
}
|
||||||
if (isGroup(item)) {
|
if (isGroup(item)) {
|
||||||
continue;
|
continue;
|
||||||
} else if (item.strokeWidth !== value) {
|
} else if (item.strokeWidth !== value) {
|
||||||
|
@ -129,7 +138,11 @@ const getColorsFromSelection = function (selectedItems) {
|
||||||
let selectionStrokeWidth;
|
let selectionStrokeWidth;
|
||||||
let firstChild = true;
|
let firstChild = true;
|
||||||
|
|
||||||
for (const item of selectedItems) {
|
for (let item of selectedItems) {
|
||||||
|
if (item.parent instanceof paper.CompoundPath) {
|
||||||
|
// Compound path children inherit fill and stroke color from their parent.
|
||||||
|
item = item.parent;
|
||||||
|
}
|
||||||
let itemFillColorString;
|
let itemFillColorString;
|
||||||
let itemStrokeColorString;
|
let itemStrokeColorString;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue