Skip to content

Commit 75f7a36

Browse files
committed
A few small changes
1 parent 674ab6f commit 75f7a36

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

features/outline-shape-options/data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"title": "Outline Shape Options",
3-
"description": "Change the shape of the corners of the object's outline in the Paint Editor.",
2+
"title": "Customizable Shape Outlines",
3+
"description": "Adds more options in the outline dropdown to allow you to customize the shape of the outline, such as making corners round.",
44
"credits": [
55
{
66
"username": "Masaabu-YT",
Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
export default async function ({ feature, console }) {
22
const icons = {
3-
Cap: [
4-
"butt",
5-
"round",
6-
"square"
7-
],
8-
Join: [
9-
"miter",
10-
"round",
11-
"bevel",
12-
"arcs",
13-
"miter-clip"
14-
]
15-
}
3+
Cap: ["butt", "round", "square"],
4+
Join: ["miter", "round", "bevel", "arcs", "miter-clip"],
5+
};
166

177
function createSection(type) {
188
const selectedItems = feature.traps.getPaper().project.selectedItems;
@@ -21,60 +11,70 @@ export default async function ({ feature, console }) {
2111

2212
function changeItems(pos, value) {
2313
for (var i in selectedItems) {
24-
if (selectedItems[i][pos]!==undefined) {
14+
if (selectedItems[i][pos] !== undefined) {
2515
selectedItems[i][pos] = value;
2616
}
2717
}
2818
}
2919

3020
const row = document.createElement("div");
31-
row.classList.add('color-picker_row-header_173LQ')
21+
row.classList.add("color-picker_row-header_173LQ");
3222
const labelName = document.createElement("span");
33-
labelName.classList.add('color-picker_label-name_17igY')
34-
labelName.textContent = `Line${type}`;
23+
labelName.classList.add("color-picker_label-name_17igY");
24+
labelName.textContent = `Line ${type}`;
3525
const labelReadout = document.createElement("span");
36-
labelReadout.classList.add('color-picker_label-readout_9vjb2')
26+
labelReadout.classList.add("color-picker_label-readout_9vjb2");
3727
if (selectedItems.length === 1) {
3828
strokeValue = `${selectedItems[0][`stroke${type}`]}`;
3929
labelReadout.textContent = strokeValue;
4030
}
4131
row.appendChild(labelName);
4232
row.appendChild(labelReadout);
4333

44-
const content = document.createElement("div")
45-
content.classList.add('color-picker_gradient-picker-row_mnu4O')
46-
icons[type].forEach(iconName => {
34+
const content = document.createElement("div");
35+
content.classList.add("color-picker_gradient-picker-row_mnu4O");
36+
icons[type].forEach((iconName) => {
4737
const icon = document.createElement("img");
48-
icon.classList.add(`ste-outline-shape-options-${iconName}`)
38+
icon.classList.add(`ste-outline-shape-options-${iconName}`);
4939
icon.src = feature.self.getResource(`${type}-${iconName}`);
50-
if (iconName !== strokeValue) icon.classList.add("ste-outline-shape-options-passive");
40+
if (iconName !== strokeValue)
41+
icon.classList.add("ste-outline-shape-options-passive");
5142
icon.addEventListener("click", () => {
52-
changeItems(`stroke${type}`,`${iconName}`)
53-
labelReadout.textContent = iconName
54-
const elements = content.getElementsByTagName('*');
55-
for (let i=0; i<elements.length; i++) {
56-
if (elements[i].classList.contains(`ste-outline-shape-options-${iconName}`)) elements[i].classList.remove("ste-outline-shape-options-passive")
57-
else elements[i].classList.add("ste-outline-shape-options-passive")
43+
changeItems(`stroke${type}`, `${iconName}`);
44+
labelReadout.textContent = iconName;
45+
const elements = content.getElementsByTagName("*");
46+
for (let i = 0; i < elements.length; i++) {
47+
if (
48+
elements[i].classList.contains(
49+
`ste-outline-shape-options-${iconName}`
50+
)
51+
)
52+
elements[i].classList.remove("ste-outline-shape-options-passive");
53+
else elements[i].classList.add("ste-outline-shape-options-passive");
5854
}
5955
});
60-
content.appendChild(icon)
56+
content.appendChild(icon);
6157
});
6258

6359
result.appendChild(row);
6460
result.appendChild(content);
61+
feature.self.hideOnDisable(result)
6562
return result;
6663
}
6764

68-
ScratchTools.waitForElements("div.color-picker_swatch-row_1Q_s_", function(element) {
69-
if (feature.traps.paint().modals.fillColor) return;
70-
if (feature.traps.getPaper().project.selectedItems.length<1) return;
71-
const dividerLine = document.createElement("div");
72-
dividerLine.classList.add('color-picker_divider_3a3qR')
73-
const sectionCap = createSection('Cap')
74-
const sectionJoin = createSection('Join')
65+
ScratchTools.waitForElements(
66+
"div[class*='color-picker_swatch-row_']",
67+
function (element) {
68+
if (feature.traps.paint().modals.fillColor) return;
69+
if (feature.traps.getPaper().project.selectedItems.length < 1) return;
70+
const dividerLine = document.createElement("div");
71+
dividerLine.classList.add("color-picker_divider_3a3qR");
72+
const sectionCap = createSection("Cap");
73+
const sectionJoin = createSection("Join");
7574

76-
element.insertAdjacentElement('afterend', sectionJoin)
77-
element.insertAdjacentElement('afterend', sectionCap)
78-
element.insertAdjacentElement('afterend', dividerLine)
79-
})
80-
}
75+
element.insertAdjacentElement("afterend", sectionJoin);
76+
element.insertAdjacentElement("afterend", sectionCap);
77+
element.insertAdjacentElement("afterend", dividerLine);
78+
}
79+
);
80+
}

0 commit comments

Comments
 (0)