added more
This commit is contained in:
parent
c9c6e6d9f2
commit
bf19eda990
|
|
@ -1036,8 +1036,205 @@ elements.op_hottester_bomb = {
|
||||||
temp: 7065,
|
temp: 7065,
|
||||||
density: 1300,
|
density: 1300,
|
||||||
excludeRandom: true,
|
excludeRandom: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* color-temperature.js
|
||||||
|
*
|
||||||
|
* Neil Bartlett
|
||||||
|
* neilbartlett.com
|
||||||
|
* 2015-01-22
|
||||||
|
*
|
||||||
|
* Copyright [2015] [Neil Bartlett] *
|
||||||
|
*
|
||||||
|
* Color Temperature is the color due to black body radiation at a given
|
||||||
|
* temperature. The temperature is given in Kelvin. The concept is widely used
|
||||||
|
* in photography and in tools such as f.lux.
|
||||||
|
*
|
||||||
|
* The function here converts a given color temperature into a near equivalent
|
||||||
|
* in the RGB colorspace. The function is based on a curve fit on standard sparse
|
||||||
|
* set of Kelvin to RGB mappings.
|
||||||
|
*
|
||||||
|
* Two conversions are presented here. The one colorTempertature2RGBUSingTH
|
||||||
|
* is a JS version of the algorithm developed by Tanner Helland. The second is a
|
||||||
|
* slightly more accurate conversion based on a refitting of the original data
|
||||||
|
* using different curve fit functions. The performance cost of the two
|
||||||
|
* approaches is very similar and in general the second algorithm is preferred.
|
||||||
|
*
|
||||||
|
* NOTE The approximations used are suitable for photo-mainpulation and other
|
||||||
|
* non-critical uses. They are not suitable for medical or other high accuracy
|
||||||
|
* use cases.
|
||||||
|
*
|
||||||
|
* Accuracy is best between 1000K and 40000K.
|
||||||
|
*
|
||||||
|
* See http://github.com/neilbartlett/color-temperature for further details.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
//[Code licensed under the MIT License]
|
||||||
|
|
||||||
|
//[Tanner Helland version omitted]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A more accurate version algorithm based on a different curve fit to the
|
||||||
|
* original RGB to Kelvin data.
|
||||||
|
* Input: color temperature in degrees Kelvin
|
||||||
|
* Output: json object of red, green and blue components of the Kelvin temperature
|
||||||
|
*/
|
||||||
|
colorTemperature2rgb = function(kelvin) {
|
||||||
|
|
||||||
|
var temperature = kelvin / 100.0;
|
||||||
|
var red, green, blue;
|
||||||
|
|
||||||
|
if (temperature < 66.0) {
|
||||||
|
red = 255;
|
||||||
|
} else {
|
||||||
|
// a + b x + c Log[x] /.
|
||||||
|
// {a -> 351.97690566805693`,
|
||||||
|
// b -> 0.114206453784165`,
|
||||||
|
// c -> -40.25366309332127
|
||||||
|
//x -> (kelvin/100) - 55}
|
||||||
|
red = temperature - 55.0;
|
||||||
|
red = 351.97690566805693+ 0.114206453784165 * red - 40.25366309332127 * Math.log(red);
|
||||||
|
if (red < 0) red = 0;
|
||||||
|
if (red > 255) red = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Calculate green */
|
||||||
|
|
||||||
|
if (temperature < 66.0) {
|
||||||
|
|
||||||
|
// a + b x + c Log[x] /.
|
||||||
|
// {a -> -155.25485562709179`,
|
||||||
|
// b -> -0.44596950469579133`,
|
||||||
|
// c -> 104.49216199393888`,
|
||||||
|
// x -> (kelvin/100) - 2}
|
||||||
|
green = temperature - 2;
|
||||||
|
green = -155.25485562709179 - 0.44596950469579133 * green + 104.49216199393888 * Math.log(green);
|
||||||
|
if (green < 0) green = 0;
|
||||||
|
if (isNaN(green)) green = 0;
|
||||||
|
if (green > 255) green = 255;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// a + b x + c Log[x] /.
|
||||||
|
// {a -> 325.4494125711974`,
|
||||||
|
// b -> 0.07943456536662342`,
|
||||||
|
// c -> -28.0852963507957`,
|
||||||
|
// x -> (kelvin/100) - 50}
|
||||||
|
green = temperature - 50.0;
|
||||||
|
green = 325.4494125711974 + 0.07943456536662342 * green - 28.0852963507957 * Math.log(green);
|
||||||
|
if (green < 0) green = 0;
|
||||||
|
if (green > 255) green = 255;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Calculate blue */
|
||||||
|
|
||||||
|
if (temperature >= 66.0) {
|
||||||
|
blue = 255;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (temperature <= 20.0) {
|
||||||
|
blue = 0;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// a + b x + c Log[x] /.
|
||||||
|
// {a -> -254.76935184120902`,
|
||||||
|
// b -> 0.8274096064007395`,
|
||||||
|
// c -> 115.67994401066147`,
|
||||||
|
// x -> kelvin/100 - 10}
|
||||||
|
blue = temperature - 10;
|
||||||
|
blue = -254.76935184120902 + 0.8274096064007395 * blue + 115.67994401066147 * Math.log(blue);
|
||||||
|
if (blue < 0) blue = 0;
|
||||||
|
if (blue > 255) blue = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//return {red: Math.round(red), blue: Math.round(blue), green: Math.round(green)};
|
||||||
|
return "rgb("+Math.round(red)+","+Math.round(green)+","+Math.round(blue)+")"
|
||||||
|
}
|
||||||
|
|
||||||
|
//[reverse conversion omitted]
|
||||||
|
|
||||||
|
elements.color_temp_test = {
|
||||||
|
color: "#111111",
|
||||||
|
tick: function(pixel) {
|
||||||
|
if(!pixel.oldColor) {
|
||||||
|
pixel.oldColor = pixel.color
|
||||||
|
}
|
||||||
|
if(!pixel.lerpValue) {
|
||||||
|
pixel.lerpValue = 0
|
||||||
|
}
|
||||||
|
if(!pixel.lerpAR) {
|
||||||
|
pixel.lerpAR = 0
|
||||||
|
}
|
||||||
|
if(!pixel.lerpAG) {
|
||||||
|
pixel.lerpAG = 0
|
||||||
|
}
|
||||||
|
if(!pixel.lerpAB) {
|
||||||
|
pixel.lerpAB = 0
|
||||||
|
}
|
||||||
|
if(!pixel.lerpBR) {
|
||||||
|
pixel.lerpBR = 0
|
||||||
|
}
|
||||||
|
if(!pixel.lerpBG) {
|
||||||
|
pixel.lerpBG = 0
|
||||||
|
}
|
||||||
|
if(!pixel.lerpBB) {
|
||||||
|
pixel.lerpBB = 0
|
||||||
|
}
|
||||||
|
if(!pixel.lerpedR) {
|
||||||
|
pixel.lerpedR = 0
|
||||||
|
}
|
||||||
|
if(!pixel.lerpedG) {
|
||||||
|
pixel.lerpedG = 0
|
||||||
|
}
|
||||||
|
if(!pixel.lerpedB) {
|
||||||
|
pixel.lerpedB = 0
|
||||||
|
}
|
||||||
|
if(!pixel.lerpedColor) {
|
||||||
|
pixel.lerpedColor = ""
|
||||||
|
}
|
||||||
|
if(pixel.temp < 525) {
|
||||||
|
pixel.color = pixel.oldColor
|
||||||
|
}
|
||||||
|
if(pixel.temp >= 525 && pixel.temp < 1582) {
|
||||||
|
pixel.lerpValue = (pixel.temp-524)/(1581-524)
|
||||||
|
pixel.lerpAR = pixel.oldColor.split(",")[0].slice(4)
|
||||||
|
pixel.lerpAG = pixel.oldColor.split(",")[1]
|
||||||
|
pixel.lerpAB = pixel.oldColor.split(",")[2].slice(0,-1)
|
||||||
|
pixel.lerpBR = colorTemperature2rgb(pixel.temp + 273.15).split(",")[0].slice(4)
|
||||||
|
pixel.lerpBG = colorTemperature2rgb(pixel.temp + 273.15).split(",")[1]
|
||||||
|
pixel.lerpBB = colorTemperature2rgb(pixel.temp + 273.15).split(",")[2].slice(0,-1)
|
||||||
|
pixel.lerpedR = pixel.lerpBR*pixel.lerpValue + pixel.lerpAR*(1-pixel.lerpValue)
|
||||||
|
pixel.lerpedG = pixel.lerpBG*pixel.lerpValue + pixel.lerpAG*(1-pixel.lerpValue)
|
||||||
|
pixel.lerpedB = pixel.lerpBB*pixel.lerpValue + pixel.lerpAB*(1-pixel.lerpValue)
|
||||||
|
pixel.lerpedColor = "rgb(" + pixel.lerpedR + "," + pixel.lerpedG + "," + pixel.lerpedB + ")"
|
||||||
|
pixel.color = pixel.lerpedColor
|
||||||
|
}
|
||||||
|
if(pixel.temp >= 1582) {
|
||||||
|
pixel.color = colorTemperature2rgb(pixel.temp + 273.15)
|
||||||
|
}
|
||||||
|
doHeat(pixel);
|
||||||
|
},
|
||||||
|
category: "special",
|
||||||
|
temp: -273,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
elements.rainbow_alt_test = {
|
||||||
|
color: ["#ffaacc","#ffaacc","#aaccff","#aaccff","#ffffbb","#ffffbb"],
|
||||||
|
tick: function(pixel) {
|
||||||
|
var t = pixelTicks*3+pixel.x+pixel.y;
|
||||||
|
var r = Math.floor(255*(1-Math.cos(t*Math.PI/180)));
|
||||||
|
var g = Math.floor(255*(1-Math.cos(t*Math.PI/180+2*Math.PI/3)));
|
||||||
|
var b = Math.floor(255*(1-Math.cos(t*Math.PI/180+4*Math.PI/3)));
|
||||||
|
pixel.color = "rgb("+Math.ceil((r/2)+127)+","+Math.ceil((g/2)+127)+","+Math.ceil((b/2)+127)+")";
|
||||||
|
doHeat(pixel);
|
||||||
|
},
|
||||||
|
category: "special",
|
||||||
|
}
|
||||||
|
|
||||||
runAfterLoad(function() {
|
runAfterLoad(function() {
|
||||||
if(enabledMods.includes("mods/fey_and_more.js")) {
|
if(enabledMods.includes("mods/fey_and_more.js")) {
|
||||||
aaa.push("poisonwater")
|
aaa.push("poisonwater")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue