Merge pull request #416 from JustAGenericUsername/main
i made heatglow.js gooder
This commit is contained in:
commit
dded5b1849
|
|
@ -1,3 +1,6 @@
|
|||
function weightedAverage(num1, num2, weight){
|
||||
return ((weight * num1)+((1-weight)*num2))
|
||||
}
|
||||
const heatfunc = function(pixel){
|
||||
if (pixel.ogR == null || pixel.ogG == null || pixel.ogB == null || !(pixel.element == pixel.ogElement)){
|
||||
pixel.ogR = parseInt(pixel.color.slice(4, pixel.color.indexOf(',')), 10)
|
||||
|
|
@ -5,23 +8,24 @@ const heatfunc = function(pixel){
|
|||
pixel.ogB = parseInt(pixel.color.slice(pixel.color.lastIndexOf(',') + 1, -1), 10)
|
||||
pixel.ogElement = pixel.element
|
||||
}else{
|
||||
pixel.gethigh = (elements[pixel.element].tempHigh)
|
||||
pixel.halftemp = ((20+pixel.gethigh)/2)
|
||||
if (pixel.temp <= (pixel.gethigh) - pixel.halftemp){
|
||||
pixel.ctemp = 0;
|
||||
} else if (pixel.temp > (pixel.gethigh)-pixel.halftemp && pixel.temp <= pixel.gethigh){
|
||||
pixel.ctemp = ((1/pixel.halftemp)*pixel.temp)-(((pixel.gethigh)-pixel.halftemp)/pixel.halftemp)
|
||||
var gethigh = (elements[pixel.element].tempHigh)
|
||||
var halftemp = ((20+gethigh)/2)
|
||||
if (pixel.temp <= (gethigh) - halftemp){
|
||||
var ctemp = 0;
|
||||
} else if (pixel.temp > (gethigh)-halftemp && pixel.temp <= gethigh){
|
||||
var ctemp = ((1/halftemp)*pixel.temp)-(((gethigh)-halftemp)/halftemp)
|
||||
}
|
||||
if (pixel.ctemp <= 0.5){
|
||||
pixel.newR = (((510-(2*pixel.ogR))*pixel.ctemp)+pixel.ogR);
|
||||
pixel.newG = ((0-((2*pixel.ogG)*pixel.ctemp))+pixel.ogG);
|
||||
pixel.newB = ((0-((2*pixel.ogB)*pixel.ctemp))+pixel.ogB);
|
||||
}else if (pixel.ctemp > 0.5){
|
||||
pixel.newR = 255;
|
||||
pixel.newG = ((510*pixel.ctemp)-255);
|
||||
pixel.newB= ((280*pixel.ctemp)-140);
|
||||
if (ctemp <= 0.5){
|
||||
var newR = (((510-(2*pixel.ogR))*ctemp)+pixel.ogR);
|
||||
var newG = ((0-((2*pixel.ogG)*ctemp))+pixel.ogG);
|
||||
var newB = ((0-((2*pixel.ogB)*ctemp))+pixel.ogB);
|
||||
}else if (ctemp > 0.5){
|
||||
var newR = 255;
|
||||
var newG = ((510*ctemp)-255);
|
||||
var newB= ((280*ctemp)-140);
|
||||
}
|
||||
pixel.color = "rgb(" + pixel.newR + "," + pixel.newG + "," + pixel.newB + ")";
|
||||
let weight = (1-(ctemp/1.3))
|
||||
pixel.color = "rgb(" + weightedAverage(pixel.ogR, newR, weight) + "," + weightedAverage(pixel.ogG, newG, weight) + "," + weightedAverage(pixel.ogB, newB, weight) + ")";
|
||||
}
|
||||
};
|
||||
if (!eLists.metals) { eLists.metals = [] }
|
||||
|
|
@ -53,9 +57,6 @@ elements.color_baker = {
|
|||
desc: "Use to bake a metals paint color into its 'true' color, for heating purposes.",
|
||||
}
|
||||
/*
|
||||
function weightedAverage(num1, num2, weight){
|
||||
return ((weight * num1)+((1-weight)*num2))
|
||||
}
|
||||
const plantfunc = function(pixel){
|
||||
if (pixel.ogR == null || pixel.ogG == null || pixel.ogB == null){
|
||||
pixel.ogR = parseInt(pixel.color.slice(4, pixel.color.indexOf(',')), 10)
|
||||
|
|
|
|||
|
|
@ -2302,4 +2302,44 @@ elements.selective_void = {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let radiusVar = 0
|
||||
let circleElem = 0
|
||||
let circleRep = false
|
||||
elements.scuffed_circle_brush = {
|
||||
category: "special",
|
||||
color: elements.drag.color,
|
||||
excludeRandom: true,
|
||||
state: "solid",
|
||||
movable: "false",
|
||||
onSelect: function(){
|
||||
var answerR = prompt("Radius of the brush.",(radiusVar||undefined));
|
||||
if (!answerR) { return }
|
||||
radiusVar = answerR;
|
||||
var answerE = prompt("Element of the brush.",(circleElem||undefined));
|
||||
if (!answerE) { return }
|
||||
circleElem = answerE;
|
||||
var answerH = prompt("Replace? y or n. May be laggy.",(circleRep||undefined));
|
||||
if (!answerH) { return }
|
||||
circleRep = answerH;
|
||||
},
|
||||
tick: function(pixel){
|
||||
var circlec = circleCoords(pixel.x, pixel.y, radiusVar)
|
||||
for (var i = 0; i < circlec.length; i++){
|
||||
var coord = circlec[i]
|
||||
var x = coord.x
|
||||
var y = coord.y
|
||||
if (isEmpty(x, y)){
|
||||
createPixel(circleElem, x, y)
|
||||
}
|
||||
else if (!isEmpty(x, y, true) && !(circleRep == "n")){
|
||||
deletePixel(x, y)
|
||||
createPixel(circleElem, x, y)
|
||||
}
|
||||
}
|
||||
var thisx = pixel.x
|
||||
var thisy = pixel.y
|
||||
deletePixel(thisx, thisy)
|
||||
createPixel(circleElem, thisx, thisy)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue