Added color mix conditions and hoverstat for fruit leaves
This commit is contained in:
parent
71eff8655a
commit
684d7a45bc
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
|
||||||
*Version 1.0.0
|
|
||||||
*/
|
|
||||||
function noiseify(color, range){
|
function noiseify(color, range){
|
||||||
if(color.startsWith("#")){
|
if(color.startsWith("#")){
|
||||||
color = hexToRGB(color);
|
color = hexToRGB(color);
|
||||||
|
|
@ -18,10 +18,17 @@ function is2d(arr){
|
||||||
return arr.some(item => Array.isArray(item));
|
return arr.some(item => Array.isArray(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
function colorMix(p1, p2, bias = 0.5){
|
function colorMix(p1, p2, bias = 0.5, condition = undefined){
|
||||||
c1 = p1.color;
|
if(condition != undefined && condition(p1,p2)){
|
||||||
p1.color = interpolateRgb(getRGB(p1.color), getRGB(p2.color), bias);
|
c1 = p1.color;
|
||||||
p2.color = interpolateRgb(getRGB(c1), getRGB(p2.color), bias);
|
p1.color = interpolateRgb(getRGB(p1.color), getRGB(p2.color), bias);
|
||||||
|
p2.color = interpolateRgb(getRGB(c1), getRGB(p2.color), bias);
|
||||||
|
} else {
|
||||||
|
c1 = p1.color;
|
||||||
|
p1.color = interpolateRgb(getRGB(p1.color), getRGB(p2.color), bias);
|
||||||
|
p2.color = interpolateRgb(getRGB(c1), getRGB(p2.color), bias);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function interpolateRgb(rgb1, rgb2, ratio = 0.5) {
|
function interpolateRgb(rgb1, rgb2, ratio = 0.5) {
|
||||||
|
|
@ -68,3 +75,15 @@ function pixelToggle(pixel, multi = {r:1,g:1,b:1}){
|
||||||
function normalize(obj){
|
function normalize(obj){
|
||||||
return `rgb(${obj.r},${obj.g},${obj.b})`;
|
return `rgb(${obj.r},${obj.g},${obj.b})`;
|
||||||
}
|
}
|
||||||
|
let mixConditions = {
|
||||||
|
ifDifferent: function(p1,p2){
|
||||||
|
let res = false;
|
||||||
|
let rgb1 = getRGB(p1.color), rgb2 = getRGB(p2.color);
|
||||||
|
for(let key in rgb1){
|
||||||
|
if(rgb1[key] < rgb2[key]+6 || rgb1[key] > rgb2[key]-6){
|
||||||
|
res = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
/*
|
/*
|
||||||
*Version 2.2.1
|
*Version 2.2.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let plants;
|
let plants;
|
||||||
let growthPatterns = {
|
let growthPatterns = {
|
||||||
pineapple1: [[-1,-1],[-2,-2],[1,-1],[2,-2],[0,-1],[0,-2],[0,-3],[0,-4],[0,-5],[0,-6],[-1,-6],[1,-6],[-1,-5],[1,-5],[-1,-4],[1,-4],[-1,-3],[1,-3],[0,-7],[-1,-8],[1,-8]],
|
pineapple1: [[-1,-1],[-2,-2],[1,-1],[2,-2],[0,-1],[0,-2],[0,-3],[0,-4],[0,-5],[0,-6],[-1,-6],[1,-6],[-1,-5],[1,-5],[-1,-4],[1,-4],[-1,-3],[1,-3],[0,-7],[-1,-8],[1,-8]],
|
||||||
|
|
@ -185,7 +188,18 @@ dependOn("orchidslibrary.js", ()=>{
|
||||||
if(this[item] && Array.isArray(this[item]) && this[item].includes(target)){return true;}
|
if(this[item] && Array.isArray(this[item]) && this[item].includes(target)){return true;}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
},
|
||||||
|
get all(){
|
||||||
|
let res = [];
|
||||||
|
for(let key in plants){
|
||||||
|
if(key != "all" && Array.isArray(plants[key])){
|
||||||
|
for(let plant of plants[key]){
|
||||||
|
res.push(plant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let ethyleneChance = {
|
let ethyleneChance = {
|
||||||
|
|
@ -293,6 +307,8 @@ dependOn("orchidslibrary.js", ()=>{
|
||||||
type: "fruit",
|
type: "fruit",
|
||||||
};
|
};
|
||||||
isFood = true;
|
isFood = true;
|
||||||
|
tempHigh = 65;
|
||||||
|
stateHigh = ["sugar", "dead_plant", "dead_plant", "dead_plant"];
|
||||||
constructor(name, colour, jColour, type = "tree", sColour = false, extract = false, low = false){
|
constructor(name, colour, jColour, type = "tree", sColour = false, extract = false, low = false){
|
||||||
this.properties.fruit = name;
|
this.properties.fruit = name;
|
||||||
this.color = colour;
|
this.color = colour;
|
||||||
|
|
@ -529,6 +545,9 @@ dependOn("orchidslibrary.js", ()=>{
|
||||||
dir: [1,1],
|
dir: [1,1],
|
||||||
bloomColor: "#FFE2E2",
|
bloomColor: "#FFE2E2",
|
||||||
},
|
},
|
||||||
|
hoverStat: function(pixel){
|
||||||
|
return pixel?.fruit || "NONE";
|
||||||
|
},
|
||||||
tick: function(pixel){
|
tick: function(pixel){
|
||||||
if(pixel.dieAfter != undefined){
|
if(pixel.dieAfter != undefined){
|
||||||
let chance = (pixel.age-pixel.dieAfter)/150;
|
let chance = (pixel.age-pixel.dieAfter)/150;
|
||||||
|
|
@ -635,14 +654,19 @@ dependOn("orchidslibrary.js", ()=>{
|
||||||
if(pixelTicks > pixel.start + 150){
|
if(pixelTicks > pixel.start + 150){
|
||||||
if(Math.random() < chance){
|
if(Math.random() < chance){
|
||||||
if(pixel.fruit){
|
if(pixel.fruit){
|
||||||
if(pixel.fruit == "random"){
|
if(pixel.fruit == "randomfruit"){
|
||||||
changePixel(pixel, fruits[Math.floor(Math.random() * fruits.length)]);
|
all = plants.all;
|
||||||
|
let elem = all[Math.round(Math.random()*all.length)];
|
||||||
|
while(elem == undefined || elements[elem] == undefined){
|
||||||
|
elem = all[Math.round(Math.random()*all.length)]
|
||||||
|
}
|
||||||
|
changePixel(pixel, elem);
|
||||||
}
|
}
|
||||||
if (pixel.pattern && pixel.growthPattern == false) {
|
if (pixel.pattern && pixel.growthPattern == false) {
|
||||||
pixel.blooming = false;
|
pixel.blooming = false;
|
||||||
pixel.growthPattern = true;
|
pixel.growthPattern = true;
|
||||||
|
|
||||||
} else {
|
} else if(pixel.fruit != "randomfruit") {
|
||||||
let c = (pixel.offspringColor) ? pixel.offspringColor : undefined;
|
let c = (pixel.offspringColor) ? pixel.offspringColor : undefined;
|
||||||
changePixel(pixel, pixel.fruit);
|
changePixel(pixel, pixel.fruit);
|
||||||
if(c != undefined){
|
if(c != undefined){
|
||||||
|
|
@ -886,7 +910,7 @@ dependOn("orchidslibrary.js", ()=>{
|
||||||
for(let i = 0; i < squareCoords.length; i++){
|
for(let i = 0; i < squareCoords.length; i++){
|
||||||
let x = pixel.x+squareCoords[i][0], y = pixel.y+squareCoords[i][1];
|
let x = pixel.x+squareCoords[i][0], y = pixel.y+squareCoords[i][1];
|
||||||
if(!isEmpty(x,y) && !outOfBounds(x,y) && pixelMap[x][y].element == pixel.element && Math.random() < 0.005){
|
if(!isEmpty(x,y) && !outOfBounds(x,y) && pixelMap[x][y].element == pixel.element && Math.random() < 0.005){
|
||||||
colorMix(pixel, pixelMap[x][y]);
|
colorMix(pixel, pixelMap[x][y], 0.5, mixConditions.ifDifferent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -894,7 +918,7 @@ dependOn("orchidslibrary.js", ()=>{
|
||||||
for(let i = 0; i < squareCoords.length; i++){
|
for(let i = 0; i < squareCoords.length; i++){
|
||||||
let x = pixel.x+squareCoords[i][0], y = pixel.y+squareCoords[i][1];
|
let x = pixel.x+squareCoords[i][0], y = pixel.y+squareCoords[i][1];
|
||||||
if(!isEmpty(x,y) && !outOfBounds(x,y) && pixelMap[x][y].element == pixel.element && Math.random() < 0.5){
|
if(!isEmpty(x,y) && !outOfBounds(x,y) && pixelMap[x][y].element == pixel.element && Math.random() < 0.5){
|
||||||
colorMix(pixel, pixelMap[x][y]);
|
colorMix(pixel, pixelMap[x][y], 0.5, mixConditions.ifDifferent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -902,7 +926,7 @@ dependOn("orchidslibrary.js", ()=>{
|
||||||
for(let i = 0; i < squareCoords.length; i++){
|
for(let i = 0; i < squareCoords.length; i++){
|
||||||
let x = pixel.x+squareCoords[i][0], y = pixel.y+squareCoords[i][1];
|
let x = pixel.x+squareCoords[i][0], y = pixel.y+squareCoords[i][1];
|
||||||
if(!isEmpty(x,y) && !outOfBounds(x,y) && pixelMap[x][y].element == pixel.element && Math.random() < 0.005){
|
if(!isEmpty(x,y) && !outOfBounds(x,y) && pixelMap[x][y].element == pixel.element && Math.random() < 0.005){
|
||||||
colorMix(pixel, pixelMap[x][y]);
|
colorMix(pixel, pixelMap[x][y], 0.5, mixConditions.ifDifferent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -910,7 +934,7 @@ dependOn("orchidslibrary.js", ()=>{
|
||||||
for(let i = 0; i < squareCoords.length; i++){
|
for(let i = 0; i < squareCoords.length; i++){
|
||||||
let x = pixel.x+squareCoords[i][0], y = pixel.y+squareCoords[i][1];
|
let x = pixel.x+squareCoords[i][0], y = pixel.y+squareCoords[i][1];
|
||||||
if(!isEmpty(x,y) && !outOfBounds(x,y) && pixelMap[x][y].element == pixel.element && Math.random() < 0.5){
|
if(!isEmpty(x,y) && !outOfBounds(x,y) && pixelMap[x][y].element == pixel.element && Math.random() < 0.5){
|
||||||
colorMix(pixel, pixelMap[x][y]);
|
colorMix(pixel, pixelMap[x][y], 0.5, mixConditions.ifDifferent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -919,8 +943,8 @@ dependOn("orchidslibrary.js", ()=>{
|
||||||
let rgb = interpolateRgb(getRGB(p1.color), getRGB(p2.color), 0.25);
|
let rgb = interpolateRgb(getRGB(p1.color), getRGB(p2.color), 0.25);
|
||||||
changePixel(p1, "fruit_milk");
|
changePixel(p1, "fruit_milk");
|
||||||
changePixel(p2, "fruit_milk");
|
changePixel(p2, "fruit_milk");
|
||||||
p1.color = rgb;
|
p1.color = noiseify(rgb, 6);
|
||||||
p2.color = rgb;
|
p2.color = noiseify(rgb, 6);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
elements.juice.reactions.carbon_dioxide = { func: function(p1,p2){
|
elements.juice.reactions.carbon_dioxide = { func: function(p1,p2){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue