diff --git a/lang/de.json b/lang/de.json
index fe290762..8bc8ce82 100644
--- a/lang/de.json
+++ b/lang/de.json
@@ -120,6 +120,8 @@
"freezer":"Frierer",
"pipe":"Rohr",
"pipe_wall":"Rohrwand",
+"mixer": "Mixer",
+"grinder": "Mühle",
"ewall":"E-Wand",
"torch":"Fackel",
"spout":"Auslauf",
@@ -173,6 +175,7 @@
"pinecone":"Tannenzapfen",
"evergreen":"Immergrün",
"cactus":"Kaktus",
+"kelp": "Seetang",
"seeds":"Samen",
"grass_seed":"Grassamen",
"wheat_seed":"Weizensamen",
@@ -216,6 +219,7 @@
"antimatter":"Antimaterie",
"plastic":"Plastik",
"molten_plastic":"Geschmolzenes_Plastik",
+"cloth": "Stoff",
"cellulose":"Zellulose",
"wax":"Wachs",
"melted_wax":"Geschmolzener_Wachs",
@@ -433,10 +437,11 @@
"bless":"Segnen",
"god_ray":"Gott_Strahl",
"heat_ray":"Hitzestrahl",
+"freeze_ray": "Frierstrahl",
+"pop": "Knall",
"explosion":"Explosion",
"n_explosion":"N-Explosion",
"supernova":"Supernova",
-"pop":"Knall",
"cook":"Kochen",
"incinerate":"verbrennen",
"room_temp":"Zimmertemperatur",
diff --git a/lang/template.json b/lang/template.json
index 0d5eb96e..030a601b 100644
--- a/lang/template.json
+++ b/lang/template.json
@@ -120,6 +120,8 @@
"freezer": "",
"pipe": "",
"pipe_wall": "",
+"mixer": "",
+"grinder": "",
"ewall": "",
"torch": "",
"spout": "",
@@ -173,6 +175,7 @@
"pinecone": "",
"evergreen": "",
"cactus": "",
+"kelp": "",
"seeds": "",
"grass_seed": "",
"wheat_seed": "",
@@ -216,6 +219,7 @@
"antimatter": "",
"plastic": "",
"molten_plastic": "",
+"cloth": "",
"cellulose": "",
"wax": "",
"melted_wax": "",
@@ -433,10 +437,11 @@
"bless": "",
"god_ray": "",
"heat_ray": "",
+"freeze_ray": "",
+"pop": "",
"explosion": "",
"n_explosion": "",
"supernova": "",
-"pop": "",
"cook": "",
"incinerate": "",
"room_temp": "",
@@ -540,4 +545,4 @@
"blaster": "",
"propane_ice": "",
"molten_caustic_potash": ""
-}
\ No newline at end of file
+}
diff --git a/lang/tok.json b/lang/tok_old.json
similarity index 100%
rename from lang/tok.json
rename to lang/tok_old.json
diff --git a/mods/a_mod_by_alice.js b/mods/a_mod_by_alice.js
index b8661677..8fa29b54 100644
--- a/mods/a_mod_by_alice.js
+++ b/mods/a_mod_by_alice.js
@@ -6,35 +6,25 @@ var allDependenciesExist = dependencyExistence.reduce(function(a,b) { return a &
if(allDependenciesExist) {
try {
//COMMON VARIABLES ##
-
const whiteColor = {r: 255, g: 255, b: 255};
const blackColor = {r: 0, g: 0, b: 0};
canvas = document.getElementsByTagName("canvas")[0];
ctx = canvas.getContext("2d");
-
//ESSENTIAL COMMON FUNCTIONS (CODE LIBRARY) ##
-
//DEBUGGING
-
function logAndReturn(thing) {
console.log(thing);
return thing
};
-
//URL
-
urlParams = new URLSearchParams(window.location.search);
-
//Objects
-
//getKeyByValue code by SO UncleLaz: https://stackoverflow.com/questions/9907419/how-to-get-a-key-in-a-javascript-object-by-its-value
//CC-BY-SA-4.0
function getKeyByValue(object, value) {
return Object.keys(object).find(key => object[key] === value);
};
-
//RNG
-
//Random integer from 0 to n
function randomIntegerFromZeroToValue(value) {
var absoluteValuePlusOne = Math.abs(value) + 1;
@@ -44,7 +34,6 @@ try {
return 0 - Math.floor(Math.random() * absoluteValuePlusOne)
};
};
-
//Random thing from array
function randomChoice(array) {
if(!array) { throw new Error("randomChoice: Array is undefined or missing!") }
@@ -53,12 +42,10 @@ try {
var randomIndex = randomIntegerFromZeroToValue(length - 1);
return array[randomIndex];
};
-
//Random 1 or -1
function randomSign() {
return Math.random() < 0.5 ? 1 : -1
};
-
//Random integer from m to n
function randomIntegerBetweenTwoValues(min,max) {
if(min > max) {
@@ -68,7 +55,6 @@ try {
};
return Math.floor(Math.random() * (max - min + 1)) + min
};
-
//cyrb128 idk where this comes from but it was in the same thread
function cyrb128(str) {
let h1 = 1779033703, h2 = 3144134277,
@@ -86,7 +72,6 @@ try {
h4 = Math.imul(h2 ^ (h4 >>> 19), 2716044179);
return [(h1^h2^h3^h4)>>>0, (h2^h1)>>>0, (h3^h1)>>>0, (h4^h1)>>>0];
}
-
function mulberry32(a) { //Mulberry32 implemented in JS from StackOverflow, https://gist.github.com/tommyettinger/46a874533244883189143505d203312c
return function() {
var t = a += 0x6D2B79F5;
@@ -95,7 +80,6 @@ try {
return ((t ^ t >>> 14) >>> 0) / 4294967296;
}
} //returns random function seeded with a
-
//Seeded randbetween
function seededRandBetween(min,max,randomFunction) {
if(min > max) {
@@ -105,9 +89,7 @@ try {
};
return Math.floor(randomFunction() * (max - min + 1)) + min
};
-
//Arrays
-
//Shallow array comparer by SO Tim Down: https://stackoverflow.com/a/10260204
//CC-BY-SA-3.0
function arraysIdentical(arr1, arr2) {
@@ -122,7 +104,6 @@ try {
};
return true;
};
-
function indexOf(arr, val, comparer) {
for (var i = 0, len = arr.length; i < len; ++i) {
if ( i in arr && comparer(arr[i], val) ) {
@@ -131,21 +112,17 @@ try {
};
return -1;
};
-
function averageNumericArray(array) {
var total = array.reduce(addTwoNumbers,0)
return total / array.length
};
-
function sumNumericArray(array) { //Sum of array numbers
return array.reduce((partialSum, a) => partialSum + a, 0);
};
-
function pad_array(arr,len,fill) { //https://stackoverflow.com/a/38851957
//console.log("Padding array");
return arr.concat(Array(len).fill(fill)).slice(0,len);
}
-
//Function to check if an array includes a given array by SO Johnny Tisdale: https://stackoverflow.com/a/60922255
//CC-BY-SA-4.0
function includesArray(parentArray, testArray) {
@@ -156,7 +133,6 @@ try {
};
return false;
};
-
function addArraysInPairs(array1,array2,fill=0) { //e.g. [1,2,3] + [10,0,-1] = [11,2,2]
//console.log("Adding in pairs: " + array1 + " and " + array2 + ".");
if(array1.length > array2.length) { //zero-padding
@@ -173,7 +149,6 @@ try {
//console.log("Added into " + tempArray + ".");
return tempArray;
};
-
function tryJoin(stringOrArray,joiner) {
//console.log(`tryJoin: ${stringOrArray}`);
if(typeof(stringOrArray) === "string") {
@@ -186,24 +161,18 @@ try {
throw new TypeError(`Unexpected type: ${typeof(stringOrArray)}`);
};
};
-
//Checks
-
//Element exists in the elements object
function elementExists(elementName) {
return typeof(elements[elementName]) === "object";
};
-
//Has a given state
function isState(elementName,inputState) {
if(!elementExists(elementName)) {
throw new Error(`Element ${elementName} doesn't exist`);
};
-
var infoState = elements[elementName].state;
-
if(infoState == undefined) { infoState = "undefined" };
-
if(inputState == undefined) { inputState = "undefined" };
if(inputState instanceof Array) {
var limit = 0;
@@ -212,14 +181,11 @@ try {
limit++;
};
};
-
if(inputState instanceof Array) {
return inputState.includes(infoState);
};
-
return infoState == inputState;
};
-
//Check if pixel of given element exists at given location
function hasPixel(x,y,elementInput) {
if(isEmpty(x,y,true)) { //if empty, it can't have a pixel
@@ -235,13 +201,11 @@ try {
if(!elementExists(elementInput)) { console.log(`hasPixel: Element "${elementInput}" doesn't exist`) };
return pixelMap[x][y].element === elementInput;
};
- };
+ };
};
-
//Is movable
var backupCategoryWhitelist = ["land","powders","weapons","food","life","corruption","states","fey","Fantastic Creatures","dyes","energy liquids","random liquids","random gases","random rocks"];
var backupElementWhitelist = ["mercury", "chalcopyrite_ore", "chalcopyrite_dust", "copper_concentrate", "fluxed_copper_concentrate", "unignited_pyrestone", "ignited_pyrestone", "everfire_dust", "extinguished_everfire_dust", "mistake", "polusium_oxide", "vaporized_polusium_oxide", "glowstone_dust", "redstone_dust", "soul_mud", "wet_soul_sand", "nitrogen_snow", "fusion_catalyst", "coal", "coal_coke", "blast_furnace_fuel", "molten_mythril"];
-
function commonMovableCriteria(name,shallowBlacklist=null) {
if(typeof(elements[name]) !== "object") {
throw new Error(`Nonexistent element ${name}`);
@@ -288,10 +252,8 @@ try {
};
return false;
};
-
//Element name search
window.searchQuery = {};
-
function searchElements(query) {
if(typeof(window.searchQuery) == "undefined") { window.searchQuery = "" }; //necessary because of filter's idiotic no-argument policy
window.searchQuery = query;
@@ -301,7 +263,6 @@ try {
});
return matches
};
-
function elementsWith(keyQuery) {
if(typeof(window.keyQuery) == "undefined") { window.keyQuery = "" }; //necessary because of filter's idiotic no-argument policy
window.keyQuery = keyQuery;
@@ -311,7 +272,6 @@ try {
});
return matches
};
-
function elementsWithout(keyInverseQuery) {
if(typeof(window.keyInverseQuery) == "undefined") { window.keyInverseQuery = "" }; //necessary because of filter's idiotic no-argument policy
window.keyInverseQuery = keyInverseQuery;
@@ -321,7 +281,6 @@ try {
});
return matches
};
-
function getElementsInCategory(categoryName) {
if(["",null,undefined].includes(categoryName)) { categoryName = "other" };
window.categoryQuery = categoryName;
@@ -331,7 +290,6 @@ try {
});
return matches
};
-
function getStateHigh(element,forceArray=false) {
if(!(element instanceof Array)) { element = [element] };
var existantElements = element.filter(function(name) { return elementExists(name) });
@@ -346,7 +304,6 @@ try {
return results
}
};
-
function getState(element,forceArray=false) {
if(!(element instanceof Array)) { element = [element] };
var existantElements = element.filter(function(name) { return elementExists(name) });
@@ -361,7 +318,6 @@ try {
return results
}
};
-
function getStateLow(element,forceArray=false) {
if(!(element instanceof Array)) { element = [element] };
var existantElements = element.filter(function(name) { return elementExists(name) });
@@ -376,7 +332,6 @@ try {
return results
}
};
-
function getStateAtTemp(element,temp) {
var data = elements[element];
var tl = data.tempLow;
@@ -389,7 +344,6 @@ try {
return element
}
};
-
function getBreakInto(element,forceArray=false) {
if(!(element instanceof Array)) { element = [element] };
var existantElements = element.filter(function(name) { return elementExists(name) });
@@ -404,14 +358,11 @@ try {
return results
}
};
-
//Math(s)
-
//Base n logarithm from https://stackoverflow.com/a/3019290
function logN(number,base) { //Vulnerable to float issues
return Math.log(number) / Math.log(base);
};
-
//Distance between points
function pyth(xA,yA,xB,yB) {
var a = Math.abs(xB - xA);
@@ -419,21 +370,17 @@ try {
var c = Math.sqrt(a**2 + b**2);
return c;
};
-
//Limit number to [min, max]
function bound(number,lowerBound,upperBound) {
return Math.min(upperBound,Math.max(lowerBound,number));
};
-
//Emergency color wrapper
rgbColorBound = function(color) {
return bound(color,0,255);
};
-
function addTwoNumbers(number1,number2) { //reducer
return number1 + number2
}
-
//Logistic curve
//x = real number
//L = maximum value
@@ -442,16 +389,13 @@ try {
function logisticCurve(x,L,k,x0) {
return L/( 1 + ( Math.E ** ( -k * (x - x0) ) ) );
};
-
// https://stackoverflow.com/questions/10756313/javascript-jquery-map-a-range-of-numbers-to-another-range-of-numbers
// Function from August Miller
//Map a range of numbers to another range of numbers
function scale (number, inMin, inMax, outMin, outMax) {
return (number - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
}
-
//Color
-
function rgbStringToUnvalidatedObject(string) { //turns rgb() to {r,g,b} with no bounds checking
//console.log("Splitting string into object");
string = string.split(",");
@@ -461,7 +405,6 @@ try {
//console.log("String split: outputs " + red + ", " + green + ", " + blue + ".");
return {r: red, g: green, b: blue};
};
-
function rgbStringToObject(string,doRounding=true,doBounding=true) { //turns rgb() to {r,g,b}
//console.log(`rgbStringToObject: ${string}`);
//console.log("Splitting string into object");
@@ -495,7 +438,6 @@ try {
//console.log("String split: outputs " + red + ", " + green + ", " + blue + ".");
return {r: red, g: green, b: blue};
};
-
function hslColorStringToObject(color) {
if(!color.startsWith("hsl(") || !color.endsWith(")")) {
throw new Error(`The color ${color} is not a valid hsl() color`)
@@ -521,7 +463,6 @@ try {
if(hueNaN || saturationNaN || lightnessNaN) { throw new Error(NanErrorString) };
return {h: hue, s: saturation, l: lightness};
};
-
function rgbToHex(color) {
//console.log(`rgbToHex called on ${typeof(color) === "object" ? JSON.stringify(color) : color}`);
if(typeof(color) == "object") { //Expects object like "{r: 172, g: 11, b: 34}"
@@ -592,7 +533,6 @@ try {
throw new Error(`Received invalid color: ${color}`);
};
};
-
function linearBlendTwoColorObjects(color1,color2,weight1=0.5) { /*third argument is for color1 and expects a float from 0
to 1, where 0 means "all color2" and 1 means "all color1"*/
var w1 = Math.min(Math.max(weight1,0),1);
@@ -607,7 +547,6 @@ try {
var blue3 = (blue1 * w1) + (blue2 * (1 - w1));
return {r: red3, g: green3, b: blue3};
};
-
function lightenColor(color,offset,outputType="rgb") {
if(typeof(color) === "string") {
if(color.length < 10) {
@@ -617,24 +556,20 @@ try {
color = "#" + color;
};
//console.log(`octothorpe checked: ${color}`);
-
offset = parseFloat(offset);
if(isNaN(offset)) {
throw new Error("Offset is NaN");
};
-
var oldColor = color; //for error display
color = hexToRGB(color);
if(color === null) {
throw new Error(`hexToRGB(color) was null (${oldColor}, maybe it's an invalid hex triplet?)`);
};
-
//console.log("converted color: " + JSON.stringify(color));
var red = color.r + offset;
var green = color.g + offset;
var blue = color.b + offset;
//console.log(`altered color: rgb(${red},${green},${blue})`);
-
//rounding and bounding
red = Math.round(red);
green = Math.round(green);
@@ -644,9 +579,7 @@ try {
green = bound(green,0,255)
blue = bound(blue,0,255)
//console.log(`bounded color: rgb(${red},${green},${blue})`);
-
color = {r: red, g: green, b: blue};
-
switch(outputType.toLowerCase()) {
case "rgb":
return `rgb(${red},${green},${blue})`;
@@ -664,17 +597,14 @@ try {
if(color.startsWith("rgb(")) {
color = convertColorFormats(color,"json"); //object conversion
//console.log(`color converted to object: ${JSON.stringify(color)}`);
-
offset = parseFloat(offset);
if(isNaN(offset)) {
throw new Error("Offset is NaN");
};
-
var red = color.r + offset;
var green = color.g + offset;
var blue = color.b + offset;
//console.log(`altered color: rgb(${red},${green},${blue})`);
-
//rounding and bounding
red = Math.round(red);
green = Math.round(green);
@@ -684,9 +614,7 @@ try {
green = bound(green,0,255)
blue = bound(blue,0,255)
//console.log(`bounded color: rgb(${red},${green},${blue})`);
-
color = {r: red, g: green, b: blue};
-
switch(outputType.toLowerCase()) {
case "rgb":
return `rgb(${red},${green},${blue})`;
@@ -710,13 +638,11 @@ try {
if(typeof(color.r) === "undefined" || typeof(color.g) === "undefined" || typeof(color.b) === "undefined") {
throw new Error("Color must be of the form {r: red, g: green, b: blue}");
};
-
//console.log("received color: " + JSON.stringify(color));
var red = color.r + offset;
var green = color.g + offset;
var blue = color.b + offset;
//console.log(`altered color: rgb(${red},${green},${blue})`);
-
//rounding and bounding
red = Math.round(red);
green = Math.round(green);
@@ -726,9 +652,7 @@ try {
green = bound(green,0,255)
blue = bound(blue,0,255)
//console.log(`bounded color: rgb(${red},${green},${blue})`);
-
color = {r: red, g: green, b: blue};
-
switch(outputType.toLowerCase()) {
case "rgb":
return `rgb(${red},${green},${blue})`;
@@ -744,7 +668,6 @@ try {
};
};
};
-
function rgbObjectToString(color,stripAlpha=false) {
if(typeof(color) !== "object") {
throw new Error("Input color is not an object");
@@ -763,7 +686,6 @@ try {
//console.log(`Colors bounded to (${red}, ${green}, ${blue})`);
return `rgb(${red},${green},${blue})`
};
-
function convertColorFormats(color,outputType="rgb",stripAlpha=false) {
if(typeof(color) === "undefined") {
//console.log("Warning: An element has an undefined color. Unfortunately, due to how the code is structured, I can't say which one.");
@@ -775,34 +697,44 @@ try {
var bytes,r,g,b,a;
if(typeof(color) === "string") {
//Hex input case
-
- if(color.length < 10) {
- //a proper hex quadruplet is still shorter than the shortest proper rgb() string
- //console.log(`detected as hex: ${color}`);
- //catch missing octothorpes
- if(!color.startsWith("#")) {
- color = "#" + color;
- };
- //console.log(`octothorpe checked: ${color}`);
-
- if(oldColor.length < 6) {
- bytes = oldColor.toLowerCase().match(/[a-z0-9]/g).map(x => parseInt(x.concat(x),16));
- } else {
- bytes = oldColor.toLowerCase().match(/[a-z0-9]{2}/g).map(x => parseInt(x,16));
+ if(/^#?[A-Za-z0-9]{1,8}$/.test(oldColor)) {
+ if(color.startsWith("#")) {
+ oldColor = oldColor.match(/[A-Za-z0-9]{1,8}/)[0];
};
+ switch(oldColor.length) {
+ case 0:
+ throw new Error("convertColorFormats: hexadecimal input but color bytes are somehow missing?");
+ case 1: //A => AAAAAA (bs)
+ oldColor = oldColor.repeat(6);
+ break
+ case 2: //AB => AAAAAABB (bs)
+ oldColor = (oldColor[0].repeat(6)) + (oldColor[1].repeat(2));
+ break
+ case 3: //ABC => AABBCC, ABCD => AABBCCDD (real)
+ case 4:
+ oldColor = oldColor.match(/[A-Za-z0-9]/g).map(x => x.repeat(2)).join("")
+ break
+ case 5: //ABCDE => AABBCCDE (bs)
+ var _rgb = oldColor.slice(0,3);
+ var _alpha = oldColor.slice(3,5);
+ oldColor = (_rgb.match(/[A-Za-z0-9]/g).map(x => x.repeat(2)).join("")) + alpha
+ case 7: //9ABCDEF => 9ABCDEFF (bs)
+ var _rgb = oldColor.slice(0,6);
+ var _alpha = oldColor.slice(6,7);
+ oldColor = _rgb + (_alpha.repeat(2))
+ case 6: //no change
+ case 8: //no change
+ break
+ };
+ bytes = oldColor.toLowerCase().match(/[a-z0-9]{2}/g).map(x => parseInt(x,16));
r = bytes[0];
g = bytes[1];
b = bytes[2];
- if(bytes.length > 3) {
- a = bytes[3] / 255;
- } else {
- a = null
- };
- if(stripAlpha) { a = null };
+ a = stripAlpha ? null : (bytes[3] ?? null);
//to JSON for ease of use
color = {"r": r, "g": g, "b": b};
if(typeof(a) == "number") { color["a"] = a };
- } else {
+ } else {
//otherwise assume rgb() input
bytes = color.match(/[\d\.]+/g);
if(typeof(bytes?.map) == "undefined") {
@@ -814,15 +746,7 @@ try {
r = bytes[0];
g = bytes[1];
b = bytes[2];
- if(bytes.length > 3) {
- a = bytes[3];
- if(a > 1) {
- a /= 255
- }
- } else {
- a = null
- };
- if(stripAlpha) { a = null };
+ a = stripAlpha ? null : (bytes[3] ?? null);
//to JSON for ease of use
color = {"r": r, "g": g, "b": b}
if(typeof(a) == "number") { color["a"] = a };
@@ -832,15 +756,7 @@ try {
r = bytes[0];
g = bytes[1];
b = bytes[2];
- if(bytes.length > 3) {
- a = bytes[3];
- if(a > 1) {
- a /= 255
- }
- } else {
- a = null
- };
- if(stripAlpha) { a = null };
+ a = stripAlpha ? null : (bytes[3] ?? null);
//to JSON for ease of use
color = {"r": r, "g": g, "b": b}
if(typeof(a) == "number") { color["a"] = a };
@@ -849,15 +765,10 @@ try {
r = color.r;
g = color.g;
b = color.b;
- if(typeof(color.a) == "number") {
- a = color.a;
- } else {
- a = null
- };
- if(stripAlpha) { a = null }
+ a = stripAlpha ? null : (color.a ?? null);
};
//Colors are now objects
-
+ if(a !== null) { a /= 255 };
switch(outputType.toLowerCase()) {
case "rgb":
case "rgba":
@@ -898,16 +809,12 @@ try {
throw new Error("outputType must be \"rgb\", \"hex\", \"json\", or \"array\"");
}
};
-
function rgbHexCatcher(color) {
return convertColorFormats(color,"rgb");
};
-
function _rgbHexCatcher(color) {
return convertColorFormats(color,"rgb");
};
-
-
function averageColorObjects(color1,color2,weight1=0.5) { //misnomer, actually a linear interpolation but it's too late to rename that
//third argument is for color1 and expects a float from 0 to 1, where 0 means "all color2" and 1 means "all color1"
//(backwards from how it should work)
@@ -923,14 +830,12 @@ try {
var blue3 = (blue1 * w1) + (blue2 * (1 - w1))
return {r: red3, g: green3, b: blue3}
};
-
function lerpColors(color1,color2,outputType="rgb",weight1=0.5) {
color1 = convertColorFormats(color1,"json");
color2 = convertColorFormats(color2,"json");
theColor = averageColorObjects(color1,color2,weight1);
return convertColorFormats(theColor,outputType);
};
-
function multiplyColors(color1,color2,outputType="rgb") {
//normalize rgb()/hex by turning any hex into rgb() and then rgb()s to {r,g,b}
if(typeof(color1) !== "object") {
@@ -957,7 +862,6 @@ try {
throw new Error("outputType must be \"rgb\", \"hex\", \"json\"");
};
};
-
function divideColors(color1,color2,outputType="rgb") { //color2 is the divisor and color1 the dividend (base/original color)
//normalize rgb()/hex by turning any hex into rgb() and then rgb()s to {r,g,b}
if(typeof(color1) !== "object") {
@@ -987,7 +891,6 @@ try {
throw new Error("outputType must be \"rgb\", \"hex\", \"json\"");
};
};
-
function addColors(color1,color2,outputType="rgb") {
//normalize rgb()/hex by turning any hex into rgb() and then rgb()s to {r,g,b}
if(typeof(color1) !== "object") {
@@ -1014,7 +917,6 @@ try {
throw new Error("outputType must be \"rgb\", \"hex\", \"json\"");
};
};
-
function subtractColors(color1,color2,outputType="rgb") {
//normalize rgb()/hex by turning any hex into rgb() and then rgb()s to {r,g,b}
if(typeof(color1) !== "object") {
@@ -1041,7 +943,6 @@ try {
throw new Error("outputType must be \"rgb\", \"hex\", \"json\"");
};
};
-
function averageRgbPrefixedColorArray(colorArray,returnObject=false) { //array of rgb()s to single rgb() of average color
//averageRgbPrefixedColorArray(["rgb(255,0,0)", "rgb(0,0,0)", "rgb(0,0,255)"]);
//console.log("Averaging started");
@@ -1052,7 +953,7 @@ try {
//console.log("Average function: Executing catcher on " + colorArray);
var color = convertColorFormats(colorArray[k]);
//console.log("Logged color for aRPCA: " + color);
- color = color.split(",");
+ color = color.split(",");
var red = parseFloat(color[0].substring(4));
reds.push(red)
var green = parseFloat(color[1]);
@@ -1063,25 +964,22 @@ try {
redAverage = Math.round(averageNumericArray(reds));
greenAverage = Math.round(averageNumericArray(greens));
blueAverage = Math.round(averageNumericArray(blues));
- var output;
+ var output;
returnObject ? output = {r: redAverage, g: greenAverage, b: blueAverage} : output = `rgb(${redAverage},${greenAverage},${blueAverage})`;
//console.log("Averaging finished, product: " + output);
return output;
};
-
//https://stackoverflow.com/questions/46432335/hex-to-hsl-convert-javascript
function rgbStringToHSL(rgb,outputType="array") { //Originally a hex-to-HSL function, edited to take RGB and spit out an array
//console.log("HSLing some RGBs");
var result = rgbStringToUnvalidatedObject(rgb);
-
var r = result.r;
var g = result.g;
var b = result.b;
-
- r /= 255, g /= 255, b /= 255;
+ var a = result.a ?? null;
+ r /= 255, g /= 255, b /= 255; if(a) { a /= 255 };
var max = Math.max(r, g, b), min = Math.min(r, g, b);
var h, s, l = (max + min) / 2;
-
if(max == min){
h = s = 0; // achromatic
} else {
@@ -1094,32 +992,29 @@ try {
}
h /= 6;
};
-
s = s*100;
s = Math.round(s);
l = l*100;
l = Math.round(l);
h = Math.round(360*h);
-
+ if(a !== null && a > 1) { a /= 255 };
//var colorInHSL = 'hsl(' + h + ', ' + s + '%, ' + l + '%)';
//Edit to return an array
switch(outputType.toLowerCase()) {
case "array":
- return [h,s,l];
+ return a == null ? [h,s,l] : [h,s,l,a];
break;
case "hsl":
- return `hsl(${h},${s}%,${l}%)`;
+ return a == null ? `hsl(${h},${s}%,${l}%)` : `hsla(${h},${s}%,${l}%,${a})`;
break;
case "json":
- return {h: h, s: s, l: l};
+ return a == null ? {h: h, s: s, l: l} : {h: h, s: s, l: l, a: a};
default:
throw new Error("outputType must be \"array\", \"hsl\", or \"json\"");
- break;
+ break;
};
//console.log("HSL output "+ colorInHSL + ".");
-
};
-
function normalizeColorToHslObject(color,arrayType=null) {
var ambiguousArrayError = "changeSaturation can't tell if the array input is supposed to be RGB or HSL. Please use an \"arrayType\" argument of \"rgb\" or \"hsl\".";
var isHsl = false;
@@ -1127,26 +1022,26 @@ try {
if(arrayType === null) {
throw new Error(ambiguousArrayError);
} else if(arrayType === "rgb") {
- color = `rgb(${color[0]},${color[1]},${color[2]})`;
+ color = color.length > 3 ? `rgba(${color[0]},${color[1]},${color[2]},${color[3]})` : `rgb(${color[0]},${color[1]},${color[2]})`;
color = rgbStringToHSL(color,"json"); //rgb arr to hsl obj
} else if(arrayType === "hsl") {
- color = {h: color[0], s: color[1], l: color[2]}; //hsl arr to hsl obj
+ color = color.length > 3 ? {h: color[0], s: color[1], l: color[2], a: color[3]} : {h: color[0], s: color[1], l: color[2]}; //hsl arr to hsl obj
} else {
throw new Error(ambiguousArrayError);
};
} else {
- //by this point, any array cases would have been handled, leaving just hex (rgb), json rgb, json hsl, string rgb, and string hsl
+ //by this point, any array cases would have been handled, leaving just hex (rgb), json rgb, json hsl, string rgb, and string hsl
if(typeof(color) === "string") {
- if(color.length < 10) { //detect hex: assume hex triplet if too short to be a well-formed rgb()
+ if(/^#?[A-Za-z0-9]{1,8}$/.test(color)) { //detect hex
if(!color.startsWith("#")) {
color = "#" + color; //catch missing #
};
isHsl = false;
};
- if(color.startsWith("rgb(")) { //detect rgb(): self-explanatory
+ if(color.startsWith("rgb")) { //detect rgba?(): self-explanatory
isHsl = false;
};
- if(color.startsWith("hsl(")) { //detect hsl(): self-explanatory
+ if(color.startsWith("hsl")) { //detect hsla?(): self-explanatory
isHsl = true;
};
} else if(typeof(color) === "object") {
@@ -1166,9 +1061,8 @@ try {
};
};
};
- return color;
+ return color;
};
-
function convertHslObjects(color,outputType="rgb") {
if(color == null) { console.error("convertHslObjects: Color is null"); color = {h: 300, s: 100, l: 50} };
switch(outputType.toLowerCase()) {
@@ -1185,13 +1079,13 @@ try {
case "rgb-json":
case "rgb_json":
color = hexToRGB(hslToHex(...Object.values(color))); //hsl to hex and hex to rgb_json
- return color;
+ return color;
break;
case "rgbarray":
case "rgb-array":
case "rgb_array":
color = hexToRGB(hslToHex(...Object.values(color))); //hsl to hex, hex to rgb_json, and rgb_json to rgb_array
- return [color.r, color.g, color.b];
+ return [color.r, color.g, color.b];
break;
//HSL cases
case "hsl":
@@ -1201,22 +1095,20 @@ try {
case "hsljson":
case "hsl-json":
case "hsl_json":
- return color;
+ return color;
break;
case "hslarray":
case "hsl-array":
case "hsl_array":
- return [color.h, color.s, color.l];
+ return [color.h, color.s, color.l];
break;
default:
throw new Error("outputType must be \"rgb\", \"hex\", \"rgb_json\", \"rgb_array\", \"hsl\", \"hsl_json\", or \"hsl_array\"");
}
};
-
function changeSaturation(color,saturationChange,operationType="add",outputType="rgb",arrayType=null,doRounding=true) {
color = normalizeColorToHslObject(color,arrayType);
//only {h,s,l} should exist now
-
//Math
switch(operationType.toLowerCase()) {
case "+":
@@ -1255,18 +1147,14 @@ try {
default:
throw new Error("Operation must be \"add\", \"subtract\", \"multiply\", \"divide\", \"set\", \"min\", or \"max\"");
};
-
color.h = doRounding ? Math.round(color.h % 360) : color.h % 360;
color.s = doRounding ? Math.round(bound(color.s,0,100)) : color.s,0,100;
color.l = doRounding ? Math.round(bound(color.l,0,100)) : color.l,0,100;
-
return convertHslObjects(color,outputType)
};
-
function changeLuminance(color,luminanceChange,operationType="add",outputType="rgb",arrayType=null,doRounding=true) {
color = normalizeColorToHslObject(color,arrayType);
//only {h,s,l} should exist now
-
//Math
switch(operationType.toLowerCase()) {
case "+":
@@ -1305,18 +1193,14 @@ try {
default:
throw new Error("Operation must be \"add\", \"subtract\", \"multiply\", \"divide\", \"set\", \"min\", or \"max\"");
};
-
color.h = doRounding ? Math.round(color.h % 360) : color.h % 360;
color.s = doRounding ? Math.round(bound(color.s,0,100)) : color.s,0,100;
color.l = doRounding ? Math.round(bound(color.l,0,100)) : color.l,0,100;
-
return convertHslObjects(color,outputType);
};
-
function changeHue(color,hueChange,operationType="add",outputType="rgb",arrayType=null,doRounding=true) {
color = normalizeColorToHslObject(color,arrayType);
//only {h,s,l} should exist now
-
//Math
switch(operationType.toLowerCase()) {
case "+":
@@ -1355,14 +1239,11 @@ try {
default:
throw new Error("Operation must be \"add\", \"subtract\", \"multiply\", \"divide\", \"set\", \"min\", or \"max\"");
};
-
color.h = doRounding ? Math.round(color.h % 360) : color.h % 360;
color.s = doRounding ? Math.round(bound(color.s,0,100)) : color.s,0,100;
color.l = doRounding ? Math.round(bound(color.l,0,100)) : color.l,0,100;
-
return convertHslObjects(color,outputType);
};
-
function colorToHsl(color,outputType="json") {
if(typeof(color.h) == "number" && typeof(color.s) == "number" && typeof(color.l) == "number") {
return color
@@ -1371,7 +1252,6 @@ try {
color = rgbStringToHSL(color,outputType);
return color;
};
-
//https://stackoverflow.com/questions/36721830/convert-hsl-to-rgb-and-hex
function hslToHex(h, s, l) { //h, s, l params to hex triplet
//console.log(`Hexing some HSLs (the HSLs are ${h},${s},${l})`)
@@ -1387,19 +1267,15 @@ try {
//console.log(`Hexed to #${f(0)}${f(8)}${f(4)}`)
return `#${f(0)}${f(8)}${f(4)}`;
};
-
//Pixels
-
function tryMoveAndReturnBlockingPixel(pixel,nx,ny,leaveBehind,force) {
if(outOfBounds(nx,ny)) { return false };
if(isEmpty(nx,ny,false)) { return tryMove(pixel,nx,ny,leaveBehind,force) };
return pixelMap[nx][ny]
};
-
- function exposedToAir(pixel) {
+ function exposedToAir(pixel) {
return (isEmpty(pixel.x+1,pixel.y) || isEmpty(pixel.x-1,pixel.y) || isEmpty(pixel.x,pixel.y+1) || isEmpty(pixel.x,pixel.y-1));
};
-
function tryTarnish(pixel,element,chance) {
if(exposedToAir(pixel)) {
if(Array.isArray(element)) {
@@ -1413,7 +1289,6 @@ try {
};
};
};
-
//Try to create a pixel, return true if it could be created and false if it couldn't
function tryCreatePixel(elementInput,x,y) {
//array handling
@@ -1427,12 +1302,10 @@ try {
if(elementInput.length === 0) { throw new Error("elementInput has no existing elements") };
elementInput = randomChoice(elementInput);
};
-
//existence check
if(!elementExists(elementInput)) {
throw new Error("Element " + elementInput + " doesn't exist!");
};
-
//actual creation check
if(isEmpty(x,y)) {
createPixel(elementInput,x,y);
@@ -1441,7 +1314,6 @@ try {
return false;
};
};
-
function tryCreatePixelReturn(elementInput,x,y) {
//array handling
if(elementInput.includes(",")) { //CSTA
@@ -1454,12 +1326,10 @@ try {
if(elementInput.length === 0) { throw new Error("elementInput has no existing elements") };
elementInput = randomChoice(elementInput);
};
-
//existence check
if(!elementExists(elementInput)) {
throw new Error("Element " + elementInput + " doesn't exist!");
};
-
//actual creation check
if(isEmpty(x,y)) {
return createPixelReturn(elementInput,x,y);
@@ -1467,7 +1337,6 @@ try {
return false;
};
};
-
function createPixelReturn(elementIn,x,y) { //sugar
var element = elementIn; while(element instanceof Array) { element = randomChoice(element) };
var newPixel = new Pixel(x, y, element);
@@ -1475,7 +1344,6 @@ try {
checkUnlock(element);
return newPixel;
};
-
function changePixelReturn(pixel,element,changetemp=true) {
if(typeof(elements[element]) == "undefined") {
if(doLog) { console.error(`Something tried to change a pixel of ${pixel.element} at (${pixel.x},${pixel.y}) to nonexistent element "${element}"`) };
@@ -1532,7 +1400,6 @@ try {
checkUnlock(element);
return pixel;
};
-
function storeFirstTouchingElement(pixel,propertyName,copyTemp=true,spread=true) {
var info = elements[pixel.element];
if(pixel[propertyName]) {
@@ -1540,7 +1407,6 @@ try {
};
for(i = 0; i < adjacentCoords.length; i++) {
var newCoords = {x: pixel.x+adjacentCoords[i][0], y: pixel.y+adjacentCoords[i][1]};
-
if (!isEmpty(newCoords.x,newCoords.y,true)) {
newPixel = pixelMap[newCoords.x][newCoords.y];
if (info.ignore && info.ignore.indexOf(newPixel.element) !== -1) {
@@ -1559,7 +1425,6 @@ try {
}
};
};
-
function breakPixel(pixel,changeTemp=false,defaultBreakIntoDust=false) {
var result = elements[pixel.element].breakInto;
if (result === undefined) {if(defaultBreakIntoDust) { result = "dust" } else { return }};
@@ -1581,7 +1446,6 @@ try {
changePixel(pixel,result);
}
}
-
defaultHardness = 0.3;
function tryBreak(pixel,changetemp=false,defaultBreakIntoDust=false) {
var info = elements[pixel.element];
@@ -1596,7 +1460,6 @@ try {
return false;
};
};
-
function reactionStealer(pixel,newPixel,reactionTarget) {
if(!elements[reactionTarget]) {
throw new Error(`No such element ${reactionTarget}!`);
@@ -1615,7 +1478,6 @@ try {
var pixel2 = pixel;
var pixel1 = newPixel;
var r = newInfo.reactions[reactionTarget];
-
if (r.setting && settings[r.setting]===0) {
return false;
}
@@ -1642,7 +1504,6 @@ try {
if (Array.isArray(r.elem1)) {
var elem1 = r.elem1[Math.floor(Math.random() * r.elem1.length)];
} else { var elem1 = r.elem1; }
-
if (elem1 == null) {
deletePixel(pixel1.x,pixel1.y);
}
@@ -1650,22 +1511,23 @@ try {
changePixel(pixel1,elem1);
}
}
- if (r.charge1) { pixel1.charge = r.charge1; }
- if (r.temp1) { pixel1.temp += r.temp1; pixelTempCheck(pixel1); }
- if (r.color1) { // if it's a list, use a random color from the list, else use the color1 attribute
- pixel1.color = pixelColorPick(pixel1, Array.isArray(r.color1) ? r.color1[Math.floor(Math.random() * r.color1.length)] : r.color1);
- }
- if (r.attr1) { // add each attribute to pixel1
- for (var key in r.attr1) {
- pixel1[key] = r.attr1[key];
+ if(pixel1) {
+ if (r.charge1) { pixel1.charge = r.charge1; }
+ if (r.temp1) { pixel1.temp += r.temp1; pixelTempCheck(pixel1); }
+ if (r.color1) { // if it's a list, use a random color from the list, else use the color1 attribute
+ pixel1.color = pixelColorPick(pixel1, Array.isArray(r.color1) ? r.color1[Math.floor(Math.random() * r.color1.length)] : r.color1);
}
- }
+ if (r.attr1) { // add each attribute to pixel1
+ for (var key in r.attr1) {
+ pixel1[key] = r.attr1[key];
+ }
+ }
+ };
if (r.elem2 !== undefined) {
// if r.elem2 is an array, set elem2 to a random element from the array, otherwise set it to r.elem2
if (Array.isArray(r.elem2)) {
var elem2 = r.elem2[Math.floor(Math.random() * r.elem2.length)];
} else { var elem2 = r.elem2; }
-
if (elem2 == null) {
deletePixel(pixel2.x,pixel2.y);
}
@@ -1673,20 +1535,23 @@ try {
changePixel(pixel2,elem2);
}
}
- if (r.charge2) { pixel2.charge = r.charge2; }
- if (r.temp2) { pixel2.temp += r.temp2; pixelTempCheck(pixel2); }
- if (r.color2) { // if it's a list, use a random color from the list, else use the color2 attribute
- pixel2.color = pixelColorPick(pixel2, Array.isArray(r.color2) ? r.color2[Math.floor(Math.random() * r.color2.length)] : r.color2);
- }
- if (r.attr2) { // add each attribute to pixel2
- for (var key in r.attr2) {
- pixel2[key] = r.attr2[key];
+ if(pixel2) {
+ if (r.charge2) { pixel2.charge = r.charge2; }
+ if (r.temp2) { pixel2.temp += r.temp2; pixelTempCheck(pixel2); }
+ if (r.color2) { // if it's a list, use a random color from the list, else use the color2 attribute
+ pixel2.color = pixelColorPick(pixel2, Array.isArray(r.color2) ? r.color2[Math.floor(Math.random() * r.color2.length)] : r.color2);
}
+ if (r.attr2) { // add each attribute to pixel2
+ for (var key in r.attr2) {
+ pixel2[key] = r.attr2[key];
+ }
+ }
+ };
+ if(pixel1 && pixel2) {
+ if (r.func) { r.func(pixel1,pixel2); }
}
- if (r.func) { r.func(pixel1,pixel2); }
return r.elem1!==undefined || r.elem2!==undefined;
};
-
function spreadingProperty(pixel,propertyName,whitelist=null) {
if(isNaN(pixel[propertyName])) {
pixel[propertyName] = 0;
@@ -1716,7 +1581,6 @@ try {
};
return true;
};
-
function spreadingPropertyReturn(pixel,propertyName,whitelist=null) {
if(isNaN(pixel[propertyName])) {
pixel[propertyName] = 0;
@@ -1748,7 +1612,6 @@ try {
};
return recipients;
};
-
function swapNumericPropertyValues(pixel1,pixel2,propertyName,whitelist=null) {
if(!pixel1 || !pixel2) {
return false;
@@ -1766,13 +1629,10 @@ try {
};
return true;
};
-
//World
-
function getCirclePixels(x,y,radius) {
return circleCoords(x,y,radius).map(coordinates => pixelMap[coordinates.x]?.[coordinates.y]).filter(function(pixelOrUndefined) { return typeof(pixelOrUndefined) == "object" })
};
-
function getPixelMooreNeighbors(pixel) {
var coordsToCheck = mooreDonutCoords.map(function(offsets) { return {x: offsets[0]+pixel.x, y: offsets[1]+pixel.y} } );
var neighbors = [];
@@ -1791,7 +1651,6 @@ try {
};
return neighbors
};
-
function clonePixel(pixel,newX,newY,replaceExistingPixel=false,returnPixel=false) {
if(!pixel) { return false };
if(outOfBounds(newX,newY)) { return false };
@@ -1799,7 +1658,7 @@ try {
//Do nothing
} else {
if(replaceExistingPixel) {
- deletePixel(newX,newY)
+ deletePixel(newX,newY)
} else {
return false
}
@@ -1810,7 +1669,57 @@ try {
currentPixels.push(newPixel);
return returnPixel ? newPixel : true
};
-
+ clonedPixel = null;
+ elements.clone_painter_picker = {
+ color: "#ffffff",
+ tool: function(pixel) {
+ var newPixel = structuredClone ? structuredClone(pixel) : JSON.parse(JSON.stringify(pixel));
+ delete newPixel.x;
+ delete newPixel.y;
+ clonedPixel = newPixel;
+ logMessage(`Selected the pixel of ${pixel.element} from (${pixel.x},${pixel.y})`);
+ selectElement("clone_painter")
+ },
+ tick: function(pixel) {
+ if(clonedPixel) {
+ adjacentCoords.forEach(function(offsetPair) {
+ var finalCoords = [offsetPair[0] + pixel.x,offsetPair[1] + pixel.y];
+ clonePixel(clonedPixel,...finalCoords)
+ });
+ }
+ },
+ onSelect: function() {
+ if(!clonedPixel) {
+ logMessage("Select the pixel you want to duplicate");
+ }
+ },
+ maxSize: 1,
+ category: "special",
+ state: "solid",
+ density: 150000,
+ desc: "This selects the pixel that the clone_painter element will duplicate."
+ };
+ elements.clone_painter = {
+ color: "#ffffff",
+ tick: function(pixel) {
+ var x = pixel.x; //they need to be used after the pixel is removed
+ var y = pixel.y;
+ deletePixel(x,y);
+ if(clonedPixel) {
+ clonePixel(clonedPixel,x,y)
+ };
+ return
+ },
+ category: "tools",
+ density: 150000,
+ onSelect: function() {
+ if(!clonedPixel) {
+ logMessage("Please select a pixel to clone using the clone painter picker");
+ selectElement("clone_painter_picker")
+ }
+ },
+ desc: `This places (or due to how elements work, changes itself into) duplicates of a previously selected pixel.
Click here to select the clone painter picker to choose which pixel to clone`
+ };
function cloneArea(topLeftX,topLeftY,bottomRightX,bottomRightY,newTopLeftX,newTopLeftY,oldPixelHandling_PreClear1_OnlyReplace2_Ignore3=1,errorOnOutOfBounds=false) {
var results = {"created": 0, "replaced": 0, "deleted": 0, "skipped": 0, "skipped_OOB": 0};
for(var x = topLeftX; x <= bottomRightX; x++) {
@@ -1873,7 +1782,6 @@ try {
};
return results
};
-
function getEmptyVonNeumannNeighbors(pixel) {
var neighbors = [];
var x = pixel.x;
@@ -1887,7 +1795,6 @@ try {
};
return neighbors
};
-
function getEmptyMooreNeighbors(pixel) {
var neighbors = [];
var x = pixel.x;
@@ -1901,12 +1808,36 @@ try {
};
return neighbors
};
-
+ function getVonNeumannNeighbors(pixel) {
+ var neighbors = [];
+ var x = pixel.x;
+ var y = pixel.y;
+ for(var i = 0; i < adjacentCoords.length; i++) {
+ var finalX = pixel.x + adjacentCoords[i][0];
+ var finalY = pixel.y + adjacentCoords[i][1];
+ if(!isEmpty(finalX,finalY,true)) {
+ neighbors.push(pixelMap[finalX][finalY])
+ };
+ };
+ return neighbors
+ };
+ function getMooreNeighbors(pixel) {
+ var neighbors = [];
+ var x = pixel.x;
+ var y = pixel.y;
+ for(var i = 0; i < mooreDonutCoords.length; i++) {
+ var finalX = pixel.x + mooreDonutCoords[i][0];
+ var finalY = pixel.y + mooreDonutCoords[i][1];
+ if(!isEmpty(finalX,finalY,true)) {
+ neighbors.push(pixelMap[finalX][finalY])
+ };
+ };
+ return neighbors
+ };
function breakCircle(x,y,radius,respectHardness=false,changeTemp=false,defaultBreakIntoDust=false) {
var coords = getCirclePixels(x,y,radius);
coords.forEach(pixel => respectHardness ? tryBreak(pixel,changeTemp,defaultBreakIntoDust) : breakPixel(pixel,changeTemp,defaultBreakIntoDust))
};
-
function fillCircle(element,x,y,radius,overwrite=false) {
var coords = circleCoords(x,y,radius);
var newElement = element;
@@ -1924,7 +1855,6 @@ try {
};
};
};
-
function fillCircleReturn(element,x,y,radius,overwrite=false) {
//console.log("fcr");
var pixels = [];
@@ -1955,7 +1885,6 @@ try {
//console.log(pixels.map(x => x.element));
return pixels;
};
-
function isOpenAndOnSurface(x,y,includeBottomBound=true) {
if(!isEmpty(x,y,false)) {
return false;
@@ -1965,7 +1894,6 @@ try {
};
return !isEmpty(x,y+1,true);
};
-
//Freeze pixel
function freezePixel(pixel,changetemp=true) {
var info = elements[pixel.element];
@@ -1983,15 +1911,12 @@ try {
return false;
};
};
-
while(result instanceof Array) {
result = randomChoice(result);
};
-
changePixel(pixel,result,changetemp);
return true;
};
-
//Melt pixel
function meltPixel(pixel,changetemp=true) {
var info = elements[pixel.element];
@@ -2009,17 +1934,13 @@ try {
return false;
};
};
-
while(result instanceof Array) {
result = randomChoice(result);
};
-
changePixel(pixel,result,changetemp);
return true;
};
-
//Logic
-
function xor(c1,c2) {
if(!!c1 && !c2) {
return true;
@@ -2029,9 +1950,7 @@ try {
return false;
};
};
-
//currentPixels operations
-
function findInCurrentPixels(x,y) {
var pixel = currentPixels.filter(function(pixelObject) {
return pixelObject.x == x && pixelObject.y == y;
@@ -2045,21 +1964,16 @@ try {
pixel = pixel[0];
return pixel;
};
-
function filterCurrentPixels(filterFunction) {
return currentPixels.filter(filterFunction);
};
-
//Filter test functions
-
function _filterTest_xIsTwenty(pixel) {
return pixel.x == 20;
};
-
function _filterTest_tempIsOdd(pixel) {
return Math.trunc(pixel.temp) % 2 == 1;
};
-
function _filterTest_redRock(pixel) {
var color = rgbStringToHSL(convertColorFormats(pixel.color,"rgb"),"json");
var isRed = ((color.h % 360) >= 350) || ((color.h % 360) <= 10);
@@ -2067,8 +1981,7 @@ try {
var isBright = (color.l > 20);
return isRed && isVivid && isBright;
};
-
- //Ghost pixel repair function
+ //Ghost pixel repair functions
function rebuildCurrentPixels() {
var currPix = []; //rebuild currentPixels from pixelMap to try to fix bug
for(pmi = 0; pmi < pixelMap.length; pmi++) {
@@ -2083,11 +1996,29 @@ try {
};
};
currentPixels = currPix;
+ }; //Take each item from pixelMap into currentPixels
+ afterEveryTick(function() {
+ if(typeof(rebuildCurrentPixels) !== "undefined") {
+ rebuildCurrentPixels()
+ }
+ }); //nuclear option: rebuild current pixels every tick (this is kind of cursed but desyncs are bad)
+ function removePixelsFromPixelmapThatAreNotInCurrentpixels() {
+ pixelMap = pixelMap.map(col => col.map(function(pixel) {
+ if(pixel == undefined) {
+ return undefined
+ } else if(currentPixels.includes(pixel)) {
+ return pixel
+ } else {
+ return undefined
+ }
+ }))
+ };
+ function removePixelsFromCurrentpixelsThatAreNotInPixelmap() {
+ var flatPixelMap = pixelMap.flat();
+ currentPixels = currentPixels.filter(pixel => flatPixelMap.includes(pixel));
+ flatPixelMap = null
};
-
-
//Sugar functions
-
function newElement(name="element_name",color="#FF00FF",otherProps={}) {
elements[name] = {
color: color,
@@ -2097,9 +2028,7 @@ try {
};
return elements[name];
};
-
//Fixes
-
//fix -1-caused ghost pixels
function deletePixel(x,y) {
if(isEmpty(x,y,true)) { return false };
@@ -2128,9 +2057,7 @@ try {
}
}*/
};
-
//Language
-
function englishFormatList(thingsArrayIn) {
var thingsArray = thingsArrayIn;
var amount = thingsArray.length;
@@ -2144,13 +2071,10 @@ try {
return thingsArray.join(", ")
};
};
-
function capitalizeFirstLetter(string,locale=null) {
return string[0][locale ? "toLocaleUpperCase" : "toUpperCase"](locale) + string.slice(1)
};
-
//COLOR MANIPULATION TOOLS ##
-
var colorToolCounter = 0;
saturationAmount = 1;
saturationOp = "add";
@@ -2159,9 +2083,7 @@ try {
hueAmount = 1;
hueOp = "add";
colorToolElementFilter = "none";
-
var ops = ["add","subtract","multiply","divide","set","min","max","+","-","*","x","×","/","÷","=",">",">=","<","<="];
-
function colorToolFilterPrompt() {
var preElement = prompt("Enter the elements you want to limit it to\nSeparate multiple elements with commas\nType \"none\" for no filter");
if(preElement === null) {
@@ -2175,11 +2097,9 @@ try {
colorToolElementFilter = preElement;
return colorToolElementFilter;
};
-
function saturationPrompt() {
var preSaturation = prompt("Enter the value you want to use");
var preSatOp = prompt(`Enter the operation ("add", "subtract", "multiply", or "divide", or "set")`);
-
//value check
if(isNaN(parseFloat(preSaturation))) {
if(preSaturation === "" || preSaturation === null) {
@@ -2191,27 +2111,23 @@ try {
};
};
preSaturation = parseFloat(preSaturation);
-
//operation check
if(!ops.includes(preSatOp.toLowerCase())) {
if(preSatOp === "" || preSatOp === null) {
alert(`No operation was specified! Defaulting to "add".`);
preSatOp = "add";
} else {
- alert(`Invalid operation! Only "add", "subract", "multiply", "divide", "set", "min", and "max" are accepted (defaulting to "add").`);
+ alert(`Invalid operation! Only "add", "subract", "multiply", "divide", "set", "min", and "max" are accepted (defaulting to "add").`);
preSatOp = "add";
};
};
-
saturationAmount = preSaturation;
saturationOp = preSatOp;
return [preSaturation, preSatOp];
};
-
function luminancePrompt() {
var preLuminance = prompt("Enter the value you want to use");
var preLumOp = prompt(`Enter the operation ("add", "subtract", "multiply", or "divide", or "set")`);
-
//value check
if(isNaN(parseFloat(preLuminance))) {
if(preLuminance === "" || preLuminance === null) {
@@ -2222,28 +2138,24 @@ try {
preLuminance = 1;
};
};
-
//operation check
if(!ops.includes(preLumOp.toLowerCase())) {
if(preLumOp === "" || preLumOp === null) {
alert(`No operation was specified! Defaulting to "add".`);
preLumOp = "add";
} else {
- alert(`Invalid operation! Only "add", "subract", "multiply", "divide", "set", "min", and "max" are accepted (defaulting to "add").`);
+ alert(`Invalid operation! Only "add", "subract", "multiply", "divide", "set", "min", and "max" are accepted (defaulting to "add").`);
preLumOp = "add";
};
};
preLuminance = parseFloat(preLuminance)
-
luminanceAmount = preLuminance;
luminanceOp = preLumOp;
return [preLuminance, preLumOp];
};
-
function huePrompt() {
var preHue = prompt("Enter the value you want to use");
var preHueOp = prompt(`Enter the operation ("add", "subtract", "multiply", or "divide", or "set")`);
-
//value check
if(isNaN(parseFloat(preHue))) {
if(preHue === "" || preHue === null) {
@@ -2254,25 +2166,21 @@ try {
preHue = 1;
};
};
-
preHue = parseFloat(preHue);
-
//operation check
if(!ops.includes(preHueOp.toLowerCase())) {
if(preHueOp === "" || preHueOp === null) {
alert(`No operation was specified! Defaulting to "add".`);
preHueOp = "add";
} else {
- alert(`Invalid operation! Only "add", "subract", "multiply", "divide", "set", "min", and "max" are accepted (defaulting to "add").`);
+ alert(`Invalid operation! Only "add", "subract", "multiply", "divide", "set", "min", and "max" are accepted (defaulting to "add").`);
preHueOp = "add";
};
};
-
hueAmount = preHue;
hueOp = preHueOp;
return [preHue, preHueOp];
};
-
elements.multiply_color = {
color: ["#c27070","#c29c70","#c2c270","#70c270","#70c2c2","#7070c2","#c270c2"],
tool: function(pixel) {
@@ -2287,7 +2195,6 @@ try {
excludeRandom: true, //the toolbar is getting cluttered
desc: "Click here to configure the element filter (applies to all color tools).",
}
-
elements.divide_color = {
color: ["#c27070","#c29c70","#c2c270","#70c270","#70c2c2","#7070c2","#c270c2"],
tool: function(pixel) {
@@ -2302,7 +2209,6 @@ try {
excludeRandom: true,
desc: "Click here to configure the element filter (applies to all color tools).",
}
-
elements.add_color = {
color: ["#c27070","#c29c70","#c2c270","#70c270","#70c2c2","#7070c2","#c270c2"],
tool: function(pixel) {
@@ -2317,7 +2223,6 @@ try {
excludeRandom: true,
desc: "Click here to configure the element filter (applies to all color tools).",
}
-
elements.subtract_color = {
color: ["#c27070","#c29c70","#c2c270","#70c270","#70c2c2","#7070c2","#c270c2"],
tool: function(pixel) {
@@ -2332,7 +2237,6 @@ try {
excludeRandom: true,
desc: "Click here to configure the element filter (applies to all color tools).",
}
-
elements.hue = {
color: ["#ff0000","#ccff00","#00ff66","#0066ff","#cc00ff","#ff0000"],
tool: function(pixel) {
@@ -2346,7 +2250,6 @@ try {
excludeRandom: true,
desc: "Click here to configure the tool. Click here to configure the element filter (applies to all color tools).",
};
-
elements.saturation = {
color: ["#808080","#996666","#b34d4d","#cc3333","#e61919","#ff0000"],
tool: function(pixel) {
@@ -2360,7 +2263,6 @@ try {
excludeRandom: true,
desc: "Click here to configure the tool. Click here to configure the element filter (applies to all color tools)."
}
-
elements.luminance = {
color: ["#000000","#333333","#666666","#999999","#cccccc","#ffffff"],
tool: function(pixel) {
@@ -2374,7 +2276,6 @@ try {
excludeRandom: true,
desc: "Click here to configure the tool. Click here to configure the element filter (applies to all color tools)."
}
-
elements.grayscale = {
color: ["#7f7f7f"],
tool: function(pixel) {
@@ -2391,7 +2292,6 @@ try {
excludeRandom: true,
desc: "Click here to configure the element filter (applies to all color tools).",
}
-
elements.invert = {
color: ["#ff0000", "#00ffff"],
tool: function(pixel) {
@@ -2407,7 +2307,6 @@ try {
excludeRandom: true,
desc: "Click here to configure the element filter (applies to all color tools).",
}
-
elements.reverse_R_G_B = {
color: ["#7f7f7f"],
tool: function(pixel) {
@@ -2423,7 +2322,6 @@ try {
excludeRandom: true,
desc: "Click here to configure the element filter (applies to all color tools).",
}
-
elements.shift_R_G_B = {
color: ["#7f7f7f"],
tool: function(pixel) {
@@ -2439,7 +2337,6 @@ try {
excludeRandom: true,
desc: "Click here to configure the element filter (applies to all color tools).",
}
-
//STRIPED PAINT ##
stripeFixedDefaultProperties = {
color2: "rgb(0,0,0)",
@@ -2447,18 +2344,15 @@ try {
scale: 1,
angle: 0
};
-
stripeSpreadingProperties = {
color1: "It doesn't matter what I put here; I'm just sick of writing for loops.",
color2: "stan loona",
};
-
/*stripeSpreadingProperties2 = {
phase: 0,
scale: 1, :eggTF:
angle: 0
};*/
-
function stripeFunction(pixel) {
if(pixel.color1 == undefined || pixel.color1 == null) {
pixel.color1 = pixel.color;
@@ -2468,7 +2362,6 @@ try {
pixel[prop] = stripeFixedDefaultProperties[prop];
};
};
-
//color1 and color2 self staining
for (var i = 0; i < adjacentCoords.length; i++) {
var x = pixel.x+adjacentCoords[i][0];
@@ -2488,20 +2381,15 @@ try {
}; :eggTF:
};*/
};
-
var radians = pixel.angle * (Math.PI / 180);
-
var colorNumber = (pixel.x*Math.cos(radians))+(pixel.y*Math.sin(radians));
-
var sineWeight = (1+Math.sin(pixel.phase + colorNumber / pixel.scale))/2;
-
var preColor = lerpColors(pixel.color1,pixel.color2,"json",sineWeight);
for(colorlet in preColor) {
preColor[colorlet] = Math.round(preColor[colorlet]);
};
pixel.color = convertColorFormats(preColor,"rgb");
};
-
stripePaintDesc = `Exactly what it says on the button.
Properties:
@@ -2515,11 +2403,8 @@ Properties:
90 = horizontal line
135 = top left to bottom right...
-
color1 and color2 spread through striped paint like dye does with itself. color1 can be set on initial placement through the color picker, but otherwise, properties must be changed through the console or with prop.js's tools.
-
This does not work with HSL color and the game will black screen if one is somehow used. The color conversion functions are a clusterf***.`
-
elements.stripe_paint = {
behavior: behaviors.LIQUID,
state: "liquid",
@@ -2542,9 +2427,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
},
desc: stripePaintDesc
};
-
//CHANGEPIXEL LOG UNDEFINED-ELEMENT FAILURES ##
-
doLog = true;
oldChangePixel = changePixel;
changePixel = function(pixel,element,changetemp=true) {
@@ -2555,14 +2438,12 @@ color1 and color2 spread through striped paint like dye does with itself. col
};
oldChangePixel(pixel,element,changetemp);
};
-
//VARIABLES FOR IN-GAME CONSOLE ##
-
colorInvalidError = "Color must be in the form \"rgb(red,green,blue)\" or \"hsl(hue,saturation%,lightness%)\" (without quotes)!";
stringSynonyms = [ "string", "str", "st", "s" ];
numberSynonyms = [ "number", "num", "nm", "nu", "nb", "integer", "int", "i", "it", "float",
"flt", "ft", "fl", "f", "wholenumber", "decimalnumber", "wn", "dn", "w",
- "d", "deeznuts" ]; /*The purpose of these blatant lies is, through a
+ "d", "deeznuts" ]; /*The purpose of these blatant lies is, through a
reference to the Alice series of software, have an excuse to include deez
nuts. (p.s. this was before i picked that name)*/
objectSynonyms = [ "object", "oj", "obj", "ob", "o", "json" ];
@@ -2574,9 +2455,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
defaultArrayTypeValues = ["attachOffsets"];
synonymsOfTrue = ["true", "t", "1", "yes"];
synonymsOfFalse = ["false", "f", "0", "no"];
-
//ENABLE RUNNING CODE AFTER STATE ELEMENT AUTOGENERATION (runAfterAutogen) ##
-
resizeCanvas = function(newHeight,newWidth,newPixelSize,clear) {
var gameCanvas = document.getElementById("game");
var ctx = gameCanvas.getContext("2d");
@@ -2590,7 +2469,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
mousePos = {x:Math.round(width/2),y:Math.round(height/2)};
if (clear!==false) { clearAll(); }
}
-
autoResizeCanvas = function(clear) {
pixelSize = settings.pixelsize || 6;
if (window.innerWidth < 700) {
@@ -2610,19 +2488,14 @@ color1 and color2 spread through striped paint like dye does with itself. col
if (window.innerWidth > 1000 && newHeight > 500) { newHeight = 500; }
resizeCanvas(newHeight,newWidth,pixelSize,clear);
};
-
function runAfterAutogen(func) {
runAfterAutogenList.push(func);
};
-
function runAfterButtons(func) {
runAfterButtonsList.push(func);
};
-
runAfterAutogenList = [];
-
runAfterButtonsList = [];
-
function behaviorStringsToArrays() {
for (var behavior in behaviors) {
if (typeof behaviors[behavior][0] === "string") {
@@ -2634,7 +2507,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
}
}
-
function tripletsToRgbAndGenerateColorObjects() {
for (var key in elements) {
if (elements.hasOwnProperty(key)) {
@@ -2674,7 +2546,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
}
}
-
// Automatic molten element generation
// Moved above the exposed autoGenAllElements for ReferenceError purposes
function autoGen(newname,element,autoType) {
@@ -2745,7 +2616,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
if (elements[newname][key] == undefined) { elements[newname][key] = newelem[key]; }
}
}
-
/*if (autoType === "molten" && (elements.molten_slag && elements.molten_slag.ignore && elements.molten_slag.ignore.indexOf(element) === -1)) { // Slag reactions
if (newname !== "molten_slag") {
if (!elements[newname].reactions) { elements[newname].reactions = {}; }
@@ -2755,7 +2625,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
};
}*/
}
-
function autoGenAllElements() {
for (element in elements) {
if (elements[element].tempHigh!==undefined && (elements[element].stateHigh===undefined||elements[element].forceAutoGen)) {
@@ -2810,7 +2679,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
}
}
-
function doFinalChecks() {
nextid = 1;
for (key in elements) {
@@ -2872,7 +2740,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
if (behaviorCenter.indexOf("RT") !== -1) {
elements[key].rotatable = true;
}
-
// If the element's behavior stringified includes "BO", loop through the behavior
if (elements[key].behavior.toString().indexOf("BO") !== -1 && !elements[key].rotatable) {
for (var i = 0; i < elements[key].behavior.length; i++) {
@@ -2894,9 +2761,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
}
}
-
}
-
// If the element's state is "gas", isGas = true
if (elements[key].state === "gas") {
elements[key].isGas = true;
@@ -2905,7 +2770,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
else if (elements[key].state !== "solid" && elements[key].state !== "liquid") {
delete elements[key].state;
}
-
// If the element has reactions, loop through each one (it is an object), if the value for elem1 or elem2 is not an element and is not null, remove that key
if (elements[key].reactions) {
for (var reaction in elements[key].reactions) {
@@ -2943,7 +2807,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
}
}
-
// If the element's stateHigh or stateLow is not an element, remove it and tempHigh/Low
if (elements[key].stateHigh) {
// If it's an array, do it for each item, otherwise, just do it once
@@ -3014,7 +2877,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
if (elements[key].breakInto[i]!==null && !elements[elements[key].breakInto]) { delete elements[key].breakInto; }
}
}
-
if (elements[key].colorPattern) {
if (!elements[key].colorKey) {
delete elements[key].colorPattern;
@@ -3045,19 +2907,16 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
}
};
-
function createWorldGenOptions() {
for (var key in worldgentypes) {
document.getElementById("worldgenselect").innerHTML += "";
}
};
-
function validateWorldGenSelection() {
if (settings["worldgen"] && !worldgentypes[settings["worldgen"]]) {
settings["worldgen"] = "off";
}
};
-
function validateRandomEventChoices() {
for (var key in randomEventChoices) {
for (var i = 0; i < randomEventChoices[key].length; i++) {
@@ -3067,7 +2926,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
}
};
-
function setEqualReactions(fromElement,toElement) {
if (elements[fromElement] && elements[toElement]) {
if (elements[fromElement].reactions) {
@@ -3077,7 +2935,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
};
return false;
};
-
function loadSettings() {
var settingSpans = document.getElementsByClassName("setting-span");
for (var i = 0; i < settingSpans.length; i++) {
@@ -3091,7 +2948,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
}
};
-
function setCanvasWidthAndHeight(ctx) {
var newWidth = Math.ceil(window.innerWidth*0.9 / pixelSize) * pixelSize;
var newHeight = Math.ceil(window.innerHeight*0.675 / pixelSize) * pixelSize;
@@ -3104,11 +2960,9 @@ color1 and color2 spread through striped paint like dye does with itself. col
document.getElementById("gameDiv").style.width = newWidth + "px";
document.getElementById("loadingP").style.display = "none";
document.getElementById("canvasDiv").style.display = "block";
-
width = Math.round(newWidth/pixelSize)-1;
height = Math.round(newHeight/pixelSize)-1;
};
-
function definePixelMap() {
if (settings["worldgen"]) {
clearAll();
@@ -3121,13 +2975,11 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
}
};
-
function setRandomChoices() {
randomChoices = Object.keys(elements).filter(function(e) {
return elements[e].excludeRandom != true && elements[e].category != "tools" && !elements[e].tool;
});
};
-
function addCanvasAndWindowListeners(gameCanvas) {
gameCanvas.addEventListener("mousedown", mouseClick);
gameCanvas.addEventListener("touchstart", mouseClick, { passive: false });
@@ -3168,7 +3020,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
// e.target.result is a dataURL for the image
aImg.src = e.target.result;
- };
+ };
})(img);
reader.readAsDataURL(file);
}
@@ -3216,7 +3068,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
};
};
-
function generateModManagerList() {
if (enabledMods.length > 0) {
modManagerList = document.getElementById("modManagerList");
@@ -3232,8 +3083,114 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
};
+ currentShape = "square";
+ shapeOrder = ["square","circle","triangle","inverted triangle","rhombus","squircle","twinkle","slash","backslash"];
+ shapeExclusionConditions = {
+ /*"square": function(x,y,size,mouseX,mouseY,topLeft,bottomRight) {
+ return false
+ },*/
+ "triangle": function(x,y,size,mouseX,mouseY,topLeft,bottomRight) {
+ var xOffset = (x - topLeft[0]);
+ var yOffset = (y - topLeft[1]);
+ var distanceFromCenterLine;
+ if(size % 2 == 0) {
+ distanceFromCenterLine = Math.abs((size / 2) - (xOffset + 0.5))
+ } else {
+ distanceFromCenterLine = Math.abs(mouseX - x);
+ };
+ var distanceProportion = distanceFromCenterLine / size;
+ var hpovp = ((yOffset + (size % 2 == 0)) / size) / 2; //halvedPossiblyOffsetVerticalProportion
+ return distanceProportion > (hpovp + 0.01);
+ },
+ "inverted triangle": function(x,y,size,mouseX,mouseY,topLeft,bottomRight) {
+ var xOffset = (x - topLeft[0]);
+ var yOffset = (y - topLeft[1]);
+ var distanceFromCenterLine;
+ if(size % 2 == 0) {
+ distanceFromCenterLine = Math.abs((size / 2) - (xOffset + 0.5))
+ } else {
+ distanceFromCenterLine = Math.abs(mouseX - x);
+ };
+ var distanceProportion = distanceFromCenterLine / size;
+ var hpovpc = (1 - ((yOffset + (size % 2 !== 0)) / size)) / 2; //halvedPossiblyOffsetVerticalProportionComplement
+ return distanceProportion > (hpovpc + 0.01);
+ },
+ "rhombus": function(x,y,size,mouseX,mouseY,topLeft,bottomRight) {
+ var xOffset = (x - topLeft[0]);
+ var yOffset = (y - topLeft[1]);
+ var xDistanceFromCenterLine;
+ if(size % 2 == 0) { xDistanceFromCenterLine = Math.abs((size / 2) - (xOffset + 0.5)) } else { xDistanceFromCenterLine = Math.abs(mouseX - x) };
+ var yDistanceFromCenterLine;
+ if(size % 2 == 0) { yDistanceFromCenterLine = Math.abs((size / 2) - (yOffset + 0.5)) } else { yDistanceFromCenterLine = Math.abs(mouseY - y) };
+ return (xDistanceFromCenterLine + yDistanceFromCenterLine) > (size / 2) //i was just messing around, i didn't expect this to actually be the right condition :sob:
+ },
+ "squircle": function(x,y,size,mouseX,mouseY,topLeft,bottomRight) {
+ var xOffset = (x - topLeft[0]);
+ var yOffset = (y - topLeft[1]);
+ var xDistanceFromCenterLine;
+ if(size % 2 == 0) { xDistanceFromCenterLine = Math.abs((size / 2) - (xOffset + 0.5)) } else { xDistanceFromCenterLine = Math.abs(mouseX - x) };
+ var yDistanceFromCenterLine;
+ if(size % 2 == 0) { yDistanceFromCenterLine = Math.abs((size / 2) - (yOffset + 0.5)) } else { yDistanceFromCenterLine = Math.abs(mouseY - y) };
+ return ( (((xDistanceFromCenterLine ** 3) + (yDistanceFromCenterLine ** 3)) ** (1/3)) > (size / 2)) || ((size > 2) && (size <= 6) && ((xDistanceFromCenterLine + yDistanceFromCenterLine) == (size - 1)));
+ },
+ "twinkle": function(x,y,size,mouseX,mouseY,topLeft,bottomRight) {
+ var xOffset = (x - topLeft[0]);
+ var yOffset = (y - topLeft[1]);
+ var xDistanceFromCenterLine;
+ if(size % 2 == 0) { xDistanceFromCenterLine = Math.abs((size / 2) - (xOffset + 0.5)) } else { xDistanceFromCenterLine = Math.abs(mouseX - x) };
+ var yDistanceFromCenterLine;
+ if(size % 2 == 0) { yDistanceFromCenterLine = Math.abs((size / 2) - (yOffset + 0.5)) } else { yDistanceFromCenterLine = Math.abs(mouseY - y) };
+ return ((((xDistanceFromCenterLine ** (1/2)) + (yDistanceFromCenterLine ** (1/2))) ** (2)) > ((size / (size % 2 ? 2 : 1.7)))) && (xDistanceFromCenterLine > 0.5) && (yDistanceFromCenterLine > 0.5)
+ },
+ "circle": function(x,y,size,mouseX,mouseY,topLeft,bottomRight) {
+ var xOffset = (x - topLeft[0]);
+ var yOffset = (y - topLeft[1]);
+ var xDistanceFromCenterLine;
+ if(size % 2 == 0) { xDistanceFromCenterLine = Math.abs((size / 2) - (xOffset + 0.5)) } else { xDistanceFromCenterLine = Math.abs(mouseX - x) };
+ var yDistanceFromCenterLine;
+ if(size % 2 == 0) { yDistanceFromCenterLine = Math.abs((size / 2) - (yOffset + 0.5)) } else { yDistanceFromCenterLine = Math.abs(mouseY - y) };
+ if( (((xDistanceFromCenterLine ** 2) + (yDistanceFromCenterLine ** 2)) ** (1/2)) > (size / 2)) { return true }; //structured this way for legibility
+ if( ((xDistanceFromCenterLine + yDistanceFromCenterLine) == 2) && (size == 3)) { return true };
+ if( ((xDistanceFromCenterLine + yDistanceFromCenterLine) >= 3.5) && (size == 6)) { return true };
+ if( ((xDistanceFromCenterLine + yDistanceFromCenterLine) >= 4.5) && (size == 8) && !(Math.abs(xDistanceFromCenterLine) === Math.abs(yDistanceFromCenterLine))) { return true };
+ if( //i can't explain how these rules work, but they just do
+ (size % 2 == 1) &&
+ (size > 5) &&
+ ((xDistanceFromCenterLine + yDistanceFromCenterLine) >= (size - 3)) &&
+ !(Math.abs(xDistanceFromCenterLine) === Math.abs(yDistanceFromCenterLine))
+ ) { return true };
+ return false
+ },
+ "slash": function(x,y,size,mouseX,mouseY,topLeft,bottomRight) {
+ var xOffset = (x - topLeft[0]);
+ var yOffset = (y - topLeft[1]);
+ var yOffsetComplement = (size - 1) - yOffset;
+ if(xOffset == yOffsetComplement) { return false };
+ if(xOffset == yOffsetComplement + 1) { return false };
+ return true
+ },
+ "backslash": function(x,y,size,mouseX,mouseY,topLeft,bottomRight) {
+ var xOffset = (x - topLeft[0]);
+ var yOffset = (y - topLeft[1]);
+ if(xOffset == yOffset) { return false };
+ if(xOffset == yOffset + 1) { return false };
+ return true
+ },
+ /*"corners": function(x,y,size,mouseX,mouseY,topLeft,bottomRight) {
+ var tl = (x == topLeft[0] && y == topLeft[1]);
+ var tr = (x == bottomRight[0] && y == topLeft[1]);
+ var bl = (x == topLeft[0] && y == bottomRight[1]);
+ var br = (x == bottomRight[0] && y == bottomRight[1]);
+ return !(tl || tr || bl || br)
+ }*/
+ }
+
+
+ //supplementary functions for below
+
//redefine mouseRange to support even sizes
- function mouseRange(mouseX,mouseY,size) {
+ function mouseRange(mouseX,mouseY,size,shapeOverride=null) {
+ var shape = shapeOverride ?? currentShape ?? "square";
var coords = [];
size = size || mouseSize;
if (elements[currentElement].maxSize < mouseSize) {
@@ -3242,20 +3199,29 @@ color1 and color2 spread through striped paint like dye does with itself. col
else {
var mouseOffset = Math.trunc(size/2);
}
- var topLeft = [mouseX-mouseOffset,mouseY-mouseOffset];
- var bottomRight = [mouseX+mouseOffset,mouseY+mouseOffset];
+ var topLeft = [mouseX-mouseOffset,mouseY-mouseOffset];
+ var bottomRight = [mouseX+mouseOffset,mouseY+mouseOffset];
if(size % 2 == 0) {
bottomRight[0]--;
bottomRight[1]--;
};
- // Starting at the top left, go through each pixel
- for (var x = topLeft[0]; x <= bottomRight[0]; x++) {
- for (var y = topLeft[1]; y <= bottomRight[1]; y++) {
- // If the pixel is empty, add it to coords
- coords.push([x,y]);
- }
- }
- return coords;
+ var exclusionFunction = shapeExclusionConditions[shape] ?? null;
+ if((shape !== "square") && (exclusionFunction == null)) {
+ logMessage(`Shape ${shape} not recognized!`)
+ return []
+ };
+
+ // Starting at the top left, go through each pixel
+ for (var x = topLeft[0]; x <= bottomRight[0]; x++) {
+ for (var y = topLeft[1]; y <= bottomRight[1]; y++) {
+ // If the pixel is empty, add it to coords
+ if((shape !== "square") && exclusionFunction?.(x,y,size,mouseX,mouseY,topLeft,bottomRight)) {
+ continue
+ };
+ coords.push([x,y]);
+ }
+ };
+ return coords
};
//this part defines basically all of the keybinds
@@ -3305,7 +3271,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
//If a shift key is pressed, set to 1
if (shiftDown && shiftDown % 2 == 1) {mouseSize = 1}
//If an alt key is pressed, decrease by 1
- else if (shiftDown && shiftDown % 2 == 0) {
+ else if (shiftDown && shiftDown % 2 == 0) {
mouseSize--;
if (mouseSize < 1) { mouseSize = 1 }
}
@@ -3316,8 +3282,8 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
// If the user presses ] or =, increase the mouse size by 2
if (e.keyCode == 221 || e.keyCode == 187) {
- //If a shift key is pressed, increase by 15
- if (shiftDown && shiftDown % 2 == 1) {mouseSize = (mouseSize+15)-((mouseSize+15) % 15)}
+ //If a shift key is pressed, increase by 16
+ if (shiftDown && shiftDown % 2 == 1) {mouseSize = (mouseSize+15)-((mouseSize+15) % 15); if(mouseSize % 2 == 0) { mouseSize++ }}
//If an alt key is pressed, increase by 1
else if (shiftDown && shiftDown % 2 == 0) {mouseSize++}
else {mouseSize += 2;}
@@ -3429,17 +3395,31 @@ color1 and color2 spread through striped paint like dye does with itself. col
link.click();
document.body.removeChild(link);
}
-
-
+ //mod: shift+8 to change cursor shape, alt+8 to cycle backwards
+ if (e.keyCode == 56 && [1,2].includes(shiftDown)) {
+ var currentShapeIndex = shapeOrder.indexOf(currentShape);
+ var newIndex;
+ switch(shiftDown) {
+ default:
+ case 1:
+ newIndex = (currentShapeIndex + 1) % shapeOrder.length;
+ break
+ case 2:
+ newIndex = (currentShapeIndex - 1) % shapeOrder.length;
+ if(newIndex < 0) { newIndex = shapeOrder.length - 1 };
+ break
+ };
+ currentShape = shapeOrder[newIndex];
+ logMessage(`Current shape: ${currentShape}`)
+ }
+
// x = explodeAt()
/*else if (e.keyCode == 88) {
e.preventDefault();
explodeAt(mousePos.x, mousePos.y, Math.round(mouseSize/2));
}*/
-
});
};
-
function addUnshiftListeners() {
document.addEventListener("keyup", function(e) {
if (e.keyCode == 16 || e.keyCode == 18) {
@@ -3451,7 +3431,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
});
};
-
function createButtonsAndCountElements() {
elementCount = 0;
hiddenCount = 0;
@@ -3489,24 +3468,19 @@ color1 and color2 spread through striped paint like dye does with itself. col
selectElement(currentElement);
focusGame();
};
-
window.onload = function() {
// If the browser is Firefox, set #categoryControls padding-bottom:11px;
if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
document.getElementById("categoryControls").style.paddingBottom = "11px";
}
-
// Loop through runAfterLoadList and run each function
for (var i = 0; i < runAfterLoadList.length; i++) {
runAfterLoadList[i]();
}
-
// Loop through behaviors and each behavior, if it is a string, split the items and replace the value with the array
behaviorStringsToArrays();
-
// convert every color in the elements object to rgb
tripletsToRgbAndGenerateColorObjects()
-
autoElements = {
"molten": { // Solid -> Liquid
rgb: [ [2,1.25,0.5], [2,1,0.5], [2,0.75,0] ],
@@ -3539,48 +3513,35 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "gas",
}
}
-
// Loop through each element. If it has a tempHigh, but not a stateHigh, create a new molten element
autoGenAllElements();
-
// Loop through runAfterAutogenList and run each function
for (var i = 0; i < runAfterAutogenList.length; i++) {
runAfterAutogenList[i]();
};
-
// Loop through each element, final checks
doFinalChecks();
-
// Generate worldgen options
// Loop through the worldgentypes object, add the key to the #worldgenselect select as an option with the value of the key and the name of the key capitalized and underscores replaced with spaces
createWorldGenOptions();
validateWorldGenSelection();
-
// Loop through randomEventChoices, and loop through the array of each. If the element doesn't exist, remove it from the array.
validateRandomEventChoices();
-
// Poison == poison gas reactions
setEqualReactions("poison","poison_gas");
-
// Load settings
// Loop through all the elements with setting-span class.
// If the span's setting attribute is in settings, set the first select or input to the value of the setting.
loadSettings();
-
//scared to touch this because ctx is pretty important
var gameCanvas = document.getElementById("game");
// Get context
var ctx = gameCanvas.getContext("2d");
-
setCanvasWidthAndHeight(ctx);
-
mousePos = {x:width/2,y:height/2};
-
definePixelMap();
-
// randomChoices = the keys of "elements" with any element with the category "tools" or the property excludeRandom set to true removed
setRandomChoices();
-
addCanvasAndWindowListeners(gameCanvas);
gameCanvas.ontouchstart = function(e) {
if (e.touches) e = e.touches[0];
@@ -3591,26 +3552,20 @@ color1 and color2 spread through striped paint like dye does with itself. col
return 'Are you sure you want to leave?';
}
};
-
// If enabledMods has items, add an li to modManagerList for each item with the href to the item, target blank, and the item's name, with "X" after the link
generateModManagerList();
-
document.getElementById("game").oncontextmenu = function(e) { e.preventDefault(); return false; }
// If the user presses [ or -, decrease the mouse size by 2
addKeyboardListeners();
-
// If the user releases either shift
addUnshiftListeners();
-
// Create buttons for elements
// For each element type in elements, create a button in controls that sets the current element to that type
// Alphabetically sort and loop through dictionary named "elements"
createButtonsAndCountElements();
-
for (var i = 0; i < runAfterButtonsList.length; i++) {
runAfterButtonsList[i]();
};
-
selectElement(currentElement);
focusGame();
// For every button element, onkeyup="event.preventDefault()"
@@ -3620,7 +3575,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
e.preventDefault();
}
}
-
if (window.self !== window.top && !location.ancestorOrigins[0].includes("itch.io")) {
// Open a message that tells the user they aren't on the real website
var menuParent = document.createElement("div");
@@ -3643,26 +3597,19 @@ color1 and color2 spread through striped paint like dye does with itself. col
document.body.appendChild(menuParent);
showingMenu = "alert";
}
-
//get the first .elementButton in the first .category, and selectElement(button.element)
var firstDiv = document.getElementsByClassName("category")[0];
var firstElementButton = firstDiv.getElementsByClassName("elementButton")[0];
selectElement(firstElementButton.getAttribute("element"));
-
gameLoaded = true
};
-
-
//MORE CONFIGURABLE EXPLOSIONS (explodeAtPlus) ##
-
velocityBlacklist = [];
-
function explodeAtPlus(x,y,radius,firee="fire",smokee="smoke",beforeFunction=null,afterFunction=null,changeTemp=true) {
var message = "Explosion ";
var pixel = pixelMap[x]?.[y];
if(pixel) { message += `of ${pixel.element} ` };
message += `with radius ${radius} at (${x},${y})`;
-
// if fire contains , split it into an array
if(firee !== null) {
if (firee.indexOf(",") !== -1) {
@@ -3784,7 +3731,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
};
};
};
-
oldExplodeAt = explodeAt;
/*explodeAt = function(x,y,radius,fire="fire") {
var message = "Explosion ";
@@ -3792,20 +3738,17 @@ color1 and color2 spread through striped paint like dye does with itself. col
if(pixel) { message += `of ${pixel.element} ` };
message += `with radius ${radius} with "${fire}" at (${x},${y})`;
console.log(message);
-
oldExplodeAt(x,y,radius,fire="fire")
};*/
explodeAt = explodeAtPlus;
-
//MORE CONFIGURABLE REACTION TEMPERATURE CHANGES ##
-
function reactPixels(pixel1,pixel2) {
+ if((!(pixel1)) || (!(pixel2))) { return false };
var r = elements[pixel1?.element]?.reactions?.[pixel2?.element];
if(!r) { return false };
if (r.setting && !(settings[r.setting])) {
return false;
}
- var changeTemp = r.changeTemp ?? true
// r has the attribute "y" which is a range between two y values
// r.y example: [10,30]
// return false if y is defined and pixel1's y is not in the range
@@ -3815,7 +3758,13 @@ color1 and color2 spread through striped paint like dye does with itself. col
if (r.tempMax !== undefined && pixel1.temp > r.tempMax) {
return false;
}
- if (r.charged && !pixel.charge) {
+ if (r.burning1 !== undefined && Boolean(pixel1.burning) !== r.burning1) {
+ return false;
+ }
+ if (r.burning2 !== undefined && Boolean(pixel2.burning) !== r.burning2) {
+ return false;
+ }
+ if (r.charged && !pixel1.charge) {
return false;
}
if (r.chance !== undefined && Math.random() > r.chance) {
@@ -3825,57 +3774,69 @@ color1 and color2 spread through striped paint like dye does with itself. col
return false;
}
if (r.elem1 !== undefined) {
+ var elem1 = r.elem1;
// if r.elem1 is an array, set elem1 to a random element from the array, otherwise set it to r.elem1
- if (Array.isArray(r.elem1)) {
- var elem1 = r.elem1[Math.floor(Math.random() * r.elem1.length)];
- } else { var elem1 = r.elem1; }
-
+ while (Array.isArray(elem1)) {
+ elem1 = randomChoice(elem1)
+ }
if (elem1 == null) {
deletePixel(pixel1.x,pixel1.y);
}
else {
- changePixel(pixel1,elem1,changeTemp);
+ changePixel(pixel1,elem1,r.changeTemp1 ?? r.changeTemp ?? true);
}
}
- if (r.charge1) { pixel1.charge = r.charge1; }
- if (r.temp1) { pixel1.temp += r.temp1; pixelTempCheck(pixel1); }
- if (r.color1) { // if it's a list, use a random color from the list, else use the color1 attribute
- pixel1.color = pixelColorPick(pixel1, Array.isArray(r.color1) ? r.color1[Math.floor(Math.random() * r.color1.length)] : r.color1);
- }
- if (r.attr1) { // add each attribute to pixel1
- for (var key in r.attr1) {
- pixel1[key] = r.attr1[key];
+ if(pixel1) {
+ if (r.charge1) { pixel1.charge = r.charge1; }
+ if (r.temp1) { pixel1.temp += r.temp1; pixelTempCheck(pixel1); }
+ if (r.color1) { // if it's a list, use a random color from the list, else use the color1 attribute
+ var color1 = r.color1;
+ while(Array.isArray(color1)) {
+ color1 = randomChoice(color1)
+ };
+ pixel1.color = pixelColorPick(pixel1, color1);
+ }
+ if (r.attr1) { // add each attribute to pixel1
+ for (var key in r.attr1) {
+ pixel1[key] = r.attr1[key];
+ }
}
}
if (r.elem2 !== undefined) {
- // if r.elem2 is an array, set elem2 to a random element from the array, otherwise set it to r.elem2
- if (Array.isArray(r.elem2)) {
- var elem2 = r.elem2[Math.floor(Math.random() * r.elem2.length)];
- } else { var elem2 = r.elem2; }
-
+ var elem2 = r.elem2;
+ // if r.elem2 is an array, set elem2 to a random element from the array, otherwise set it to r.elem1
+ while (Array.isArray(elem2)) {
+ elem2 = randomChoice(elem2)
+ }
if (elem2 == null) {
deletePixel(pixel2.x,pixel2.y);
}
else {
- changePixel(pixel2,elem2,changeTemp);
+ changePixel(pixel2,elem2,r.changeTemp2 ?? r.changeTemp ?? true);
}
}
- if (r.charge2) { pixel2.charge = r.charge2; }
- if (r.temp2) { pixel2.temp += r.temp2; pixelTempCheck(pixel2); }
- if (r.color2) { // if it's a list, use a random color from the list, else use the color2 attribute
- pixel2.color = pixelColorPick(pixel2, Array.isArray(r.color2) ? r.color2[Math.floor(Math.random() * r.color2.length)] : r.color2);
- }
- if (r.attr2) { // add each attribute to pixel2
- for (var key in r.attr2) {
- pixel2[key] = r.attr2[key];
+ if(pixel2) {
+ if (r.charge2) { pixel2.charge = r.charge2; }
+ if (r.temp2) { pixel2.temp += r.temp2; pixelTempCheck(pixel2); }
+ if (r.color2) { // if it's a list, use a random color from the list, else use the color2 attribute
+ var color2 = r.color2;
+ while(Array.isArray(color2)) {
+ color2 = randomChoice(color2)
+ };
+ pixel2.color = pixelColorPick(pixel2, color2);
+ }
+ if (r.attr2) { // add each attribute to pixel2
+ for (var key in r.attr2) {
+ pixel2[key] = r.attr2[key];
+ }
}
}
- if (r.func) { r.func(pixel1,pixel2); }
+ if(pixel1 && pixel2) {
+ if (r.func) { r.func(pixel1,pixel2); }
+ }
return r.elem1!==undefined || r.elem2!==undefined;
}
-
//CHANGES TO ELECTRICITY CODE (doElectricity changes) ##
-
function doElectricity(pixel) {
if(isNaN(pixel.charge)) {
pixel.charge = 0;
@@ -3928,12 +3889,9 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
}
}
-
//MORE CONFIGURABLE FIRE (fireMod changes) ##
-
//Variable
fireSpawnBlacklist = ["fire","cold_fire","rad_fire"];
-
//doBurning
function doBurning(pixel) {
if (pixel.burning) { // Burning
@@ -3950,10 +3908,8 @@ color1 and color2 spread through striped paint like dye does with itself. col
var fireChance = info.fireSpawnChance ?? 10;
var fireIsCold = (fire === "cold_fire");
//var fireInfo = fire === null ? null : elements[fire];
-
pixel.temp += burnTempChange;
pixelTempCheck(pixel);
-
for (var i = 0; i < adjacentCoords.length; i++) { // Burn adjacent pixels
var x = pixel.x+adjacentCoords[i][0];
var y = pixel.y+adjacentCoords[i][1];
@@ -3977,7 +3933,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
}
}
-
if ((pixelTicks - pixel.burnStart > (info.burnTime || 200)) && Math.floor(Math.random()*100)<(info.burn || 10)) {
var burnInto = info.burnInto ?? "fire";
while(burnInto instanceof Array) {
@@ -4017,7 +3972,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
}
}
-
//No changeTemp for fire=>smoke
elements.fire.tick = function(pixel){
if (pixel.start === pixelTicks) {return}
@@ -4056,7 +4010,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
if (!pixel.del) { doDefaults(pixel); }
if (!pixel.del && settings.burn===0 && (pixelTicks-pixel.start > 70) && Math.random() < 0.1 ) { changePixel(pixel,"smoke",false) };
};
-
//New elements
elements.cold_fire.burning = true;
elements.cold_fire.burnTempChange = -1;
@@ -4068,7 +4021,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
"M2|XX|M2",
"XX|M2|XX"
],
-
elements.cold_smoke = {
color: "#282848",
behavior: behaviors.DGAS,
@@ -4092,7 +4044,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
density: 1280,
stain: 0.075,
};
-
elements.rad_fire = { //this is BBB
color: ["#daff21","#a6ff00","#ffff00"],
behavior: [
@@ -4104,18 +4055,14 @@ color1 and color2 spread through striped paint like dye does with itself. col
if(Math.random() < 0.4) {
pixel.temp++;
};
-
if(Math.random() < 0.05) { //5%/t to radify
if(typeof(transformAdjacent) === "function" && typeof(radioactiveObject) === "object") {
transformAdjacent(pixel,radioactiveObject);
};
};
-
var move1Spots = [[-1,-1],[0,-1],[1,-1]];
var move2Spots = [[-1,0],[0,1],[1,0]];
-
var randomMove1 = move1Spots[Math.floor(Math.random() * move1Spots.length)];
-
if(!tryMove(pixel, pixel.x+randomMove1[0], pixel.y+randomMove1[1])) {
//console.log((pixel.x+randomMove1[0]) + " " + (pixel.y+randomMove1[1]))
var newPixel = null;
@@ -4158,7 +4105,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
density: 0.1,
ignoreAir: true,
};
-
elements.rad_smoke = {
color: "#415c25",
behavior: behaviors.DGAS,
@@ -4172,20 +4118,16 @@ color1 and color2 spread through striped paint like dye does with itself. col
deletePixel(pixel.x,pixel.y);
return;
};
-
if(Math.random() < 0.2) {
pixel.temp++;
};
-
if(Math.random() < 0.04) { //4%/t to radify
if(typeof(transformAdjacent) === "function" && typeof(radioactiveObject) === "object") {
transformAdjacent(pixel,radioactiveObject);
};
};
-
var move1Spots = [[0,-1],[1,0],[0,1],[-1,0]];
var move2Spots = [[-1,-1],[1,-1],[1,1],[-1,1]];
-
var randomMove1 = move1Spots[Math.floor(Math.random() * move1Spots.length)];
if(!tryMove(pixel, pixel.x+randomMove1[0], pixel.y+randomMove1[1])) {
//console.log((pixel.x+randomMove1[0]) + " " + (pixel.y+randomMove1[1]))
@@ -4229,34 +4171,27 @@ color1 and color2 spread through striped paint like dye does with itself. col
density: 1340,
stain: 0.075,
};
-
elements.holy_fire = {
color: ["#FFFF96","#FFBF49","#CE743B"], //placeholder
tick: function(pixel) {
-
var moveResult = tryMoveAndReturnBlockingPixel(pixel,pixel.x + randomSign(),pixel.y - 1);
var blockingPixels = [];
var secondMoveResult = null;
-
if(typeof(moveResult) == "object" && !(elements[pixel.element].ignore.concat(pixel.element).includes(moveResult.element))) {
blockingPixels.push(moveResult)
};
-
//if move1Result = true then nothing else happens
-
if(moveResult !== true) {
var coords = randomChoice([[-1,0],[0,1],[1,0]]).map(offsetPair => addArraysInPairs(offsetPair,[pixel.x,pixel.y]));
secondMoveResult = tryMoveAndReturnBlockingPixel(pixel,...coords);
-
if(typeof(secondMoveResult) == "object" && !(elements[pixel.element].ignore.concat(pixel.element).includes(secondMoveResult.element))) {
blockingPixels.push(secondMoveResult)
};
};
-
if(blockingPixels.length > 0) {
blockingPixels.forEach(function(pixel) {
var blessRxn = elements.bless.reactions[pixel.element];
- if(typeof(blessRxn) == "object") {
+ if(typeof(blessRxn) == "object") {
var elem2 = blessRxn.elem2;
if(elem2 !== null) {
while(Array.isArray(elem2)) { elem2 = randomChoice(elem2) };
@@ -4297,7 +4232,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
density: 0.08,
ignoreAir: true
};
-
elements.holy_bomb = {
color: ["#dbb260", "#94591e"],
tick: function(pixel) {
@@ -4330,10 +4264,8 @@ color1 and color2 spread through striped paint like dye does with itself. col
excludeRandom: true,
desc: "A bomb that burns the world to pure ash. To enable automatic bomb generation, set the generateBombs query parameter.",
};
-
elements.bless.ignore ??= [];
elements.bless.ignore.push("holy_fire");
-
elements.plasma_explosion = {
color: ["#c78fff","#ea8fff","#be8fff"],
tick: function(pixel) {
@@ -4347,30 +4279,23 @@ color1 and color2 spread through striped paint like dye does with itself. col
excludeRandom: true,
noMix: true
};
-
elements.god_slayer_fire = {
color: ["#FFBACE","#FC6DCA","#9954B0"],
tick: function(pixel) {
-
var moveResult = tryMoveAndReturnBlockingPixel(pixel,pixel.x + randomSign(),pixel.y - 1);
var blockingPixels = [];
var secondMoveResult = null;
-
if(typeof(moveResult) == "object" && !(elements[pixel.element].ignore.concat(pixel.element).includes(moveResult.element))) {
blockingPixels.push(moveResult)
};
-
//if move1Result = true then nothing else happens
-
if(moveResult !== true) {
var coords = randomChoice([[-1,0],[0,1],[1,0]]).map(offsetPair => addArraysInPairs(offsetPair,[pixel.x,pixel.y]));
secondMoveResult = tryMoveAndReturnBlockingPixel(pixel,...coords);
-
if(typeof(secondMoveResult) == "object" && !(elements[pixel.element].ignore.concat(pixel.element).includes(secondMoveResult.element))) {
blockingPixels.push(secondMoveResult)
};
};
-
if(blockingPixels.length > 0) {
blockingPixels.forEach(function(pixel) {
var value = Math.random();
@@ -4406,7 +4331,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
return
})
};
-
doDefaults(pixel);
},
temp:10000,
@@ -4423,34 +4347,27 @@ color1 and color2 spread through striped paint like dye does with itself. col
density: 0.07,
ignoreAir: true
};
-
elements.liquid_holy_fire = {
color: ["#FFFF96","#FFBF49","#CE743B"], //placeholder
tick: function(pixel) {
-
var moveResult = tryMoveAndReturnBlockingPixel(pixel,pixel.x + randomIntegerBetweenTwoValues(-1,1),pixel.y + 1);
var blockingPixels = [];
var secondMoveResult = null;
-
if(typeof(moveResult) == "object" && !(elements[pixel.element].ignore.concat(pixel.element).includes(moveResult.element))) {
blockingPixels.push(moveResult)
};
-
//if move1Result = true then nothing else happens
-
if(moveResult !== true) {
var coords = [randomSign(),0].map(offsetPair => addArraysInPairs(offsetPair,[pixel.x,pixel.y]));
secondMoveResult = tryMoveAndReturnBlockingPixel(pixel,...coords);
-
if(typeof(secondMoveResult) == "object" && !(elements[pixel.element].ignore.concat(pixel.element).includes(secondMoveResult.element))) {
blockingPixels.push(secondMoveResult)
};
};
-
if(blockingPixels.length > 0) {
blockingPixels.forEach(function(pixel) {
var blessRxn = elements.bless.reactions[pixel.element];
- if(typeof(blessRxn) == "object") {
+ if(typeof(blessRxn) == "object") {
var elem2 = blessRxn.elem2;
if(elem2 !== null) {
while(Array.isArray(elem2)) { elem2 = randomChoice(elem2) };
@@ -4491,30 +4408,23 @@ color1 and color2 spread through striped paint like dye does with itself. col
density: 270,
ignoreAir: true
};
-
elements.liquid_god_slayer_fire = {
color: ["#FFBACE","#FC6DCA","#9954B0"],
tick: function(pixel) {
-
var moveResult = tryMoveAndReturnBlockingPixel(pixel,pixel.x + randomIntegerBetweenTwoValues(-1,1),pixel.y + 1);
var blockingPixels = [];
var secondMoveResult = null;
-
if(typeof(moveResult) == "object" && !(elements[pixel.element].ignore.concat(pixel.element).includes(moveResult.element))) {
blockingPixels.push(moveResult)
};
-
//if move1Result = true then nothing else happens
-
if(moveResult !== true) {
var coords = [randomSign(),0].map(offsetPair => addArraysInPairs(offsetPair,[pixel.x,pixel.y]));
secondMoveResult = tryMoveAndReturnBlockingPixel(pixel,...coords);
-
if(typeof(secondMoveResult) == "object" && !(elements[pixel.element].ignore.concat(pixel.element).includes(secondMoveResult.element))) {
blockingPixels.push(secondMoveResult)
};
};
-
if(blockingPixels.length > 0) {
blockingPixels.forEach(function(pixel) {
var value = Math.random();
@@ -4550,7 +4460,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
return
})
};
-
doDefaults(pixel);
},
temp:15000,
@@ -4567,7 +4476,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
density: 380,
ignoreAir: true
};
-
elements.god_slayer_bomb = {
color: ["#a43dcc", "#49b6d1"],
tick: function(pixel) {
@@ -4600,10 +4508,8 @@ color1 and color2 spread through striped paint like dye does with itself. col
excludeRandom: true,
desc: "A bomb that makes gods tremble. To enable automatic bomb generation, set the generateBombs query parameter.",
};
-
elements.cloner.burnTime = Infinity;
elements.cloner.burnInto = "cloner";
-
elements.cold_torch = {
"color": "#4394d6",
"behavior": [
@@ -4632,9 +4538,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
"tempHigh": 600,
"stateHigh": "wood",
};
-
var GTDR = { "elem1": "torch", chance: 0.01 }; //grand torch degradation reaction
-
elements.grand_torch = {
"color": "#FFBF2F",
"tick": function(pixel) {
@@ -4678,51 +4582,22 @@ color1 and color2 spread through striped paint like dye does with itself. col
"tempLow": 1000,
"stateLow": "torch",
};
-
elements.torch.reactions ??= {};
elements.torch.reactions.magic = { elem1: ["torch","torch","grand_torch"], elem2: null, changeTemp: true };
elements.torch.tempHigh = 1500;
elements.torch.stateHigh = "grand_torch";
-
var PTDR = { "elem1": "wood", chance: 0.003 };
-
elements.plasma_torch = {
"color": "#86579c",
"tick": function(pixel) {
- var offset;
- switch((pixel.r ?? 0) % 4) {
- case 0.5:
- offset = [-1,-1];
- break;
- case 1:
- offset = [-1,0];
- break;
- case 1.5:
- offset = [-1,1];
- break;
- case 2:
- offset = [0,1];
- break;
- case 2.5:
- offset = [1,1];
- break;
- case 3:
- offset = [1,0];
- break;
- case 3.5:
- offset = [1,-1];
- break;
- case 4:
- case 0:
- default:
- offset = [0,-1];
- break;
- };
+ var rotation = -(((pixel.r ?? 0) % 4) + 1); //preserving the original behavior of 0 = up, 1 = left
+ var rotationInRadians = scale(rotation,0,4,0,Math.PI * 2);
+ var vector = [Math.cos(rotationInRadians), Math.sin(rotationInRadians)];
//base strength (distance) 2, plus 1 for each 500*C above 7K*C; when charged, increase by 10% for each full or partial unit of charge (0.25 yields 10%, 1 yields 10%, 1.55 yields 20%, 2 yields 20%...)
var strength = Math.max(2,Math.min(300, ((2 + Math.floor((pixel.temp - 7000) / 500)) * (1 + (Math.ceil(pixel.charge ?? 0) * 0.1))))); //bound to 2-300, in part for performance reasons
//console.log(strength);
for(var i = 1; i <= strength; i++) {
- var newOffsets = offset.map(x => x * i);
+ var newOffsets = vector.map(coord => Math.round(coord * i));
var finalPos = {x: pixel.x + newOffsets[0], y: pixel.y + newOffsets[1]};
//console.log({x:pixel.x,y:pixel.y},finalPos);
if(!(isEmpty(finalPos.x,finalPos.y))) {
@@ -4761,9 +4636,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
"tempLow": 4999,
"stateLow": "grand_torch",
};
-
var GrPTDR = { "elem1": "plasma_torch", chance: 0.001 }; //grand plasma torch degradation reaction
-
elements.grand_plasma_torch = {
"color": "#b92eff",
"tick": function(pixel) {
@@ -4804,7 +4677,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
"tempLow": 6000,
"stateLow": "plasma_torch",
};
-
elements.rad_torch = {
"color": "#85d643",
"behavior": [
@@ -4833,7 +4705,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
"tempLow": -273,
"stateHigh": "wood",
};
-
elements.mystic_torch = {
"color": ["#8e27ba", "#b3297e"],
"behavior": [
@@ -4862,7 +4733,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
"hardness": 0.999
};
elements.mystic_fire.state = "gas";
-
elements.napalm = {
color: "#e0873e",
behavior: [
@@ -4879,7 +4749,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
burnTime: 500,
temp: airTemp,
};
-
elements.hypernapalm = {
name: "h y p e r n a p a l m", //HYPERNAPALM
color: "#bd34eb",
@@ -4899,7 +4768,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
burn: 300,
burnTime: 500,
};
-
elements.cold_napalm = {
color: "#3e87e0",
behavior: [
@@ -4917,7 +4785,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
burnTempChange: -1,
burnInto: "cold_fire",
};
-
elements.rad_napalm = {
color: "#cdf760",
behavior: [
@@ -4936,13 +4803,11 @@ color1 and color2 spread through striped paint like dye does with itself. col
temp: airTemp,
burnInto: "rad_fire",
};
-
runAfterLoad(function() {
if(eLists.spout) {
eLists.spout.push("cold_torch");
eLists.spout.push("rad_torch");
};
-
elements.liquid_fire = {
color: ["#ff6b21","#ffa600","#ff4000"],
behavior: [
@@ -4966,7 +4831,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "liquid",
density: 200,
};
-
elements.liquid_cold_fire = {
color: ["#21cbff","#006aff","#00ffff"],
behavior: [
@@ -4990,7 +4854,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "liquid",
density: 420,
};
-
elements.liquid_rad_fire = {
color: ["#daff21","#a6ff00","#ffff00"],
behavior: [
@@ -5002,16 +4865,13 @@ color1 and color2 spread through striped paint like dye does with itself. col
if(Math.random() < 0.4) {
pixel.temp++;
};
-
if(Math.random() < 0.06) { //6%/t to radify
if(typeof(transformAdjacent) === "function" && typeof(radioactiveObject) === "object") {
transformAdjacent(pixel,radioactiveObject);
};
};
-
var move1Spots = [[-1,1],[0,1],[1,1]];
var move2Spots = [[-1,0],[0,-1],[1,0]];
-
var randomMove1 = move1Spots[Math.floor(Math.random() * move1Spots.length)];
if(!tryMove(pixel, pixel.x+randomMove1[0], pixel.y+randomMove1[1])) {
//console.log((pixel.x+randomMove1[0]) + " " + (pixel.y+randomMove1[1]))
@@ -5057,21 +4917,17 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "liquid",
density: 210,
};
-
elements.radiation.reactions.liquid_fire = { "elem2":"liquid_rad_fire", "chance":0.4 };
elements.radiation.reactions.fire = { "elem2":"rad_fire", "chance":0.4 };
elements.radiation.reactions.smoke = { "elem2":"rad_smoke", "chance":0.4 };
-
runAfterLoad(function() {
for(key in elements.radiation.reactions) {
var value = elements.radiation.reactions[key];
-
if(typeof(elements.rad_fire.reactions[key]) === "undefined") {
elements.rad_fire.reactions[key] = value;
};
};
});
-
elements.unrealistically_flammable_gas.burnTempChange = 10;
elements.unrealistically_flammable_gas.fireElement = "plasma";
elements.unrealistically_flammable_powder.burnTempChange = 20;
@@ -5081,16 +4937,12 @@ color1 and color2 spread through striped paint like dye does with itself. col
elements.burning_unrealistically_flammable_powder.burnTempChange = 30;
elements.burning_unrealistically_flammable_powder.fireElement = "plasma";
});
-
//CONFIGURABLE MAXIMUM COLOR OFFSET (maxColorOffset) ##
-
defaultColorOffset = 15;
-
pixelColorPick = function(pixel,customColor=null,maxOffset=null) {
var element = pixel.element;
var elementInfo = elements[element];
//if (elementInfo.behavior instanceof Array) {
-
if (pixel.charge && elementInfo.colorOn) {
customColor = elementInfo.colorOn;
}
@@ -5111,13 +4963,12 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
// Randomly darken or lighten the RGB color
//try maxOffset parameter, then info maxColorOffset, then default 15
- var offsetAmount;
+ var offsetAmount;
if(maxOffset !== null) {
offsetAmount = maxOffset;
} else {
offsetAmount = elementInfo?.maxColorOffset ?? defaultColorOffset;
};
-
var maxColorOffset = Math.floor(Math.random() * (Math.random() > 0.5 ? -1 : 1) * Math.random() * offsetAmount);
var r = rgb.r + maxColorOffset;
var g = rgb.g + maxColorOffset;
@@ -5127,7 +4978,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
g = Math.max(0, Math.min(255, g));
b = Math.max(0, Math.min(255, b));
var color = "rgb("+r+","+g+","+b+")";
-
/*}
else {
var color = elementInfo.color;
@@ -5137,7 +4987,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
}*/
return color;
}
-
//FIND MODE, PIXEL PROPERTIES LINKED TO SPECIAL CODE, CONFIGURABLE VISUAL DISTORTION AND VISUAL PIXEL SHAPE SETTINGS (acid_and_shapes.js) ##
//two separate things i.e. not "pixel properties linked to special code, configurable visual distortion, and visual pixel shape settings" though there's basically no semantic difference
var style = document.createElement('style');
@@ -5145,28 +4994,23 @@ color1 and color2 spread through striped paint like dye does with itself. col
style.id = 'findStatusStylesheet';
style.innerHTML = '.findStatus { color: #E11; text-decoration: none; }';
document.getElementsByTagName('head')[0].appendChild(style);
-
find = false;
findElement = "sand";
findColorPulseTimer = 0;
findColorPulseTimerSubTimer = 0;
-
function marasi(number) {
return Math.min(255,Math.round(Math.abs(Math.sin(number) * 255)));
};
-
function updateFindDescription() {
var elems = findElement;
if(elems instanceof Array) {
elems = elems.join(", ");
};
elements.find_toggle.desc = `I'm running out of keybinds
-
If this text is green or underlined, find mode is on. Currently finding: ${elems} (this display does not update automatically).
Click here to toggle find mode. This highlights the currently selected element. Click here to configure the find filter.`;
};
-
function toggleFind() {
if(find != true) {
find = true;
@@ -5177,7 +5021,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
};
updateFindDescription();
};
-
elements.find_toggle = {
color: ["#000000", "#000000", "#000000", "#000000", "#ff0000", "#ff0000", "#ff0000", "#ff0000"],
name: "find toggle (look at info)",
@@ -5186,13 +5029,10 @@ color1 and color2 spread through striped paint like dye does with itself. col
excludeRandom: true,
desc: `
I'm running out of keybinds
-
-
If this text is green or underlined, find mode is on. Currently finding: sand (this display does not update automatically).
Click here to toggle find mode. This highlights the currently selected element. Click here to configure the find filter.`,
};
-
function findFilterPrompt() {
var preElement = prompt("Enter the elements you want to highlight\nSeparate multiple elements with commas");
if(preElement === null || preElement === "") {
@@ -5209,43 +5049,34 @@ color1 and color2 spread through striped paint like dye does with itself. col
return findElement;
};
var incrementt = 0;
-
var interval = setInterval( increment, 500/30);
-
function increment(){
incrementt = incrementt % (Math.PI*8.8) + (Math.PI/30);
}
-
shapeModes = ["normal","circles","triangles"];
settings.shapeMode ??= 0;
settings.doacid ??= false;
settings.acidFunction ??= "none";
-
- function getShapeMode() {
+ function getShapeMode() {
return shapeModes[settings.shapeMode] ?? "normal";
};
-
specialProperties = {
/*red: {
specialFunction: function(pixel) { pixel.color = "rgb(255,0,0)" }
},*/
};
-
acidFunctions = {
sin: Math.sin,
tan: Math.tan,
none: function(number) { return number }
};
-
var tickBehaviorStringCache = {
POWDER: behaviors.POWDER.toString(),
LIQUID: behaviors.LIQUID.toString(),
UL_UR_OPTIMIZED: behaviors.UL_UR_OPTIMIZED.toString()
};
-
settings ??= {};
settings.shockoverlay ??= true;
-
//I hate overwriting drawPixels
runAfterAutogen(function() {
//rAA because velocity.js already puts its redef in a rAL and rAA comes after that
@@ -5312,29 +5143,29 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
var pixelDrawList = pixelsFirst.concat(pixelsLast);
for (var i = 0; i < pixelDrawList.length; i++) {
- pixel = pixelDrawList[i];
+ var pixel = pixelDrawList[i];
if (pixelMap[pixel.x][pixel.y] == undefined) {continue}
if (pixel.con) { pixel = pixel.con }
if (view===null || view===3) {
var colorOut = pixel.color;
- for(var imsorryaboutthelagthiswillcause in specialProperties) {
- if(pixel[imsorryaboutthelagthiswillcause] !== undefined && specialProperties[imsorryaboutthelagthiswillcause].specialColorFunction) {
- colorOut = specialProperties[imsorryaboutthelagthiswillcause].specialColorFunction(pixel,oldColor=colorOut)
+ for(var sry4thelag in specialProperties) {
+ if(pixel[sry4thelag] !== undefined && specialProperties[sry4thelag].specialColorFunction) {
+ colorOut = specialProperties[sry4thelag].specialColorFunction(pixel,oldColor=colorOut)
}
}
ctx.fillStyle = colorOut;
}
else if (view === 2) { // thermal view
- // set the color to pixel.temp, from hottest at -66 (294.1875) hue to coldest 225 hue, with the minimum being -273, max being 7755
+ // set the color to pixel.temp, from hottest at -66 (294.1875) hue to coldest 265 hue, with the minimum being -273, max being 7755
var temp = pixel.temp;
- temp = Math.min(Math.max(temp,(settings.abszero ?? -273.15)),55530);
+ temp = Math.min(Math.max(temp + 900,(settings.abszero ?? -273.15)),55530);
var hue,sat,lig;
sat = 100;
lig = 50;
if(temp <= 7755) {
- hue = 225 - (Math.min(7755,temp)/6000)*225;
+ hue = 265 - (Math.min(7755,temp)/6000)*265;
if (hue < 0) {hue += (360 * Math.ceil(hue / -360))}
- if (temp < 0 && hue > 280) {hue = 280}
+ if (temp < 0 && hue > 285) {hue = 285}
} else if(temp <= 9255) {
hue = 294.1875;
lig = 50 + (Math.max(0,temp - 7755) * (50/1500));
@@ -5343,10 +5174,10 @@ color1 and color2 spread through striped paint like dye does with itself. col
sat = 0;
lig = 100 - (Math.max(0,temp - 9255) * (100 / 2000));
} else if(temp <= 11755) {
- hue = 225;
+ hue = 265;
lig = (Math.max(0,temp - 11255) * (25 / 500));
} else if(temp <= 19510) {
- hue = 225 - (Math.min(19510,Math.max(0,temp - 11755))/6000)*225;
+ hue = 265 - (Math.min(19510,Math.max(0,temp - 11755))/6000)*265;
if (hue < 0) {hue += (360 * Math.ceil(hue / -360))}
lig = 25;
} else if(temp <= 20510) {
@@ -5360,11 +5191,11 @@ color1 and color2 spread through striped paint like dye does with itself. col
sat = 50;
lig = 75;
} else if(temp <= 29265) {
- hue = 225;
+ hue = 265;
sat = scale(temp,28265,29265,50,40);
lig = scale(temp,28265,29265,75,87.5);
} else if(temp <= 37020) {
- hue = scale(temp,29265,37020,225,654.1875) % 360;
+ hue = scale(temp,29265,37020,265,654.1875) % 360;
sat = 40;
lig = 87.5;
} else if(temp <= 39020) {
@@ -5376,11 +5207,11 @@ color1 and color2 spread through striped paint like dye does with itself. col
sat = 40;
lig = 50;
} else if(temp <= 47775) {
- hue = 225;
+ hue = 265;
sat = scale(temp,46775,47775,40,20);
lig = 50;
} else { //55530
- hue = scale(temp,47775,55530,225,654.1875) % 360;
+ hue = scale(temp,47775,55530,265,654.1875) % 360;
sat = 20;
lig = 50;
};
@@ -5408,14 +5239,12 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
else if (view === 5) { // velocity view
var data = elements[pixel.element];
-
var vx = pixel.vx ?? 0;
var vy = pixel.vy ?? 0;
/*
var pseudoVelocity = 0;
var coordsToCheck;
var behaviorCoordsToCheck;
-
if(Array.isArray(data.behavior)) {
switch((pixel.r ?? 0) % 4) {
default:
@@ -5434,7 +5263,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
case 3:
coordsToCheck = [1,0];
behaviorCoordsToCheckOffset = [1,2];
- break;
+ break;
};
if(data.behavior[behaviorCoordsToCheckOffset[0]][behaviorCoordsToCheckOffset[1]] == "M1") {
if(isEmpty(pixel.x+coordsToCheck[0],pixel.y+coordsToCheck[1])) {
@@ -5478,29 +5307,23 @@ color1 and color2 spread through striped paint like dye does with itself. col
vy += pseudoVelocity;
};
*/
-
if(vx === 0 && vy === 0) {
ctx.fillStyle = "rgb(15,15,15)"
} else {
var magnitude = Math.sqrt ((vx ** 2) + (vy ** 2));
-
var direction = Math.atan2(pixel.vy ?? 0,pixel.vx ?? 0)*180/Math.PI;
if(direction < 0) { direction = scale(direction,-180,0,360,180) };
-
hue = direction;
sat = 100;
lig = bound(scale(magnitude,0,100,10,100),0,100);
-
ctx.fillStyle = "hsl("+hue+","+sat+"%,"+lig+"%)";
}
}
-
if(find) { //if find and matching, override fill style with the find coloration
if(findElement instanceof Array ? findElement.includes(pixel.element) : pixel.element === findElement) {
ctx.fillStyle = "rgb(255," + marasi(findColorPulseTimer / 10) + ",0)";
}
};
-
var mode = getShapeMode();
settings.acidFunction ??= "none";
var acidFunction;
@@ -5614,11 +5437,9 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
}
};
-
if (ctx.globalAlpha < 1) {
ctx.globalAlpha = 1;
};
-
if (elements[currentElement].maxSize < mouseSize) {
var mouseOffset = Math.trunc(elements[currentElement].maxSize/2);
}
@@ -5640,7 +5461,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
ctx.fillRect(mousePos.x*pixelSize,mousePos.y*pixelSize,pixelSize,pixelSize);
}
if ((!paused) || forceTick) {pixelTicks++};
-
findColorPulseTimerSubTimer++;
if(findColorPulseTimerSubTimer >= 2) {
findColorPulseTimer++;
@@ -5649,14 +5469,12 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
});
//I hate overwriting drawPixels
-
viewKey = {
2: "thermal",
3: "basic",
4: "smooth",
5: "velocity"
};
-
function setView(n) {
if (viewKey[n]) { // range of number keys with valid views
view = n;
@@ -5665,18 +5483,15 @@ color1 and color2 spread through striped paint like dye does with itself. col
view = null;
}
};
-
runAfterLoad(function() {
//Setting
var settingsMenu = document.getElementById("settingsMenu").getElementsByClassName("menuText")[0];
-
var settingNodes = [...settingsMenu.childNodes].filter(function(node) { return node.nodeType == 1 });
var lastSetting = settingNodes[settingNodes.length - 1];
//console.log(lastSetting);
//console.log(lastSetting.getAttribute("style"));
lastSetting.removeAttribute("style"); //restore padding for worldgen setting;
//console.log(lastSetting.getAttribute("style"));
-
//Shape setting
var shapeSettingSpan = document.createElement("span");
shapeSettingSpan.setAttribute("setting","shapeMode");
@@ -5692,7 +5507,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
for(value in options) {
var newOption = document.createElement("option");
if(value == "0") {
- newOption.setAttribute("selected","");
+ newOption.setAttribute("selected","");
};
newOption.setAttribute("value",value);
newOption.innerText = options[value];
@@ -5700,7 +5515,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
};
shapeSettingSpan.appendChild(settingDropdown);
settingsMenu.appendChild(shapeSettingSpan);
-
//Acid function setting
var acidFuncSpan = document.createElement("span");
acidFuncSpan.setAttribute("setting","acidFunction");
@@ -5725,13 +5539,11 @@ color1 and color2 spread through striped paint like dye does with itself. col
};
acidFuncSpan.appendChild(settingDropdown);
settingsMenu.appendChild(acidFuncSpan);
-
//Handle the styling of the last setting
settingNodes = [...settingsMenu.childNodes].filter(function(node) { return node.nodeType == 1 });
lastSetting = settingNodes[settingNodes.length - 1];
//console.log(lastSetting);
lastSetting.setAttribute("style","padding-bottom:0"); //remove padding from last setting;
-
settings ??= {};
settings.burnoverlay ??= false;
var redBurnSettingSpan = document.createElement("span");
@@ -5756,7 +5568,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
redBurnSettingSpan.appendChild(newHelpMark);
var cheerfulSetting = document.querySelector('span[setting="cheerful"]');
cheerfulSetting.after(redBurnSettingSpan);
-
settings.shockoverlay ??= true;
var yellowShockSettingSpan = document.createElement("span");
yellowShockSettingSpan.setAttribute("setting","shockoverlay");
@@ -5779,7 +5590,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
yellowShockSettingSpan.appendChild(settingInput);
yellowShockSettingSpan.appendChild(newHelpMark);
redBurnSettingSpan.after(yellowShockSettingSpan);
-
settings.doacid ??= false;
var acidSettingSpan = document.createElement("span");
acidSettingSpan.setAttribute("setting","doacid");
@@ -5802,7 +5612,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
acidSettingSpan.appendChild(settingInput);
acidSettingSpan.appendChild(newHelpMark);
yellowShockSettingSpan.after(acidSettingSpan);
-
var sizeSetting = document.querySelector('span[setting="pixelsize"]');
var sizeDropdown = sizeSetting.querySelector("select");
sizeDropdown.setAttribute("onchange","var size = (this.value === 'null' ? null : parseFloat(this.value)); console.log(size); if((size >= 0.05) && (size <= 194.73749999999999) && (size !== null) && (size !== false) && !(isNaN(size))) { console.log(size); setSetting('pixelsize',size);this.nextElementSibling.innerText='Reset Scene' }");
@@ -5819,7 +5628,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
otherOption.innerText = "Other";
sizeDropdown.insertAdjacentElement("beforeend",otherOption);
pixelSizeSettingDropdownOtherOptionIndex = (sizeDropdown.children.length) - 1;
-
//Append code to showSettings to set every setting toggle button's state according to its setting's value on page load (so if you turned the setting on, the button is already green when you load the page)
function showSettingsButtonAutoUpdateAppendFunction() {
var toggleButtonSettings = document.querySelectorAll('span.setting-span.multisetting[setting]:has(input[type="button"])');
@@ -5840,8 +5648,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
oldShowSettings();
showSettingsButtonAutoUpdateAppendFunction()
};
-
- console.log(everyTick(function() {
+ everyTick(function() {
if(paused) { return };
for(var propName in specialProperties) {
//thanks, I hate not being able to pass arguments to filter functions
@@ -5856,17 +5663,15 @@ color1 and color2 spread through striped paint like dye does with itself. col
specialProperties[propName]?.specialFunction?.(propPixel);
};
}
- }),"Property handler tick callback set")
+ })
});
-
//FUNCTION EXECUTION WHEN A PIXEL TRIES TO MOVE INTO ANOTHER (onTryMoveInto) ##
-
elements.on_try_move_into_test = {
color: "#ffffff",
properties: {
ticks: 0,
attemptedMovesIntoPixel: 0
- },
+ },
behavior: behaviors.POWDER,
reactions: {
"dirt": { elem1: "diamond" }
@@ -5892,7 +5697,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
desc: "Try burying this pixel and see what happens. (Use Debug)\n\nonTryMoveInto is run as part of tryMove, before reactions, while tick functions are run as part of pixelDraw.\nIn some circumstances, such as a pixel being buried under a pile of anything that isn't a sturdy powder, this function may run multiple times per tick. For example, bury this pixel in ash and look in the console.\n\nTo use this function, include in your element definition the \"onTryMoveInto\" key with a function value, similarly to tick functions. This function takes two arguments; \"otherPixel\" is the pixel that is trying to move and \"pixel\" is the pixel whose position otherPixel is trying to move into.",
related: ["debug", "ash"],
}
-
function tryMove(pixel,nx,ny,leaveBehind,force) {
if(!pixel) { return false };
if (pixel.drag && !force) { return true; }
@@ -5949,9 +5753,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
return false;
}
-
//PIXEL MOVER TOOLS ##
-
elements.move_up = {
color: "#1C0000",
tool: function(pixel) {
@@ -5960,7 +5762,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "movement tools",
excludeRandom: true,
},
-
elements.move_down = {
color: "#000038",
tool: function(pixel) {
@@ -5969,7 +5770,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "movement tools",
excludeRandom: true,
},
-
elements.move_left = {
color: "#007000",
tool: function(pixel) {
@@ -5978,7 +5778,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "movement tools",
excludeRandom: true,
},
-
elements.move_right = {
color: "#000E00",
tool: function(pixel) {
@@ -5987,7 +5786,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "movement tools",
excludeRandom: true,
},
-
elements.move_up_left = {
color: "#E00000",
tool: function(pixel) {
@@ -5996,7 +5794,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "movement tools",
excludeRandom: true,
},
-
elements.move_down_left = {
color: "#0001C0",
tool: function(pixel) {
@@ -6005,7 +5802,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "movement tools",
excludeRandom: true,
},
-
elements.move_up_right = {
color: "#038000",
tool: function(pixel) {
@@ -6014,7 +5810,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "movement tools",
excludeRandom: true,
},
-
elements.move_down_right = {
color: "#000007",
tool: function(pixel) {
@@ -6023,9 +5818,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "movement tools",
excludeRandom: true,
}
-
//TOOL THAT DELETES EVERY ELEMENT OF THE CLICKED TYPE(S) ##
-
elements.delete_all_of_element = {
name: "delete all of element",
color: ["#a7a7a7", "#a7a7a7", "#a7a7a7", "#a7a7a7", "#000000", "#000000", "#000000", "#000000"],
@@ -6043,9 +5836,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "tools",
excludeRandom: true,
};
-
//TEMPERATURE TOOLS ##
-
//base syntax by sightnado
/*elements.warm = {
color: "#7fff7f",
@@ -6090,7 +5881,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
},
category: "cursed tools",
};
-
elements.inf_temp = {
color: ["#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff", "#ff0000", "#ffffff"],
tool: function(pixel) {
@@ -6099,9 +5889,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
},
category: "cursed tools",
};
-
//OTHER TOOLS ##
-
elements.burn = {
color: ["#FF6B21", "#FFA600", "#FF4000"],
tool: function(pixel) {
@@ -6111,7 +5899,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "tools",
excludeRandom: true,
};
-
elements.cursed_shock = {
color: ["#ffff00", "#00ff00", "#ffff00", "#00ff00", "#ffff00", "#00ff00", "#ffff00", "#00ff00"],
tool: function(pixel) {
@@ -6128,9 +5915,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "cursed tools",
excludeRandom: true,
};
-
//TROLL PIXELS ##
-
elements.troll_1 = {
color: "#eeeeee",
tick: function(pixel) {
@@ -6145,7 +5930,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
excludeRandom: true,
desc: "Deletes random pixels"
},
-
elements.troll_2 = {
color: "#eeeeee",
tick: function(pixel) {
@@ -6158,7 +5942,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
excludeRandom: true,
desc: "Paints random pixels black"
},
-
elements.troll_3 = {
color: "#eeeeee",
tick: function(pixel) {
@@ -6173,7 +5956,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
excludeRandom: true,
desc: "Swaps with random pixels"
},
-
elements.troll_4 = {
color: "#eeeeee",
tick: function(pixel) {
@@ -6193,7 +5975,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
excludeRandom: true,
desc: "Causes random explosions"
},
-
elements.offset_fourth_y = {
color: ["#000000", "#ff00ff", "#000000", "#ff00ff", "#000000", "#ff00ff", "#000000", "#ff00ff"],
tool: function(pixel) {
@@ -6202,7 +5983,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
},
category: "cursed tools",
},
-
elements.offset_half_y = {
color: ["#000000", "#ff00ff", "#000000", "#ff00ff", "#000000", "#ff00ff", "#000000", "#ff00ff"],
tool: function(pixel) {
@@ -6211,7 +5991,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
},
category: "cursed tools",
},
-
elements.offset_three_fourth_y = {
color: ["#000000", "#ff00ff", "#000000", "#ff00ff", "#000000", "#ff00ff", "#000000", "#ff00ff"],
tool: function(pixel) {
@@ -6220,10 +5999,9 @@ color1 and color2 spread through striped paint like dye does with itself. col
},
category: "cursed tools",
},
-
elements.troll_5 = {
color: "#eeeeee",
- tick: function() {
+ tick: function(pixel) {
var target = randomChoice(currentPixels);
if(target && !(isEmpty(target.x,target.y))) {
target.r ??= 0;
@@ -6236,10 +6014,9 @@ color1 and color2 spread through striped paint like dye does with itself. col
excludeRandom: true,
desc: "Randomly rotates pixels"
}
-
elements.troll_6 = {
color: "#eeeeee",
- tick: function() {
+ tick: function(pixel) {
if(pixel.temp < -273) {
pixel.temp = -273;
};
@@ -6264,7 +6041,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
temp: -1,
desc: "Advances the simulation timer (not time travel) by its temperature"
},
-
elements.troll_7 = {
color: "#eeeeee",
tick: function(pixel) {
@@ -6279,11 +6055,8 @@ color1 and color2 spread through striped paint like dye does with itself. col
excludeRandom: true,
desc: "Randomly heats and cools random pixels"
}
-
//TRIGGERABLE RANDOM-TOOL POWDERS ##
-
if(typeof(randomChoices) == "undefined") {randomChoices = []}; //this is generated after mod load, but JS will probably die if I don't have it defined in the code
-
elements.heat_random = {
name: "heat-randomized powder",
color: ["#4e5f8a","#b334ec","#fa96f9","#b6ecf6","#80ebc8","#e9286b","#8eed91","#b18b30"], //"random"'s colors plus 0x100000
@@ -6299,7 +6072,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
temp: 20,
desc: "Turns to a random element when heated to 50°C",
};
-
elements.cold_random = {
name: "cold-randomized powder",
color: ["#3e5f9a","#a334fc","#e490ff","#9de3ff","#70ebd8","#d9287b","#7eeda1","#a18b40"], //"random"'s colors plus 0x000010 except where the last byte was above 0xef, where substraction was done to the first two bytes to compensate
@@ -6315,7 +6087,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "special",
desc: "Turns to a random element when cooled to -50°C",
};
-
elements.shock_random = {
name: "shock-randomized powder",
color: ["#4e6f8a","#b344ec","#faa6f9","#b6fcf6","#80fbc8","#e9386b","#8efd91","#b19b30"], //"random"'s colors plus 0x101000
@@ -6334,11 +6105,8 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "special",
desc: "Turns to a random element when shocked",
};
-
//ALKAHEST ##
-
alkahestBlacklist = ["alkahest","alkahest_fairy","wall","alkahest_spout"]
-
elements.alkahest = {
color: "#33eeee",
behavior: behaviors.LIQUID_OLD,
@@ -6364,15 +6132,14 @@ color1 and color2 spread through striped paint like dye does with itself. col
};
pixel[newElement]++;
deletePixel(checkPosX,checkPosY);
+ continue
};
};
};
};
},
};
-
//LIQUID ENERGY ELEMENTS ##
-
elements.liquid_plasma = {
color: ["#8800ff","#b184d9","#8800ff"],
behavior: [
@@ -6394,7 +6161,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
charge: 0.5,
conduct: 1,
},
-
elements.liquid_fire = {
color: ["#ff6b21","#ffa600","#ff4000"],
behavior: [
@@ -6417,7 +6183,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "liquid",
density: 21,
},
-
elements.liquid_smoke = {
color: "#383838",
behavior: [
@@ -6441,7 +6206,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "liquid",
density: 2180,
},
-
elements.liquid_cold_fire = {
color: ["#21cbff","#006aff","#00ffff"],
behavior: [
@@ -6460,7 +6224,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "liquid",
density: 42,
},
-
elements.le_liquid_light = {
color: "#ffffa8",
behavior: [
@@ -6471,7 +6234,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
temp: 40,
category: "energy liquids",
},
-
elements.liquid_laser = {
color: "#ff0000",
behavior: [
@@ -6482,7 +6244,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
temp: 40,
category: "energy liquids",
},
-
elements.liquid_electric = {
color: "#dddd00",
behavior: [
@@ -6495,7 +6256,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
density: 44.1,
},
-
elements.liquid_radiation = {
color: ["#00ff00","#6fff00"],
behavior: [
@@ -6567,13 +6327,11 @@ color1 and color2 spread through striped paint like dye does with itself. col
"antibody": { "elem2":"cancer", "chance":0.8 },
"infection": { "elem2":"cancer", "chance":0.8 },
"cancer": { "elem2":null, "chance":0.2 },
-
},
state: "liquid",
density: 4.2,
category: "energy liquids",
},
-
elements.liquid_explosion = {
color: ["#ffb48f","#ffd991","#ffad91"],
behavior: [
@@ -6587,7 +6345,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
density: 2000,
excludeRandom: true,
}
-
elements.everfire_liquid = {
"name": "everfire liquid",
"color": "#06142b",
@@ -6600,7 +6357,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
"category": "energy liquids",
"fireColor": ["#0041a8","#8ab7ff"],
},
-
elements.extinguished_everfire_liquid = {
"name": "extinguished everfire liquid",
"color": "#242d3b",
@@ -6611,7 +6367,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
"category": "energy liquids",
"hidden": true,
},
-
elements.liquid_magic = {
"name": "liquid magic",
"color": ["#a270ff","#f2d9ff"],
@@ -6625,7 +6380,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
"category": "energy liquids",
"reactions": elements.magic.reactions,
},
-
elements.liquid_mystic_fire = {
"name": "liquid mystic fire",
"color": ["#5454ff","#2020d4","#5800c4"],
@@ -6641,9 +6395,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
"category": "energy liquids",
"burning": true,
},
-
//concoction and essence are already liquid
-
elements.liquid_frostbomb = {
color: "#72dfed",
behavior: [
@@ -6657,9 +6409,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
density: 2000,
excludeRandom: true,
}
-
//LIQUID VOID ##
-
elements.liquid_void = {
color: "#262626",
behavior: [
@@ -6669,7 +6419,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
],
ignore: ["liquid_void", "void", "wall", "cloner", "ecloner", "slow_cloner", "clone_powder", "floating_cloner", "clone_liquid", "liquid_cloner", "fire_cloner", "antigravity_powder_cloner", "floating_cloner_spout", "clone_liquid_spout", "liquid_cloner_spout", "fire_cloner_spout", "converter", "liquid_void_spout"],
/*The hardcoded array of cloners is used because I don't know how to detect them.
- Generation code:
+ Generation code:
elementArray = Object.keys(elements);
for (let i = 0; i < elementArray.length; i++) {
var elementName = elementArray[i];
@@ -6683,15 +6433,11 @@ color1 and color2 spread through striped paint like dye does with itself. col
density: 6969,
excludeRandom: true,
}
-
if(!elements.void.ignore) {
elements.void.ignore = [];
};
-
elements.void.ignore.push("liquid_void");
-
//LIQUID CLONER ##
-
elements.clone_liquid = {
color: "#f0f000",
behavior: [
@@ -6706,13 +6452,9 @@ color1 and color2 spread through striped paint like dye does with itself. col
density:2710,
hardness: 1,
},
-
elements.floating_cloner.state = "gas";
-
elements.floating_cloner.ignore.push("floating_cloner_spout");
-
//ASSORTED RANDOM THINGS ##
-
//TPT reference
elements.warp = {
name: "warp",
@@ -6725,7 +6467,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "special",
state: "gases",
},
-
elements.unrealistically_flammable_gas = {
color: "#ddee11",
behavior: [
@@ -6747,8 +6488,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempHigh: 95,
stateHigh: "burning_unrealistically_flammable_gas",
conduct: 0.2
- },
-
+ },
elements.burning_unrealistically_flammable_gas = {
color: "#eedd11",
behavior: [
@@ -6771,8 +6511,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
stateHigh: "plasma",
hidden: true,
excludeRandom: true,
- },
-
+ },
elements.unrealistically_flammable_powder = {
color: "#cddd22",
behavior: [
@@ -6794,8 +6533,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempHigh: 95,
stateHigh: "burning_unrealistically_flammable_gas",
conduct: 0.4,
- },
-
+ },
elements.burning_unrealistically_flammable_powder = {
color: "#ddcd22",
behavior: [
@@ -6820,7 +6558,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
hidden: true,
excludeRandom: true,
},
-
elements.black_decay = { //random mystcraft mod reference
name: "black decay",
color: "#222222",
@@ -6832,9 +6569,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "special",
excludeRandom: true,
},
-
elements.steel.behavior = behaviors.FAIRYKILL;
-
elements.tungstensteel = {
color: "#555589",
behavior: behaviors.FAIRYKILL,
@@ -6843,8 +6578,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
density: 19000,
conduct: 0.48,
},
-
- elements.stainless_steel = {
+ elements.stainless_steel = {
color: "#7d8181",
behavior: behaviors.WALL,
reactions: {
@@ -6859,16 +6593,13 @@ color1 and color2 spread through striped paint like dye does with itself. col
conduct: 0.42,
hardness: 0.85
};
-
elements.steel.reactions.acid = { elem1:"rust" };
-
elements.molten_tungsten = {
density: 17600,
temp: 3500,
tempHigh: 5555,
stateHigh: "tungsten_gas",
},
-
elements.pop_rock_pop = {
color: ["#ffb49f","#ffd9a1","#ffada1"],
behavior: [
@@ -6882,7 +6613,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
excludeRandom: true,
hidden: true,
},
-
elements.pop_rocks = {
color: ["#d4d4d4","#74d4d4","#d474d4","#7474d4","#d4d474","#74d474","#d47474","#747474","#2f2f2f","#8f2f2f","#2f8f2f","#8f8f2f","#2f2f8f","#8f2f8f","#2f8f8f","#8f8f8f","#606060","#c06060","#60c060","#c0c060","#6060c0","#c060c0","#60c0c0","#c0c0c0"],
behavior: behaviors.POWDER,
@@ -6897,7 +6627,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
hardness: 0.2,
breakInto: ["sugar","pop_rock_pop"],
},
-
elements.tungsten_gas = {
color: "#FFEEE2",
behavior: [
@@ -6912,12 +6641,10 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "gases",
hidden: true,
},
-
elements.molten_steel ??= {};
elements.molten_steel.reactions ??= {};
elements.molten_steel.reactions.molten_tungsten = { "elem1":"molten_tungstensteel", "elem2":"molten_tungstensteel" };
elements.molten_steel.reactions.molten_chromium = { "elem1":"molten_stainless_steel", "elem2":["molten_chromium","molten_chromium","molten_chromium","molten_chromium","molten_chromium","molten_chromium","molten_chromium","molten_chromium","molten_stainless_steel"] };
-
elements.unrealistically_flammable_substance_bomb = {
name: "unrealistically flammable bomb",
color: "#cdad52",
@@ -6931,7 +6658,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
density: 1300,
excludeRandom: true,
},
-
elements.warp_bomb = {
name: "warp bomb",
color: "#422e4a",
@@ -6945,7 +6671,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
density: 1300,
excludeRandom: true,
},
-
elements.turbine = {
color: "#75726a",
tempHigh: elements.copper.tempHigh,
@@ -6974,11 +6699,92 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "machines",
density: averageNumericArray([elements.steel.density, elements.copper.density, airDensity])
};
-
+ elements.test_fader = { //basically an aray clone
+ color: "#FFFFFF",
+ properties: {
+ "life": 100,
+ "fadeRate": 1
+ },
+ hardness: 0.8,
+ density: 0,
+ state: "solid",
+ tick: function(pixel) {
+ pixel.life ??= 100;
+ var alpha = isNaN(pixel.life) ? Math.floor(Math.random() * 256) : (pixel.life * 2.55); //CL REFERENCE??!?!?!?!?!?!?!?!??!?
+ //console.log("tick");
+ var splitColor = convertColorFormats(pixel.color,"json");
+ //console.log(pixel.color,splitColor);
+ splitColor.a = alpha;
+ pixel.color = convertColorFormats(splitColor,"hex");
+ //console.log(pixel.color);
+ if(pixel.fadeRate == 0 || (pixel.fadeRate && isNaN(pixel.fadeRate))) {
+ } else {
+ pixel.life -= (pixel.fadeRate ?? 1);
+ };
+ if(pixel.life < 0) {
+ deletePixel(pixel.x,pixel.y);
+ return
+ }
+ }
+ };
+ sweepingLaserTransparencyWhitelist = ["glass","glass_shard","rad_glass","rad_glass_shard","glass_pane","rad_glass_pane","water","salt_water","sugar_water","pool_water"];
+ sweepingLaserTransparencyBlacklist = [];
+ //Sweeping laser
+ elements.sweeping_laser = {
+ "color": "#905050",
+ "tick": function(pixel) {
+ pixel.r ??= 0;
+ if(isNaN(pixel.r)) { return false };
+ pixel.rSpeed ??= -0.03;
+ pixel.beamLength ??= 10;
+ pixel.beamTemp ??= 2000;
+ pixel.brevity ??= 5;
+ pixel.beamColor ??= "#FF0000";
+ var beamElement = "test_fader";
+ var rotation = -(((pixel.r ?? 0) % 4) + 1); //preserving the original behavior of 0 = up, 1 = left
+ var rotationInRadians = scale(rotation,0,4,0,Math.PI * 2);
+ var vector = [Math.cos(rotationInRadians), Math.sin(rotationInRadians)];
+ var distance = Math.min(300,Math.max(2,(pixel.beamLength + 1) ?? 10));
+ for(var i = 1; i <= distance; i += 0.5) { //twice the tries to try to reduce gaps in the beam
+ var newOffsets = vector.map(coord => Math.round(coord * i));
+ var finalPos = {x: pixel.x + newOffsets[0], y: pixel.y + newOffsets[1]};
+ //console.log(finalPos);
+ //console.log({x:pixel.x,y:pixel.y},finalPos);
+ if(!(isEmpty(finalPos.x,finalPos.y))) {
+ var otherPixel = pixelMap[finalPos.x]?.[finalPos.y];
+ if(otherPixel && (
+ [beamElement,pixel.element].concat(sweepingLaserTransparencyWhitelist).includes(otherPixel.element) ||
+ elements[otherPixel.element].state === "gas"
+ ) && !(sweepingLaserTransparencyBlacklist.includes(otherPixel.element))) {
+ if(otherPixel.element == "test_fader") { //intentionally hard-coded
+ otherPixel.life = 100
+ };
+ continue
+ } else {
+ break
+ }
+ };
+ var newBeamPixel = tryCreatePixelReturn(beamElement,finalPos.x,finalPos.y);
+ if(!newBeamPixel) {
+ break
+ } else {
+ newBeamPixel.temp = pixel.beamTemp ?? 2000;
+ newBeamPixel.fadeRate = pixel.brevity ??= 5;
+ newBeamPixel.color = (pixel.beamColor ?? "#FF0000");
+ }
+ };
+ pixel.r += pixel.rSpeed ?? 0.03;
+ },
+ "reactions": {
+ "water": { elem1: "steel", charge1: 1 },
+ },
+ "category": "special",
+ "breakInto": "charcoal",
+ "tempHigh": 2700,
+ "stateHigh": "molten_steel",
+ };
//hormones
-
//estrogens
-
elements.estradiol = {
color: "#f2fcee", //it absorbs shorter wavelength UV than testosterone and I am treating this like absorbing violet for convenience
//https://www.researchgate.net/publication/226065469_Optical_Properties_of_Two_Types_of_Sex_Hormones_of_the_Cyclopentenephenanthrene_Series
@@ -6990,12 +6796,10 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempHigh: 173,
category: "powders",
},
-
elements.molten_estradiol = {
tempHigh: 446,
stateHigh: "vaporized_estradiol",
},
-
elements.vaporized_estradiol = {
color: ["#ffbf60","#ffdc60","#ff9d60"], //hormone gas wouldn't glow that brightly at these temperatures but just ignore that
behavior: behaviors.GAS,
@@ -7007,9 +6811,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempLow: 446,
stateLow: "molten_estradiol",
},
-
//progestogens
-
elements.progesterone = {
color: "#f7eefc", //slightly different? from testosterone but exaggerated
//https://downloads.hindawi.com/journals/ijps/2017/9603140.pdf
@@ -7021,12 +6823,10 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempHigh: 121,
category: "powders",
},
-
elements.molten_progesterone = {
tempHigh: 447,
stateHigh: "vaporized_progesterone",
},
-
elements.vaporized_progesterone = {
color: ["#ffbf60","#ffdc60","#ff9d60"],
behavior: behaviors.GAS,
@@ -7037,11 +6837,8 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempLow: 447,
stateLow: "molten_progesterone",
}
-
//androgens
-
//plain testosterone
-
elements.testosterone = {
color: "#f7eef7", //it absorbs longer wavelength UV than estradiol and I am treating this like absorbing green for convenience
behavior: behaviors.POWDER,
@@ -7051,13 +6848,11 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempHigh: 155,
category: "powders",
},
-
elements.molten_testosterone = {
tempHigh: 433,
temp: 400,
stateHigh: "vaporized_testosterone",
},
-
elements.vaporized_testosterone = {
color: ["#ffbf60","#ffdc60","#ff9d60"],
behavior: behaviors.GAS,
@@ -7069,9 +6864,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempLow: 433,
stateLow: "molten_testosterone",
},
-
//undecanoate (form actually used in HRT)
-
elements.testosterone_undecanoate = {
color: "#f8f2fc", //more creatively-interpreted UV data: https://spectrabase.com/spectrum/5Yc7XCCDkA7 plus http://depts.washington.edu/cmditr/modules/lum/color.html and a lot of eyeballing and loose approximation
behavior: behaviors.POWDER,
@@ -7081,13 +6874,11 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempHigh: 63,
category: "powders",
},
-
elements.molten_testosterone_undecanoate = {
tempHigh: 550,
stateHigh: "vaporized_testosterone_undecanoate",
hidden: true,
},
-
elements.vaporized_testosterone_undecanoate = {
color: ["#ffbf60","#ffdc60","#ff9d60"],
behavior: behaviors.GAS,
@@ -7099,13 +6890,9 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempLow: 63,
stateLow: "molten_testosterone_undecanoate",
},
-
//other
-
//anti-androgens
-
//CPA
-
elements.cyproterone_acetate = {
color: "#efeef8", //it absorbs far longer uv than the others, which i am rendering as red absorption
//https://www.researchgate.net/figure/UV-spectrum-for-drospirenone-cyproterone-acetate-desogestrel-and-ethinyl-estradiol-at-1_fig1_315746083
@@ -7117,21 +6904,17 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempHigh: 200,
category: "powders",
},
-
/* > Hazardous decomposition products:
> Hydrogen chloride (HCl)
> Carbon monoxide and carbon dioxide
> Hydrogen
-
> https://cdn.caymanchem.com/cdn/msds/16622m.pdf
-
so many interesting effects i can't add
*/
elements.molten_cyproterone_acetate = {
tempHigh: 569,
stateHigh: "vaporized_cyproterone_acetate",
},
-
elements.vaporized_cyproterone_acetate = {
color: ["#ffbf60","#ffdc60","#ff9d60"],
behavior: behaviors.GAS,
@@ -7142,9 +6925,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempLow: 569,
stateLow: "molten_cyproterone_acetate",
},
-
//spironolactone
-
elements.spironolactone = {
color: "#f7eef1", //UV absorbance peak wavelength is slightly shorter than that of testosterone
//https://www.researchgate.net/publication/348592381_Quantification_of_Spironolactone_by_first_and_second_order_UV_Derivative_Spectrophotometry_in_bulk_and_tablet_dosage_form/link/6006b3cf299bf14088a649bd/download
@@ -7155,7 +6936,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempHigh: 207,
category: "powders",
},
-
elements.molten_spironolactone = {
tempHigh: 597,
stateHigh: "vaporized_spironolactone",
@@ -7163,7 +6943,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
https://sci-hub.se/https://link.springer.com/article/10.1007/BF01979243
> The TG-DTG curves of spironolactone in Fig. 7 demonstrate that the compound is thermally stable up to 200*C, and that its thermal decomposition occurs between 200 and 620*C. Four consecutive steps are observed in the TG-DTG curves. The first step, up to 260*C is ascribed to the elimination of the substituent group, SCOCH_{3} (TG= 19.59%, Calc. = 19.33%). The second step (260-370*C) and the third and fourth steps (370-700*C) involve losses of 42.93% and 37.48%, respectively, but do not permit a suggestion as to which parts of the compound are eliminated in each step. */
},
-
elements.vaporized_spironolactone = {
color: ["#ffbf60","#ffdc60","#ff9d60"],
behavior: behaviors.GAS,
@@ -7174,9 +6953,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempLow: 597,
stateLow: "molten_spironolactone",
},
-
//finasteride
-
elements.finasteride = {
color: "#fcfcf1", //UV absorbance peak wavelength is even shorter than that of estradiol
//https://www.researchgate.net/publication/312317200
@@ -7187,12 +6964,10 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempHigh: 253,
category: "powders",
},
-
elements.molten_finasteride = {
tempHigh: 577,
stateHigh: "vaporized_finasteride",
},
-
elements.vaporized_finasteride = {
color: ["#ffbf60","#ffdc60","#ff9d60"],
behavior: behaviors.GAS,
@@ -7203,9 +6978,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempLow: 577,
stateLow: "molten_finasteride",
},
-
//dutasteride
-
elements.dutasteride = {
color: "#fbf6ee", //High UV absorbances around the peak wavelengths of both estradiol and testosterone
//https://sphinxsai.com/sphinxsaivol_2no.1/pharmtech_vol_2no.1/PharmTech_Vol_2No.1PDF/PT=18%20(113-117).pdf
@@ -7216,12 +6989,10 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempHigh: 243,
category: "powders",
},
-
elements.molten_dutasteride = {
tempHigh: 620, //http://www.chemspider.com/Chemical-Structure.5293502.html
stateHigh: "vaporized_dutasteride",
},
-
elements.vaporized_dutasteride = {
color: ["#ffbf60","#ffdc60","#ff9d60"],
behavior: behaviors.GAS,
@@ -7232,9 +7003,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempLow: 620,
stateLow: "molten_dutasteride",
},
-
//bicalutamide
-
elements.bicalutamide = {
color: "#f4fcee", //peaks at 200-220 and at 270
//i am probably mapping uv to visible wrong and misreading color.html
@@ -7246,12 +7015,10 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempHigh: 192,
category: "powders",
},
-
elements.molten_bicalutamide = {
tempHigh: 659,
stateHigh: "vaporized_bicalutamide",
},
-
elements.vaporized_bicalutamide = {
color: ["#ffbf60","#ffdc60","#ff9d60"],
behavior: behaviors.GAS,
@@ -7262,9 +7029,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempLow: 659,
stateLow: "molten_bicalutamide",
},
-
//puberty blockers
-
elements.leuprolide = {
color: "#f5eefb", //http://dspace.hmlibrary.ac.in:8080/jspui/bitstream/123456789/1143/11/11_Chapter%203.pdf
behavior: behaviors.POWDER,
@@ -7274,12 +7039,10 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempHigh: 150,
category: "powders",
},
-
elements.molten_leuprolide = {
tempHigh: 1720, //https://web.archive.org/web/20210512074205/http://www.shreejipharmainternational.com/leuprolide-acetate-1177796.html
stateHigh: "vaporized_leuprolide",
},
-
elements.vaporized_leuprolide = {
color: ["#ffbf60","#ffdc60","#ff9d60"],
behavior: behaviors.GAS,
@@ -7290,9 +7053,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempLow: 1720,
stateLow: "molten_leuprolide",
},
-
//histrelin
-
elements.histrelin = {
color: "#f8f5ee", //no spectrum available
behavior: behaviors.POWDER,
@@ -7303,7 +7064,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
stateHigh: "vaporized_histrelin",
category: "powders",
},
-
elements.vaporized_histrelin = {
color: ["#ffbf60","#ffdc60","#ff9d60"],
behavior: behaviors.GAS,
@@ -7313,9 +7073,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
tempLow: 1800,
stateLow: "histrelin",
},
-
//end of hrt section
-
elements.densinium = {
color: ["#565656","#575657","#565257","#554d57","#554659"],
tempHigh: 4712, //arbitrary
@@ -7326,13 +7084,10 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
category: "solids",
} //this is effectively a mere interpretation of densinium
-
elements.molten_densinium = {
hardness: 0.9991,
}
-
elements.acid.ignore.push("densinium","molten_densinium")
-
//maxColorOffset will only be applied if maxColorOffset.js is enabled
elements.silk_velvet = {
color: ["#edece8", "#ede7e4"],
@@ -7349,7 +7104,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
burnTime:25,
density: 182,
};
-
elements.red_velvet = {
color: ["#a80508", "#b30b0e"],
maxColorOffset: 7,
@@ -7360,7 +7114,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
"XX|XX|XX",
"XX|M1|XX",
],
- tick: function() { //alias for velvet that is red
+ tick: function(pixel) { //alias for velvet that is red
pixel.element = "silk_velvet";
},
burnInto: "ash",
@@ -7368,13 +7122,11 @@ color1 and color2 spread through striped paint like dye does with itself. col
burnTime: 25,
density: 182,
};
-
elements.netherrack.hardness = 0.07;
elements.netherrack.breakInto = ["crushed_netherrack","crushed_netherrack","crushed_netherrack","crushed_netherrack","crushed_netherrack","crushed_netherrack","crushed_netherrack","sulfur"] // and some copper, gold, iron, nickel after processing //sulfur closer to 1/7 in-game
elements.netherrack.burn = 9
elements.netherrack.burnTime = 9007199254740995
elements.netherrack.burnInto = "netherrack"
-
elements.crushed_netherrack = {
color: ["#e34b46","#b04235","#73431f","#522510","#7a3326"],
behavior: behaviors.POWDER,
@@ -7388,7 +7140,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
hardness: 0.02,
hidden: true,
};
-
elements.sencc = { //same element neighbor count check
color: "#000000",
uwu: 0,
@@ -7415,7 +7166,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
hidden: true,
},
-
elements.sencc2 = { //same element neighbor count check
color: "#000000",
uwu: 0,
@@ -7442,7 +7192,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
hidden: true,
},
-
elements.sencc3 = { //same element neighbor count check
color: "#000000",
uwu: 0,
@@ -7470,7 +7219,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
hidden: true,
},
-
elements.sencc4 = { //same element neighbor count check
color: "#000000",
uwu: 0,
@@ -7498,7 +7246,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
hidden: true,
},
-
elements.sencc5 = { //same element neighbor count check
color: "#000000",
uwu: 0,
@@ -7526,7 +7273,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
hidden: true,
},
-
elements.sencc6 = { //same element neighbor count check
color: "#000000",
uwu: 0,
@@ -7554,7 +7300,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
hidden: true,
},
-
elements.sencc7 = { //same element neighbor count check
color: "#000000",
uwu: 0,
@@ -7582,7 +7327,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
hidden: true,
},
-
elements.sencc8 = { //same element neighbor count check
color: "#000000",
uwu: 0,
@@ -7610,7 +7354,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
hidden: true,
},
-
elements.sencc9 = { //same element neighbor count check
color: "#000000",
uwu: 0,
@@ -7638,7 +7381,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
hidden: true,
},
-
elements.sencc10 = { //same element neighbor count check
color: "#000000",
uwu: 0,
@@ -7666,7 +7408,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
hidden: true,
},
-
elements.sencc11 = { //same element neighbor count check
color: "#000000",
uwu: 0,
@@ -7694,7 +7435,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
hidden: true,
},
-
elements.sencc2b = { //same element neighbor count check
color: "#000000",
uwu: 0,
@@ -7727,7 +7467,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
hidden: true,
},
-
elements.discharge = {
color: "#7f7f7f",
tick: function(pixel) {
@@ -7745,7 +7484,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
behavior: behaviors.SELFDELETE,
},
-
elements.troll_powder = {
color: ["#ffffff","#000000"],
tick: function(pixel) {
@@ -7766,14 +7504,13 @@ color1 and color2 spread through striped paint like dye does with itself. col
if(fff < 5/5) { tryMove(pixel, pixel.x+2, pixel.y-1) }
}
if(Math.random() < 0.0003) { tryMove(pixel, pixel.y, pixel.y); }
- if(Math.random() < 0.0003) { tryMove(pixel, pixel.x, pixel.x); }
+ if(Math.random() < 0.0003) { tryMove(pixel, pixel.x, pixel.x); }
if(((Math.floor(pixel.x/2) % 2 == 0) && (Math.floor(pixel.y/2) % 2 == 0)) || ((Math.floor(pixel.x/2) % 2 == 1) && (Math.floor(pixel.y/2) % 2 == 1))) {
pixel.color = "rgb(32,32,32)"
} else {
pixel.color = "rgb(224,224,224)"
}
}
-
if(ddd >= 0.9) {
if(!tryMove(pixel, pixel.x, pixel.y-1)) {
if(eee < 1/2) { tryMove(pixel, pixel.x-1, pixel.y-1) } else tryMove(pixel, pixel.x+1, pixel.y-1)
@@ -7786,7 +7523,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
if(fff < 5/5) { tryMove(pixel, pixel.x+2, pixel.y+1) }
}
if(Math.random() < 0.0003) { tryMove(pixel, pixel.y, pixel.y); }
- if(Math.random() < 0.0003) { tryMove(pixel, pixel.x, pixel.x); }
+ if(Math.random() < 0.0003) { tryMove(pixel, pixel.x, pixel.x); }
if(((Math.floor(pixel.x/2) % 2 == 0) && (Math.floor(pixel.y/2) % 2 == 0)) || ((Math.floor(pixel.x/2) % 2 == 1) && (Math.floor(pixel.y/2) % 2 == 1))) {
pixel.color = "rgb(32,32,32)"
} else {
@@ -7799,7 +7536,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
density: 1602,
},
-
elements.void_first = {
color: "#262626",
tick: function(pixel) {
@@ -7979,7 +7715,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
delete pixel.dc4;
}
}
-
for(i = 0; i < adjacentCoords.length; i++) {
var pX = pixel.x; var pY = pixel.y; var oX = adjacentCoords[i][0]; var oY = adjacentCoords[i][1]; var nX = pX+oX; var nY = pY+oY;
if(!isEmpty(nX,nY,true)) {
@@ -7994,7 +7729,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
category:"special",
hardness: 1,
},
-
elements.converter = {
color: "#2ec408",
tick: function(pixel) {
@@ -8174,7 +7908,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
delete pixel.dc4;
}
}
-
for(i = 0; i < adjacentCoords.length; i++) {
var pX = pixel.x; var pY = pixel.y; var oX = adjacentCoords[i][0]; var oY = adjacentCoords[i][1]; var nX = pX+oX; var nY = pY+oY;
if(!isEmpty(nX,nY,true)) {
@@ -8191,9 +7924,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
ignore: ["wall","cloner","liquid_cloner","slow_cloner","void","clone_powder","floating_cloner","void_first","converter"],
hardness: 1,
},
-
conveyorIgnoreList = ["conveyor_1","conveyor_2","wall"]
-
elements.conveyor_1 = {
color: "#7f7f7f",
tick: function(pixel) {
@@ -8278,7 +8009,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
insulate: true,
state: "solid",
},
-
elements.conveyor_2 = {
color: "#7f7f7f",
tick: function(pixel) {
@@ -8363,7 +8093,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
insulate: true,
state: "solid",
},
-
elements.vanishing_wall = {
behavior: behaviors.WALL,
color: "#8080b0",
@@ -8384,7 +8113,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
conduct: 1,
extraInfo: "It disappears when charged.",
},
-
elements.vanishing_steel = {
color: "#71797E",
behavior: behaviors.WALL,
@@ -8402,7 +8130,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
conduct: 1,
hardness: 0.8,
};
-
elements.polka_dotted_powder = {
color: ["#000000","#000000","#7f7f7f","#ffffff","#ffffff"],
behavior: behaviors.POWDER,
@@ -8419,7 +8146,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
} else {
pixel.color = "rgb(0,0,0)"
}
- }
+ }
} else if((pixel.y + 3) % 6 == 0) {
if((pixel.x + 3) % 6 == 0) {
pixel.color = "rgb(255,255,255)"
@@ -8429,7 +8156,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
} else {
pixel.color = "rgb(0,0,0)"
}
- }
+ }
} else {
if(!settings.bg || settings.bg == "#000000") {
pixel.color = "rgb(15,15,15)"
@@ -8440,7 +8167,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
},
tempHigh: 800,
},
-
elements.molten_polka_dotted_powder = {
color: ["#ff7f00","#ff7f00","#ff9f00","#ffbf00","#ffbf00"],
density: 1100,
@@ -8454,7 +8180,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
} else {
pixel.color = "rgb(255,127,16)"
}
- }
+ }
} else if((pixel.y + 3) % 6 == 0) {
if((pixel.x + 3) % 6 == 0) {
pixel.color = "rgb(255,191,0)"
@@ -8464,7 +8190,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
} else {
pixel.color = "rgb(255,127,16)"
}
- }
+ }
} else {
if(!settings.bg || settings.bg == "#ff7f00") {
pixel.color = "rgb(255,143,16)"
@@ -8481,7 +8207,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
viscosity: 6,
hidden: true,
},
-
elements.vaporized_polka_dotted_powder = {
color: ["#ffdf7f","#ffdf7f","#ffefbf","#ffffff","#ffffff"],
behavior: behaviors.GAS,
@@ -8498,7 +8223,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
} else {
pixel.color = "rgb(255,223,127)"
}
- }
+ }
} else if((pixel.y + 3) % 6 == 0) {
if((pixel.x + 3) % 6 == 0) {
pixel.color = "rgb(255,255,255)"
@@ -8508,7 +8233,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
} else {
pixel.color = "rgb(255,233,137)"
}
- }
+ }
} else {
if(!settings.bg || settings.bg == "#ffdf7f") {
pixel.color = "rgb(255,233,137)"
@@ -8524,7 +8249,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
stateHigh: "ionized_polka_dotted_powder",
hidden: true,
},
-
elements.ionized_polka_dotted_powder = {
color: ["#fffff0","#fffff0","#fffff7","#ffffff","#ffffff"],
behavior: [
@@ -8545,7 +8269,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
} else {
pixel.color = "rgb(255,255,240)"
}
- }
+ }
} else if((pixel.y + 3) % 6 == 0) {
if((pixel.x + 3) % 6 == 0) {
pixel.color = "rgb(255,255,255)"
@@ -8555,7 +8279,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
} else {
pixel.color = "rgb(255,255,240)"
}
- }
+ }
} else {
if(!settings.bg || settings.bg == "#fffff0") {
pixel.color = "rgb(255,255,247)"
@@ -8569,7 +8293,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
stateLow: "vaporized_polka_dotted_powder",
hidden: true,
},
-
elements.hdet = {
name: "heat- dependent explosion text",
color: "#33aa44",
@@ -8611,11 +8334,9 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
category: "special"
},
-
function randInt(max) {
return Math.floor(Math.random() * (max + 1))
}
-
function randIntR(min,max) {
if(min > max) {
var temp = max; //the need of a temporary space has always annoyed me
@@ -8624,7 +8345,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
};
return Math.floor(Math.random() * (max - min + 1)) + min
};
-
elements.lower_color_copy = {
behavior: behaviors.POWDER,
tick: function(pixel) {
@@ -8643,7 +8363,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
breakInto: ["metal_scrap", "glass_shard"],
hardness: 0.7,
}
-
elements.brimstone_slag = {
color: ["#745B57","#534D4A","#463F53","#51113E","#6D283B","#BC4949","#EA9B4E"],
properties: {
@@ -8686,27 +8405,20 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
}
};
-
elements.molten_slag ??= {};
elements.molten_slag.reactions ??= {};
-
elements.molten_slag.reactions.sulfur = elements.molten_slag.reactions.molten_sulfur = elements.molten_slag.reactions.sulfur_gas = elements.molten_sulfur.reactions.slag = elements.sulfur.reactions.molten_slag = { elem1: "brimstone_slag", elem2: null };
-
elements.slag.tempHigh = 1780;
-
var temp = "firesea,lektre,concoction,mistake,unstable_mistake,toxic_mistake".split(",");
for(var i = 0; i < temp.length; i++) {
temp[i].state = "liquid";
temp[i].category = "liquids"
};
-
-
elements.head.cutInto = ["bone","meat","blood"];
elements.body.cutInto = ["bone","meat","meat","blood","blood"];
elements.wood.cutInto = ["wood_plank","wood_plank","wood_plank","wood_plank","wood_plank","wood_plank","wood_plank","wood_plank","sawdust"];
elements.fish.breakInto = ["meat","meat","bone","blood"];
elements.fish.cutInto = ["meat","meat","bone","blood"];
-
elements.bladesea = {
color: ["#959696", "#b1b3b3", "#d4d4d4", "#bfbdbd"],
state: "liquid",
@@ -8744,14 +8456,12 @@ color1 and color2 spread through striped paint like dye does with itself. col
"concoction": { "elem1": "bladesea", "elem2": "bladesea", "chance":0.005},
},
};
-
function newLegacyFnmDye(colorName,hexColor) {
if(!(hexColor.startsWith("#"))) { hexColor = "#" + hexColor };
colorName = colorName.toLowerCase();
var key = `${colorName}_dye`;
var name = `${colorName.replaceAll("_"," ")} dye`;
var pixelColor = changeLuminance(hexColor,0.73333333333333,"multiply","hex",null,false);
-
elements[key] = {
"name": name,
"color": pixelColor,
@@ -8764,11 +8474,10 @@ color1 and color2 spread through striped paint like dye does with itself. col
"density": 100,
"category": "dyes"
};
- eLists.DYE.push(key);
+ eLists.DYE.push(key);
elements.concoction.reactions[key] = { "elem1": "mistake", "elem2": null };
return elements[key]
};
-
var dyeColors = [
["rose", "#FF0067"],
["orange", "#FF7F00"],
@@ -8783,20 +8492,16 @@ color1 and color2 spread through striped paint like dye does with itself. col
["white", "#FFFFFF"],
["sky_blue", "#99d1f2"]
];
-
for(var i = 0; i < dyeColors.length; i++) {
newLegacyFnmDye(dyeColors[i][0],dyeColors[i][1])
};
-
eLists.LED = ["led_r","led_g","led_b"];
-
function newLED(abbrev,hexColor,baseColorOverrideHex=null) {
if(!(hexColor.startsWith("#"))) { hexColor = "#" + hexColor };
if(baseColorOverrideHex && !(baseColorOverrideHex.startsWith("#"))) { baseColorOverrideHex = "#" + baseColorOverrideHex };
abbrev = abbrev.toLowerCase();
var key = `led_${abbrev}`;
var pixelColor = baseColorOverrideHex ?? changeLuminance(hexColor,0x66/0xff,"multiply","hex",null,false);
-
elements[key] = {
behavior: behaviors.WALL,
reactions: {
@@ -8811,10 +8516,8 @@ color1 and color2 spread through striped paint like dye does with itself. col
conduct: 1,
breakInto: "glass_shard"
};
-
eLists.LED.push(key)
};
-
var ledColors = [
["c", "#00FFFF"], //cyan
["y", "#FFFF00"], //yellow
@@ -8834,31 +8537,22 @@ color1 and color2 spread through striped paint like dye does with itself. col
["mg", "#4df0a9"], //mint green
["sb", "#99d1f2"] //sky blue (cursed)
];
-
for(var i = 0; i < ledColors.length; i++) {
newLED(...ledColors[i]);
};
-
for(var i = 0; i < eLists.LED.length; i++) {
var key = eLists.LED[i];
elements.malware.reactions[key] = { elem2:eLists.LED, chance:0.01 }
};
-
//ASSORTED RAINBOW VARIANTS ##
-
elements.concoction.reactions.diorite_gravel = {
elem1: "static", elem2: null
};
-
elements.concoction.reactions.static = { //spread
elem1: "static", elem2: "static"
};
-
elements.concoction.state = "liquid";
-
elements.static.reactions ??= {}; elements.static.reactions.concoction = { "elem1": "static", "elem2": "static", "chance":0.005},
-
-
/*function isRed(colorIn) {
var color = colorToHsl(colorIn,"json");
var modularHue = color.h % 360;
@@ -8867,12 +8561,10 @@ color1 and color2 spread through striped paint like dye does with itself. col
if (color.l < 40 || color.l > 60) { return false };
return true
};
-
function isWhite(colorIn) {
var color = colorToHsl(colorIn,"json");
return color.s <= 15 && color.l >= 85
};*/
-
elements.rainbow.reactions ??= {};
elements.rainbow.reactions.fire = { elem1: "fireshimmer", chance: 0.1 };
elements.rainbow.reactions.plasma = { elem1: "plasmashimmer", chance: 0.1 };
@@ -8981,7 +8673,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
elements.rainbow.reactions.heejinite_powder = { elem1: "heejinshimmer" };
elements.rainbow.reactions.molten_heejinite = { elem1: "heejinshimmer" };
elements.rainbow.reactions.heejinite_gas = { elem1: "heejinshimmer" };
-
/*elements.rainbow.reactions.dye = {
func: function(pixel,otherPixel) {
//The dye reactant is the otherPixel
@@ -9001,7 +8692,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
return true
}
};*/
-
elements.rainbow.tick = function(pixel) {
var dyeColor = pixel.dyeColor ?? null;
var t = pixelTicks+pixel.x+pixel.y;
@@ -9022,7 +8712,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
pixel.color = convertColorFormats(finalColor,"rgb")
}
};
-
elements.rainbow.state = "solid";
elements.rainbow.reactions.dye = {
func: function(pixel,otherPixel) {
@@ -9042,9 +8731,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
}
}
};
-
rainbowMathlet = function(t,scale,offset) { return Math.cos(t*Math.PI/scale+offset*Math.PI/3) };
-
elements.dark_rainbow = {
color: ["#000000","#ff0000","#000000","#ff8800","#000000","#ffff00","#000000","#00ff00","#000000","#00ffff","#000000","#0000ff","#000000","#ff00ff"],
tick: function(pixel) {
@@ -9074,7 +8761,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
category: "rainbow variants",
};
-
elements.fireshimmer = {
color: ["#ff0000","#ff8800","#ffff00","#ff8800","#ff0000"],
tick: function(pixel) {
@@ -9082,7 +8768,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
var t = pixelTicks*3+pixel.x+pixel.y;
var g = Math.floor(127*((Math.max(0,1-(rainbowMathlet(t,25,0)))) ** 1.1));
baseColor = "rgb(255,"+g+",0)";
- if(!dyeColor) {
+ if(!dyeColor) {
pixel.color = baseColor
} else {
var baseJSON = convertColorFormats(baseColor,"json");
@@ -9105,7 +8791,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "rainbow variants",
movable: false,
};
-
elements.plasmashimmer = {
color: ["#8800ff","#f2f2f2","#8800ff","#f2f2f2"],
tick: function(pixel) {
@@ -9113,7 +8798,7 @@ color1 and color2 spread through striped paint like dye does with itself. col
var t = pixelTicks*3+pixel.x+pixel.y;
var value = Math.floor(127*((Math.max(0,1-(rainbowMathlet(t,25,0)))) ** 1.1));
baseColor = "rgb(" + [Math.round(127 + (value/2)), value, 255].join(",") + ")";
- if(!dyeColor) {
+ if(!dyeColor) {
pixel.color = baseColor
} else {
var baseJSON = convertColorFormats(baseColor,"json");
@@ -9135,7 +8820,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "rainbow variants",
movable: false,
};
-
elements.glitchy_rainbow = {
color: ["#ff0000","#ff8800","#ffff00","#ff8800","#ff0000"],
tick: function(pixel) {
@@ -9174,11 +8858,8 @@ color1 and color2 spread through striped paint like dye does with itself. col
category: "rainbow variants",
movable: false,
};
-
elements.rainbow.behavior = behaviors.WALL;
-
elements.dye.ignore ??= [];
-
elements.pastel_rainbow = {
color: ["#ffaacc","#ffaacc","#aaccff","#aaccff","#ffffbb","#ffffbb"],
tick: function(pixel) {
@@ -9234,7 +8915,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
category: "rainbow variants",
};
-
elements.rubyshimmer = {
color: ["#ff0000","#200000","#ff0000","#200000"],
tick: function(pixel) {
@@ -9246,7 +8926,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
category: "rainbow variants",
};
-
elements.topazshimmer = {
color: ["#ffff00","#202000","#ffff00","#202000"],
tick: function(pixel) {
@@ -9260,7 +8939,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
category: "rainbow variants",
};
-
elements.beeshimmer = {
color: ["#ffff00","#202000","#ffff00","#202000","#ffff00","#202000","#ffff00","#202000"],
tick: function(pixel) {
@@ -9274,7 +8952,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
category: "rainbow variants",
};
-
elements.ambershimmer = {
color: ["#ff7f00","#201000","#ff7f00","#201000"],
tick: function(pixel) {
@@ -9287,7 +8964,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
category: "rainbow variants",
};
-
elements.emeraldshimmer = {
color: ["#00ff00","#002000","#00ff00","#002000"],
tick: function(pixel) {
@@ -9300,7 +8976,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
category: "rainbow variants",
};
-
elements.iceshimmer = {
color: ["#00ffff","#001520","#00ffff","#001520"],
tick: function(pixel) {
@@ -9313,7 +8988,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
category: "rainbow variants",
};
-
elements.sapphireshimmer = {
color: ["#0000ff","#000020","#0000ff","#000020"],
tick: function(pixel) {
@@ -9326,7 +9000,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
category: "rainbow variants",
};
-
elements.amethystshimmer = {
color: ["#7f00ff","#100020","#7f00ff","#100020"],
tick: function(pixel) {
@@ -9339,7 +9012,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
category: "rainbow variants",
};
-
elements.spinelshimmer = {
color: ["#ff00ff","#200020","#ff00ff","#200020"],
tick: function(pixel) {
@@ -9352,7 +9024,6 @@ color1 and color2 spread through striped paint like dye does with itself. col
state: "solid",
category: "rainbow variants",
};
-
elements.mulliteshimmer = {
color: ["#f8eeff","#151020","#f8eeff","#151020"],
tick: function(pixel) {
@@ -9365,7 +9036,6 @@ color1 and color2 spread through striped paint like dye does with itself.