sandboxels/mods/glow.js

102 lines
3.0 KiB
JavaScript
Raw Normal View History

2025-01-08 14:41:56 -05:00
/* TODO:
- warning and automatic disable for non-chromium users
- firefly glow
- sun temperature-dependent glow strength
*/
var isChromium = !!window.chrome;
if (!isChromium) {
window.addEventListener("load",function(){
console.log(1)
logMessage("Error: glow.js only works on Chrome or Chromium-based browsers.")
})
}
else {
2025-01-08 13:00:52 -05:00
addCanvasLayer("glowmod");
addCanvasLayer("glowmod2");
canvasLayersPre.unshift(canvasLayers["glowmod"]);
glowmodCtx = canvasLayers["glowmod"].getContext("2d");
glowmodCtx2 = canvasLayers["glowmod2"].getContext("2d");
delete canvasLayers.glowmod;
delete canvasLayers.glowmod2;
elements.fire.emit = true;
elements.lightning.emit = 15;
elements.electric.emit = true;
elements.plasma.emit = true;
elements.uranium.emit = 3;
elements.uranium.emitColor = "#009800";
elements.rainbow.emit = true;
elements.static.emit = true;
elements.flash.emit = true;
elements.cold_fire.emit = true;
elements.blaster.emit = true;
elements.ember.emit = true;
elements.fw_ember.emit = 10;
elements.bless.emit = true;
elements.pop.emit = true;
elements.explosion.emit = true;
elements.n_explosion.emit = 10;
elements.supernova.emit = 20;
elements.midas_touch.emit = true;
elements.fireball.emit = true;
elements.sun.emit = 15;
elements.light.emit = 3;
elements.liquid_light.emit = true;
elements.laser.emit = 3;
elements.neutron.emit = 3;
elements.proton.emit = 3;
elements.radiation.emit = 3;
elements.fallout.emit = 3;
elements.rad_steam.emit = 2;
elements.rad_steam.emitColor = "#6ad48c";
elements.rad_cloud.emit = 2;
elements.rad_cloud.emitColor = "#009800";
elements.rad_glass.emit = 2;
elements.rad_glass.emitColor = "#009800";
elements.rad_shard.emit = 2;
elements.rad_shard.emitColor = "#009800";
elements.malware.emit = 2;
elements.border.emit = 2;
Version 1.11 - February 21, 2025 - Everyone's Update [Version 1.11 - February 21, 2025 - Everyone's Update] + Portals! + Portal In and Portal Out elements + Portals teleport pixels and electricity + Coral + Grows in Water + Bleaches in high temperatures + Adobe, made from Mud and Straw + Element translations for Turkish and Hungarian [Electricity Rework] ~ Electricity is now more consistent in highly conductive material ~ Sensors give out a single charge instead of 4 ~ Pixels now store when they were charged ~ Note: Effects on existing builds should be limited but please report any issues [Changes] + Liquid pixels of the same element move around + Tiny canvas size + Molten elements oscillate color (Experimental) ~ Pixels can now exist along the border of the canvas ~ Disabling Staining will clear all existing pixel stains + Dye, Paint, etc. retain their selected color independently + Radioactive Tornado variant + Humans panic when shocked ~ Humans are less heat-resistant ~ Pipes are no longer unbreakable + Smoke rises in normal air density ~ Tweaked Fire and Cold Fire behavior + Sabatier process for producing Methane + Bergius process for producing Oil + Acid reacts with Potassium ~ Increased Methane autoignition point + Uranium radiates Glass on contact + Burning Lamp Oil explodes in Water + Liquid Ozone explodes when broken or shocked + Molten Gallium can react with Gold Coins + Slaked Lime reacts with Carbon Dioxide + Molten Plastic evaporates + Glue turns Color Sand into Stained Glass + Butter and Caustic Potash make Soap + Neutrons radiate Glass, Clouds, and Water ~ Light absorbed by LEDs is deleted ~ Foam made from Oxygen + Water releases the Oxygen ~ Tweaked Bleach and Acid reaction ~ Increased Molten Sulfur freezing point ~ Tweaked Smash tool + Cyanide dirties Water variants + Infection dirties Water + Tea and Coffee bubble when hot + CO2 carbonates Salt Water instead of dirtying + Soda and Seltzer release Foam when mixed + Pilk creates Foam + Cells can ferment Milk variants ~ Cells ferment Milk slower ~ Cheese keeps color when breaking into powder (Pilk Powder?) ~ Caramel is more heat-resistant ~ Acid turns Humans into Bone ~ Birds are less flammable + Fish turn to white meat when cooked + Worms can compost Petal, Pistil, and Vine + Rats can eat Hard Yolk + Alcohol calms Humans + Humans panic from bad smells + Smog breaks into Dirty Water ~ Fireworks create less Carbon Dioxide + Bless can fix Brick Rubble + Midas Touch converts some metals to Gold variants + Malware can affect Snake ~ Pointer retains same speed at any TPS ~ Optimized Cell and Cancer ~ Recolored Pipe Wall ~ Improved Slug, Brick, and Ruins buttons ~ Hid Liquid Oxygen ~ Unhid Liquid Hydrogen ~ Moved Liquid Hydrogen to Liquids ~ Moved Poison Gas to Gases + Liquid Nitrogen alias 'LN2' + Electric alias 'Electron' + Light alias 'Photon' + Nut Oil alias 'Cooking Oil' + Epsom Salt alias 'Magnesium Sulfate' + Pyrite alias 'Iron Sulfide' + Limestone alias 'Calcium Carbonate' + Quicklime alias 'Calcium Oxide' + Slaked Lime alias 'Calcium Hydroxide' ~ Petal displays with dark text ~ Slightly moved Porcelain + Built-in dialog boxes ~ Canvas touches the top of the page ~ Wide canvas size takes up more screen space ~ White border no longer shown on wide canvas size ~ Buttons, menus, and the canvas have thicker borders ~ "Elem" in stats bar is no longer uppercase ~ Unknown has no grain - Loading a save no longer changes your selected element + Ctrl+S to bring up save prompt + Ctrl+Shift+S to instantly save canvas + Retroactive changelogs for versions v0.1-v0.4 + Bluesky social link + Partial translations for Ukrainian, Toki Pona, and Halacae + Finished translations for Spanish and Russian [Bug Fixes] ~ Fixed: Oxygen from hydrolysis immediately turns to Foam ~ Fixed: Menu heights vary dramatically with long categories ~ Fixed: Mod Manager and Info Screen text boxes don't stick to bottom ~ Fixed: Lattice Wars appear without borders ~ Fixed: Smash tool breaks harder elements faster ~ Fixed: Error in console on page load ~ Fixed: Artifacts above stats bar text on Chrome ~ Fixed: Console logging when Hail breaks a pixel ~ Fixed: Milk variants still heat into Yogurt ~ Fixed: Controls still show Smooth View keybind ~ Fixed: "Save to File" button cut off on some small screens ~ Fixed: Many aliases can't be used in Element Select ~ Fixed: Prop tool doesn't change pixel state when changing temperature ~ Fixed: Grenades stop moving while charged ~ Fixed: Lightning doesn't reach bottom on large canvases ~ Fixed: Ghost pixels when placing Foam with low air temperature set ~ Fixed: 'CR' behavior cell errors with low air temperature set [Technical] + Portal 'channel' property can be set with the Prop tool (Integer) + runAfterReset function + isBreakable function + 'breakIntoColorMultiplier' element property + 'onMoveInto' element property, called when another pixel moves into it (function(pixel1,pixel2)) + 'chargeStart' pixel property ~ 'breakIntoColor' element property can be used without 'breakInto' + 'sense' sensor property to detect a certain element ~ Optimized electricity ~ Fire is affected by air density + View setting dropdown includes views added by mods ~ currentSaveData is now always defined, and holds metadata about the current canvas, even non-saves + currentSaveData always contains a UUID for seeded randomness ~ Default max pixel count slightly increased ~ Save version is now sb3 ~ Canvas border width is now stored (Default 1 for old saves) ~ Pixel properties with value "undefined" are skipped + Error message in console for broken translation files + GUI translation support + More GUI elements have IDs + Future standalone mode
2025-02-21 13:47:50 -05:00
elements.void.emit = 10;
2025-01-08 13:00:52 -05:00
viewInfo[1] = { // Blur Glow (Emissive pixels only)
name: "",
pixel: viewInfo[1].pixel,
effects: true,
colorEffects: true,
pre: function(ctx) {
glowmodCtx2.canvas.width = ctx.canvas.width;
glowmodCtx2.canvas.height = ctx.canvas.height;
},
pixel: viewInfo[1].pixel,
post: function(ctx) {
glowmodCtx.canvas.width = ctx.canvas.width;
glowmodCtx.canvas.height = ctx.canvas.height;
glowmodCtx.filter = "blur(30px)";
// Draw the blurred content on the canvas
glowmodCtx.drawImage(glowmodCtx2.canvas, 0, 0);
glowmodCtx.filter = "none";
},
};
renderEachPixel(function(pixel,ctx) {
if (view === 1) {
if (elements[pixel.element].emit || pixel.emit || (elements[pixel.element].colorOn && pixel.charge)) {
let a = (settings.textures !== 0) ? pixel.alpha : undefined;
let d = elements[pixel.element].emit||true;
if (d === true) d = 5;
let r = Math.floor(d/2);
drawSquare(glowmodCtx2,elements[pixel.element].emitColor||pixel.color,pixel.x-r,pixel.y-r,d,a);
}
if (pixel.charge && !elements[pixel.element].colorOn) {
drawSquare(glowmodCtx2,"#ffff00",pixel.x-1,pixel.y-1,3);
}
}
2025-01-08 14:41:56 -05:00
})
}