Create selective_paint.js

This commit is contained in:
SquareScreamYT 2024-03-21 13:52:54 +08:00 committed by GitHub
parent 248c7e6a11
commit 66beb26c16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 30 additions and 0 deletions

30
mods/selective_paint.js Normal file
View File

@ -0,0 +1,30 @@
selectivePaintElem = ""
elements.selective_paint = {
color: ["#c27070","#c29c70","#c2c270","#70c270","#70c2c2","#7070c2","#c270c2"],
onSelect: function() {
var answer = prompt("Please input the desired element to paint. It will not work if you enter multiple elements types while paused.",(selectivePaintElem||undefined));
if (!answer) { return }
selectivePaintElem = mostSimilarElement(answer);
},
tool: function(pixel) {
if (pixel.element == selectivePaintElem) {
if (!shiftDown) {
pixel.color = pixelColorPick(pixel,currentColor)
}
else {
// convert the hex of currentColor to rgb and set it as a string
var rgb = currentColor.replace("#","").match(/.{1,2}/g);
for (var i = 0; i < rgb.length; i++) {
rgb[i] = parseInt(rgb[i],16);
}
pixel.color = "rgb(" + rgb.join(",") + ")"
}
delete pixel.origColor;
}
},
customColor: true,
category: "tools",
canPlace: false,
excludeRandom:true,
desc: "Use on selected pixels to change their color."
}