Skip to content

Commit fe3d4e0

Browse files
committed
Merge remote-tracking branch 'upstream/main' into main
2 parents 9d5c499 + 99bb326 commit fe3d4e0

10 files changed

Lines changed: 204 additions & 94 deletions

File tree

.github/workflows/pr-branch-check.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: Enforce allowed branches for PRs to main
22

33
permissions:
44
contents: read
5-
65
on:
76
pull_request:
87
branches:

dist/BlueMarble.user.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/CONTRIBUTING.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,19 @@
5353
Thank you for wanting to contribute to the userscript "Blue Marble"! It means a lot to me that someone likes my project enough to want to help it grow. If you haven't already done so, consider joining our Discord. You can ask questions about the userscript there and receive feedback. You can also visit the <a href="https://bluemarble.camilledaguin.fr/" target="_blank" rel="noopener noreferrer">official Blue Marble website</a> for more information.
5454
<br>
5555
<b>Note</b>: If you are using AI, and you want to tell the AI how the codebase files are related to each-other, go to the <code>Class diagram of relationships for Blue Marble</code> diagram in the chart section of this file. Copy the chart, and give it to the AI.
56+
<br>
57+
<b>Note</b>: If you are contributing to the documentation of this project, make your fork from the <code>documentation</code> branch. If you are contributing to the code/programming of this project, make your fork from the <code>code</code> branch. If you fork main, and make a PR from <code>main</code> -> <code>main</code> your PR might be rejected. This is because <code>main</code> is not up-to-date, and your changes might conflict with up-to-date changes.
5658
</p>
5759

5860
<h2>Summary</h2>
5961
<p>
6062
<ul>
6163
<li>I don't want to waste your time, so double check with me before starting a big change like adding a new feature. For example, imagine you spend 50 hours making a bot that automatically places pixels, then your pull request was rejected because a bot that automatically places pixles does not align with the "Mission" of Blue Marble. That would be sad :(</li>
62-
<li>Follow the style of the project. E.g., if all overlays are made by calling `Overlay()`, and you want to make a new overlay, you should probably call `Overlay()` as well.</li>
64+
<li>Follow the style of the project. E.g., if all overlays are made by calling <code>Overlay()</code>, and you want to make a new overlay, you should probably call <code>Overlay()</code> as well.</li>
6365
<li>Low quality code will be rejected.</li>
6466
<li>You can find documentation for Blue Marble <a href="https://swingthevine.github.io/Wplace-BlueMarble/index.html" target="_blank" rel="noopener noreferrer">here</a>.</li>
67+
<li>Don't fork the <code>main</code> branch! Fork either <code>code</code> or <code>documentation</code>.</li>
68+
<li>If you are adding a new feature, and it is feasable to stick your feature inside a function, then use a function. This will make your code conflict less with other people's code. Make your code <a href="https://en.wikipedia.org/wiki/Modular_programming" target="_blank" rel="noopener noreferrer">modular</a>.</li>
6569
</ul>
6670
</p>
6771

@@ -79,7 +83,14 @@
7983
<h2>What Can I Contribute?</h2>
8084
<h3>Programming</h3>
8185
<p>
82-
Most of the work to be done in this userscript is related to programming. It is helpful to have a background in programming, but not required. If you are looking to learn JavaScript and its syntax, check out this <a href="https://roadmap.sh/javascript" target="_blank" rel="noopener noreferrer">roadmap for learning JavaScript</a>. We strongly recommend that you understand functions, methods, classes, and Object-Oriented-Programming if you plan to implement a brand new feature. More technical knowledge like method chaining and lambda expressions are useful but not required. You can find the documentation for Blue Marble <a href="https://swingthevine.github.io/Wplace-BlueMarble/index.html" target="_blank" rel="noopener noreferrer">here</a>.
86+
Most of the work to be done in this userscript is related to programming. It is helpful to have a background in programming, but not required. If you are looking to learn JavaScript and its syntax, check out this <a href="https://roadmap.sh/javascript" target="_blank" rel="noopener noreferrer">roadmap for learning JavaScript</a>. We strongly recommend that you understand functions, methods, classes, and Object-Oriented-Programming if you plan to implement a brand new feature. More technical knowledge like method chaining and lambda expressions are useful but not required. You can find the documentation for Blue Marble <a href="https://swingthevine.github.io/Wplace-BlueMarble/index.html" target="_blank" rel="noopener noreferrer">here</a>. Make your code modular when possible. In other words, you should "blackbox" your code by putting it in a function when possible. For example, if you are adding a color filter to remove colors from being displayed on the template, the function should pass in the template information and tile information, and output the filtered template/tile information. This way, other people's code can't interfere with the color filter. For example:
87+
<br>
88+
<ol>
89+
<li>The template image is generated and the tile information is retrieved.</li>
90+
<li>The color filter function is passed in the template image and the tile information. The color filter overrides the template image with the filtered colors, and outputs that as the template image.</li>
91+
<li>The pixel counter function is passed in the modified template image and the tile information, and outputs the pixel count.</li>
92+
<li>The modified template image and the tile information is used to render the template.</li>
93+
</ol>
8394
</p>
8495
<h3>Translation</h3>
8596
<p>

docs/README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@
4343

4444
<h1>Blue Marble</h1>
4545
<a href="https://status.wplace.lol" target="_blank" rel="noopener noreferrer"><img alt="Wplace Status" src="https://status.wplace.lol/badge/_/status?labelColor=5f5f5f&color=&style=flat&label=Wplace%20Status"></a>
46-
<a href="" target="_blank" rel="noopener noreferrer"><img alt="Latest Version" src="https://img.shields.io/badge/Latest_Version-0.84.0-lightblue?style=flat"></a>
46+
<a href="" target="_blank" rel="noopener noreferrer"><img alt="Latest Version" src="https://img.shields.io/badge/Latest_Version-0.85.0-lightblue?style=flat"></a>
4747
<a href="https://github.com/t-wy/Wplace-BlueMarble-Userscripts/releases" target="_blank" rel="noopener noreferrer"><img alt="Latest Release" src="https://img.shields.io/github/v/release/t-wy/Wplace-BlueMarble-Userscripts?sort=semver&style=flat&label=Latest%20Release&color=blue"></a>
4848
<a href="https://github.com/t-wy/Wplace-BlueMarble-Userscripts/blob/main/LICENSE.txt" target="_blank" rel="noopener noreferrer"><img alt="Software License: MPL-2.0" src="https://img.shields.io/badge/Software_License-MPL--2.0-slateblue?style=flat"></a>
4949
<a href="https://discord.gg/tpeBPy46hf" target="_blank" rel="noopener noreferrer"><img alt="Contact Me" src="https://img.shields.io/badge/Contact_Me-gray?style=flat&logo=Discord&logoColor=white&logoSize=auto&labelColor=cornflowerblue"></a>
5050
<a href="https://bluemarble.camilledaguin.fr/" target="_blank" rel="noopener noreferrer"><img alt="Blue Marble Website" src="https://img.shields.io/badge/Blue_Marble_Website-Camille_Daguin-blue?style=flat&logo=globe&logoColor=white"></a>
51-
<a href="" target="_blank" rel="noopener noreferrer"><img alt="WakaTime" src="https://img.shields.io/badge/Coding_Time-111hrs_12mins-blue?style=flat&logo=wakatime&logoColor=black&logoSize=auto&labelColor=white"></a>
52-
<a href="" target="_blank" rel="noopener noreferrer"><img alt="Total Patches" src="https://img.shields.io/badge/Total_Patches-495-black?style=flat"></a>
51+
<a href="" target="_blank" rel="noopener noreferrer"><img alt="WakaTime" src="https://img.shields.io/badge/Coding_Time-124hrs_4mins-blue?style=flat&logo=wakatime&logoColor=black&logoSize=auto&labelColor=white"></a>
52+
<a href="" target="_blank" rel="noopener noreferrer"><img alt="Total Patches" src="https://img.shields.io/badge/Total_Patches-503-black?style=flat"></a>
5353
<a href="" target="_blank" rel="noopener noreferrer"><img alt="Total Lines of Code" src="https://tokei.rs/b1/github/t-wy/Wplace-BlueMarble-Userscripts?category=code"></a>
5454
<a href="" target="_blank" rel="noopener noreferrer"><img alt="Total Comments" src="https://tokei.rs/b1/github/t-wy/Wplace-BlueMarble-Userscripts?category=comments"></a>
55-
<a href="" target="_blank" rel="noopener noreferrer"><img alt="Compression" src="https://img.shields.io/badge/Compression-69.52%25-blue"></a>
55+
<a href="" target="_blank" rel="noopener noreferrer"><img alt="Compression" src="https://img.shields.io/badge/Compression-70.18%25-blue"></a>
5656
<a href="" target="_blank" rel="noopener noreferrer"><img alt="Repo Size" src="https://img.shields.io/github/repo-size/t-wy/Wplace-BlueMarble-Userscripts"></a>
57-
<a href="" target="_blank" rel="noopener noreferrer"><img alt="Visitors" src="https://img.shields.io/badge/Visitors-354_340-gainsboro?style=flat"></a>
57+
<a href="" target="_blank" rel="noopener noreferrer"><img alt="Visitors" src="https://img.shields.io/badge/Visitors-439_667-gainsboro?style=flat"></a>
5858
<a href="" target="_blank" rel="noopener noreferrer"><img alt="Downloads" src="https://img.shields.io/github/downloads/t-wy/Wplace-BlueMarble-Userscripts/total.svg"></a>
5959
<a href="" target="_blank" rel="noopener noreferrer"><img alt="Build" src="https://github.com/t-wy/Wplace-BlueMarble-Userscripts/actions/workflows/build.yml/badge.svg"></a>
6060
<a href="" target="_blank" rel="noopener noreferrer"><img alt="Pages" src="https://github.com/t-wy/Wplace-BlueMarble-Userscripts/actions/workflows/pages/pages-build-deployment/badge.svg?branch=wiki"></a>
@@ -241,7 +241,8 @@
241241
<br>
242242
<img alt="Find template coordinates" src="https://github.com/t-wy/Wplace-BlueMarble-Userscripts/blob/main/docs/assets/TemplateCoordinates1.png"></li>
243243
<li>Upload a PNG or WEBP image.</li>
244-
<li>Click the "Enable" button.</li>
244+
<li>Click the "Create" button.</li>
245+
<li>If your template still does not show, try clicking the "Enable" button.</li>
245246
</ol>
246247
</p>
247248

@@ -254,7 +255,11 @@
254255
<p>
255256
<h4>Transparent Pixels</h4>
256257
<p>
257-
Templates for Blue Marble work slightly different from normal. Since there is a "Transparent" color, and transparent pixels in templates are typically ignored, your template should have a custom color to signify "Transparent" colored pixels. If a specific pixel can be any color, it should be transparent in the template. If a specific pixel should be "Transparent" color, it should have the <code>#deface</code> hex color. Any <code>#deface</code> colored pixel in your template will be interpereted as the "Transparent" color. Any transparent colored pixel in your template will be interpereted as ignored.
258+
Templates for Blue Marble work slightly different from normal. Since there is a "Transparent" color, and transparent pixels in templates are typically ignored, your template should have a custom color to signify "Transparent" colored pixels.
259+
<ul>
260+
<li>If you want a specific pixel to be any color, it should be transparent in your template.</li>
261+
<li>If you want a specific pixel to be the "Transparent" color on the Wplace palette, it should have the <code>#deface</code> hex color.</li>
262+
</ul>
258263
</p>
259264
<h4>Coordinates</h4>
260265
<p>
@@ -266,7 +271,7 @@
266271
</p>
267272
<h5>Template Coordinates</h5>
268273
<p>
269-
The template is aligned from the top left corner of the template. You can auto-fill this position using the "pin" icon next to the coordinate input boxes.
274+
The template is aligned from the top left corner of the template. You can auto-fill this position using the "pin" (also called "waypoint") icon next to the coordinate input boxes.
270275
</p>
271276
</p>
272277
</p>
@@ -299,6 +304,12 @@
299304
<h3>How do I hide the overlay?</h3>
300305
<p><b>A:</b> Turn the userscript off and refresh the page.</p>
301306

307+
<h3>How do I tell colors apart?</h3>
308+
<p><b>A:</b> Find the color in the color filter list. Click the checkbox to turn the color on or off. If you want to work on only one color at a time (recommended), then click "Disable All" in the color filter. Finally, enable the checkbox next to the color you want to place. This way, only one color on your template will appear at a time.</p>
309+
310+
<h3>How do get the color of a pixel?</h3>
311+
<p><b>A:</b> Use the eyedropper in the palette menu of wplace. If your template colors match the wplace palette, you can select the template pixel dot to get the template's color for that pixel.</p>
312+
302313
<h3>Why do game notifications appear on top of the overlay?</h3>
303314
<p><b>A:</b> Game notifications only appear when they need immediate attention. Therefore, they have priority over the overlay (which typically needs no attention).</p>
304315
</p>

package-lock.json

Lines changed: 14 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wplace-bluemarble",
3-
"version": "0.84.0",
3+
"version": "0.85.0",
44
"type": "module",
55
"homepage": "https://bluemarble.camilledaguin.fr/",
66
"repository": {

src/BlueMarble.meta.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// ==UserScript==
22
// @name Blue Marble
33
// @namespace https://github.com/SwingTheVine/
4-
// @version 0.84.0
4+
// @version 0.85.0
55
// @description A userscript to automate and/or enhance the user experience on Wplace.live. Make sure to comply with the site's Terms of Service, and rules! This script is not affiliated with Wplace.live in any way, use at your own risk. This script is not affiliated with TamperMonkey. The author of this userscript is not responsible for any damages, issues, loss of data, or punishment that may occur as a result of using this script. This script is provided "as is" under the MPL-2.0 license. The "Blue Marble" icon is licensed under CC0 1.0 Universal (CC0 1.0) Public Domain Dedication. The image is owned by NASA.
66
// @author SwingTheVine
77
// @license MPL-2.0
88
// @supportURL https://discord.gg/tpeBPy46hf
99
// @homepageURL https://bluemarble.camilledaguin.fr/
10-
// @icon https://raw.githubusercontent.com/t-wy/Wplace-BlueMarble-Userscripts/8d02ac9cbe8f6861248152f2b0d632a0b4a830ee/dist/assets/Favicon.png
10+
// @icon https://raw.githubusercontent.com/t-wy/Wplace-BlueMarble-Userscripts/051271c433a42db968a865b00f81bb979ee7d13f/dist/assets/Favicon.png
1111
// @updateURL https://raw.githubusercontent.com/t-wy/Wplace-BlueMarble-Userscripts/main/dist/BlueMarble.user.js
1212
// @downloadURL https://raw.githubusercontent.com/t-wy/Wplace-BlueMarble-Userscripts/main/dist/BlueMarble.user.js
1313
// @match https://wplace.live/*

src/Template.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,42 @@ export default class Template {
4646
this.storageKey = null; // Key used inside templatesJSON to persist settings
4747

4848
// Build allowed color set from site palette (exclude special Transparent entry by name)
49+
// Creates a Set of Wplace palette colors excluding "transparent"
4950
const allowed = Array.isArray(colorpalette) ? colorpalette : [];
5051
this.allowedColorsSet = new Set(
5152
allowed
52-
.filter(c => (c?.name || '').toLowerCase() !== 'transparent' && Array.isArray(c?.rgb))
53-
.map(c => `${c.rgb[0]},${c.rgb[1]},${c.rgb[2]}`)
53+
.filter(color => (color?.name || '').toLowerCase() !== 'transparent' && Array.isArray(color?.rgb))
54+
.map(color => `${color.rgb[0]},${color.rgb[1]},${color.rgb[2]}`)
5455
);
56+
5557
// Ensure template #deface marker is treated as allowed (maps to Transparent color)
5658
const defaceKey = '222,250,206';
5759
this.allowedColorsSet.add(defaceKey);
60+
61+
const keyOther = 'other';
62+
this.allowedColorsSet.add(keyOther); // Special "other" key for non-palette colors
63+
5864
// Map rgb-> {id, premium}
5965
this.rgbToMeta = new Map(
6066
allowed
61-
.filter(c => Array.isArray(c?.rgb))
62-
.map(c => [ `${c.rgb[0]},${c.rgb[1]},${c.rgb[2]}`, { id: c.id, premium: !!c.premium, name: c.name } ])
67+
.filter(color => Array.isArray(color?.rgb))
68+
.map(color => [ `${color.rgb[0]},${color.rgb[1]},${color.rgb[2]}`, { id: color.id, premium: !!color.premium, name: color.name } ])
6369
);
70+
6471
// Map #deface to Transparent meta for UI naming and ID continuity
6572
try {
66-
const transparent = allowed.find(c => (c?.name || '').toLowerCase() === 'transparent');
73+
const transparent = allowed.find(color => (color?.name || '').toLowerCase() === 'transparent');
6774
if (transparent && Array.isArray(transparent.rgb)) {
6875
this.rgbToMeta.set(defaceKey, { id: transparent.id, premium: !!transparent.premium, name: transparent.name });
6976
}
70-
} catch (_) {}
77+
} catch (ignored) {}
78+
79+
// Map other key to Other meta for UI naming and ID continuity
80+
try {
81+
this.rgbToMeta.set(keyOther, { id: 'other', premium: false, name: 'Other' });
82+
} catch (ignored) {}
83+
84+
console.log('Allowed colors for template:', this.allowedColorsSet);
7185
}
7286

7387
/** Creates chunks of the template for each tile.
@@ -112,9 +126,9 @@ export default class Template {
112126
const b = inspectData[idx + 2];
113127
const a = inspectData[idx + 3];
114128
if (a === 0) { continue; } // Ignored transparent pixel
115-
const key = `${r},${g},${b}`;
116129
if (r === 222 && g === 250 && b === 206) { deface++; }
117-
if (!this.allowedColorsSet.has(key)) { continue; } // Skip non-palette colors (but #deface added to allowed)
130+
const key = this.allowedColorsSet.has(`${r},${g},${b}`) ? `${r},${g},${b}` : 'other';
131+
//if (!this.allowedColorsSet.has(key)) { continue; } // Skip non-palette colors (but #deface added to allowed)
118132
required++;
119133
paletteMap.set(key, (paletteMap.get(key) || 0) + 1);
120134
}
@@ -228,7 +242,7 @@ export default class Template {
228242
const g = imageData.data[pixelIndex + 1];
229243
const b = imageData.data[pixelIndex + 2];
230244
if (!this.allowedColorsSet.has(`${r},${g},${b}`)) {
231-
imageData.data[pixelIndex + 3] = 0; // hide non-palette colors
245+
//imageData.data[pixelIndex + 3] = 0; // hide non-palette colors
232246
}
233247
}
234248
}

0 commit comments

Comments
 (0)