2022-10-05 13:52:37 -04:00
function marasi ( number ) {
return Math . min ( 255 , Math . round ( Math . abs ( Math . sin ( number ) * 255 ) ) ) ;
} ;
function _rgbHexCatcher ( color ) { //Hex triplet to rgb(), while rgb() is untouched
//console.log("Logged color for _rgbHexCatcher: " + color);
//I have no idea if this runs before or after parsing hex triplets to rgb() values, so I'm going to handle both (by making everything rgb() and then making it hex at the end)
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.");
color = "#FF00FF" ;
} ;
if ( color . length < 10 ) {
//console.log("Short string detected, likely a hex triplet");
if ( ! color . startsWith ( "#" ) ) {
color = "#" + color ;
} ;
var object = hexToRGB ( color ) ;
return ` rgb( ${ object . r } , ${ object . g } , ${ object . b } ) `
} else {
//console.log("Non-triplet detected");
return color ;
} ;
} ; //color function
mooreDonutCoords = [ [ - 1 , - 1 ] , [ 0 , - 1 ] , [ 1 , - 1 ] , [ - 1 , 0 ] , [ 1 , 0 ] , [ - 1 , 1 ] , [ 0 , 1 ] , [ 1 , 1 ] ] ; //Moore neighborhood (includes corners) minus center, as opposed to the von Neumann neighborhood which is the + shape.
elements . lookup . tick = function ( pixel ) {
//console.log(`### Tick ${pixelTicks} ###`);
//console.log(`Storing coordinates`);
var pX = pixel . x ;
var pY = pixel . y ;
//console.log(`Position (${pX},${pY})`);
//console.log(`Iterating`);
var neighborArray = [ ] ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
//console.log(`i: ${i}`);
//console.log(`Initialized array`);
var coord = mooreDonutCoords [ i ] ;
//console.log(`Offset pair: ${coord}`);
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
//console.log(`Stored offset pair`);
var nX = pX + oX ;
var nY = pY + oY ;
//console.log(`Final coordinates: (${nX},${nY}) (index ${i})`);
if ( isEmpty ( nX , nY , true ) ) {
//console.log(`Skipping empty pixel (${nX},${nY})`);
continue ;
} else {
//console.log(`Found pixel at (${nX},${nY})`);
var newPixel = pixelMap [ nX ] [ nY ] ;
//console.log(`Pixel stored`);
var newElement = newPixel . element ;
//console.log(`Element is ${newElement}, running exclusion check;`);
if ( newElement !== pixel . element ) { //exclude self
//console.log(`Element is different, storing in array;`);
neighborArray . push ( newElement ) ; //build array of valid neighbors
} ;
//console.log("Finding iteration done");
2022-10-04 17:04:33 -04:00
} ;
2022-10-05 13:52:37 -04:00
//console.log("End of for block (not loop)");
} ;
//console.log(`Loop done: ${neighborArray}`);
if ( neighborArray . length > 0 ) {
var changeToElement = neighborArray [ Math . floor ( Math . random ( ) * neighborArray . length ) ] ;
changePixel ( pixel , changeToElement ) ;
} ;
} ;
elements . paint . tick = function ( pixel ) {
pixel . color = _rgbHexCatcher ( currentColor ) ;
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
2022-10-04 20:00:47 -04:00
} else {
2022-10-05 13:52:37 -04:00
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
if ( newElement !== pixel . element ) { //exclude self
newPixel . color = pixel . color ; //change color of other pixel
} ;
2022-10-04 20:00:47 -04:00
} ;
} ;
2022-10-05 13:52:37 -04:00
} ;
2022-10-04 20:00:47 -04:00
2022-10-05 13:52:37 -04:00
elements . unpaint . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
if ( newElement !== pixel . element ) { //slow for self, see below
newPixel . color = pixelColorPick ( newPixel ) ; //change color of other pixel
} else {
if ( pixelTicks % 10 === 0 ) { //every 10 ticks because unpaint shouldn't be paintable, but it shouldn't be a seizure machine either
newPixel . color = pixelColorPick ( newPixel ) ;
} ;
} ;
2022-10-04 20:00:47 -04:00
} ;
2022-10-05 13:52:37 -04:00
} ;
} ;
if ( typeof ( elements . sandreplacer ) !== "undefined" ) {
elements . sandreplacer . behavior = [
"CH:sand|CH:sand|CH:sand" ,
"CH:sand|CH:sand|CH:sand" ,
"CH:sand|CH:sand|CH:sand"
] ;
} ;
if ( typeof ( elements . delete _all _of _element ) !== "undefined" ) {
elements . delete _all _of _element . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
//console.log(`stored adjacent element ${newElement} at (${nX},${nY})`);
if ( newElement !== pixel . element ) { //exclude self
var coordCircle = circleCoords ( pX , pY , 7 ) ;
//console.log(`got coordinate circle centered at (${pX},${pY}) with ${coordCircle.length} ${coordCircle.length === 1 ? "pixel" : "pixels"}`);
for ( j = 0 ; j < coordCircle . length ; j ++ ) {
//console.log(`itting through circle, index ${j}`);
var coordCircleCoord = coordCircle [ j ] ;
var cNX = coordCircleCoord . x ;
var cNY = coordCircleCoord . y ;
//console.log(`circle coords stored (${cNX},${cNY})`);
if ( isEmpty ( cNX , cNY , true ) ) {
continue ;
//console.log("skipped empty pixel");
} else {
var circleNewPixel = pixelMap [ cNX ] [ cNY ] ;
var circleNewElement = circleNewPixel . element ;
//console.log(`found pixel of element ${circleNewElement}`);
if ( circleNewElement === newElement && circleNewElement !== pixel . element ) { //exclude self, match the stored element from before
deletePixel ( cNX , cNY ) ;
} ;
} ;
} ;
2022-10-04 20:00:47 -04:00
} ;
} ;
} ;
2022-10-05 13:52:37 -04:00
} ;
} ;
elements . room _temp . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
newPixel . temp = 20 ; //to room temp
pixelTempCheck ( pixel ) ;
} ;
} ;
} ;
elements . uncharge . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
if ( newPixel . charge ) { //remove charge properties
delete pixel . charge ;
} ;
if ( newPixel . chargeCD ) {
delete pixel . chargeCD ;
} ;
} ;
} ;
} ;
elements . unburn . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
if ( newElement === "fire" ) { //fire to smoke
changePixel ( newPixel , "smoke" ) ;
} ;
if ( newPixel . burning ) { //remove burning properties
delete pixel . burning ;
2022-10-04 20:00:47 -04:00
} ;
2022-10-05 13:52:37 -04:00
if ( newPixel . burnStart ) {
delete pixel . burnStart ;
2022-10-04 20:00:47 -04:00
} ;
} ;
} ;
2022-10-05 13:52:37 -04:00
} ;
2022-10-04 20:00:47 -04:00
2022-10-05 13:52:37 -04:00
elements . smash . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
if ( elements [ newElement ] . breakInto ) {
var breakInto = elements [ pixel . element ] . breakInto ; //edited vanilla code
// if breakInto is an array, pick one
if ( Array . isArray ( breakInto ) ) {
breakInto = breakInto [ Math . floor ( Math . random ( ) * breakInto . length ) ] ;
}
changePixel ( pixel , breakInto ) ;
} ;
2022-10-04 20:00:47 -04:00
} ;
} ;
2022-10-05 13:52:37 -04:00
} ;
2022-10-04 20:00:47 -04:00
2022-10-05 13:52:37 -04:00
elements . cook . behavior = [
"HT:0.5|HT:0.5|HT:0.5" ,
"HT:0.5|HT:0.5|HT:0.5" ,
"HT:0.5|HT:0.5|HT:0.5" ,
] ;
2022-10-04 20:00:47 -04:00
2022-11-13 12:58:47 -05:00
if ( typeof ( elements . ultraheat ) !== "undefined" ) {
elements . ultraheat . behavior = [
"HT:350|HT:350|HT:350" ,
"HT:350|HT:350|HT:350" ,
"HT:350|HT:350|HT:350" ,
] ;
} ;
2022-10-05 13:52:37 -04:00
2022-11-13 12:58:47 -05:00
if ( typeof ( elements . ultracool ) !== "undefined" ) {
elements . ultracool . behavior = [
"CO:350|CO:350|CO:350" ,
"CO:350|CO:350|CO:350" ,
"CO:350|CO:350|CO:350" ,
] ;
} ;
2022-10-05 13:52:37 -04:00
elements . incinerate . behavior = [
"HT:10000|HT:10000|HT:10000" ,
"HT:10000|HT:10000|HT:10000" ,
"HT:10000|HT:10000|HT:10000" ,
] ;
if ( typeof ( elements . na _ntemp ) !== "undefined" ) {
elements . na _ntemp . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
newPixel . temp = NaN ;
} ;
} ;
} ;
} ;
if ( typeof ( elements . inftemp ) !== "undefined" ) {
elements . inftemp . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
newPixel . temp = Infinity ;
} ;
2022-10-04 20:00:47 -04:00
} ;
2022-10-05 13:52:37 -04:00
} ;
} ;
if ( typeof ( elements . superheat ) !== "undefined" ) {
elements . superheat . behavior = [
"HT:10|HT:10|HT:10" ,
"HT:10|HT:10|HT:10" ,
"HT:10|HT:10|HT:10" ,
] ;
} ;
if ( typeof ( elements . supercool ) !== "undefined" ) {
elements . supercool . behavior = [
"CO:10|CO:10|CO:10" ,
"CO:10|CO:10|CO:10" ,
"CO:10|CO:10|CO:10" ,
] ;
} ;
if ( typeof ( elements . hyperheat ) !== "undefined" ) {
elements . hyperheat . behavior = [
"HT:50|HT:50|HT:50" ,
"HT:50|HT:50|HT:50" ,
"HT:50|HT:50|HT:50" ,
] ;
} ;
if ( typeof ( elements . hypercool ) !== "undefined" ) {
elements . hypercool . behavior = [
"CO:50|CO:50|CO:50" ,
"CO:50|CO:50|CO:50" ,
"CO:50|CO:50|CO:50" ,
] ;
} ;
if ( typeof ( elements . absolutezero ) !== "undefined" ) {
elements . absolutezero . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
newPixel . temp = - 273.15 ;
} ;
2022-10-04 20:00:47 -04:00
} ;
2022-10-05 13:52:37 -04:00
} ;
} ;
if ( typeof ( elements . antigrav ) !== "undefined" ) {
elements . antigrav . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
newPixel . r = 2 ;
} ;
2022-10-04 20:00:47 -04:00
} ;
2022-10-05 13:52:37 -04:00
} ;
} ;
if ( typeof ( elements . normalgrav ) !== "undefined" ) {
elements . normalgrav . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
newPixel . r = 0 ;
} ;
2022-10-04 20:00:47 -04:00
} ;
2022-10-05 13:52:37 -04:00
} ;
} ;
if ( typeof ( elements . leftgrav ) !== "undefined" ) {
elements . leftgrav . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
newPixel . r = 3 ;
} ;
2022-10-04 20:00:47 -04:00
} ;
2022-10-05 13:52:37 -04:00
} ;
} ;
if ( typeof ( elements . rightgrav ) !== "undefined" ) {
elements . rightgrav . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
newPixel . r = 1 ;
} ;
2022-10-04 20:00:47 -04:00
} ;
} ;
} ;
2022-10-05 13:52:37 -04:00
if ( typeof ( elements . burn ) !== "undefined" ) {
elements . burn . burnTime = Infinity ;
elements . burn . burn = 100 ;
elements . burn . burnInto = "burn" ;
elements . burn . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
if ( newElement === "smoke" ) { //smoke to fire
changePixel ( newPixel , "smoke" ) ;
} ;
newPixel . burning = true ;
} ;
2022-10-04 20:00:47 -04:00
} ;
2022-10-05 13:52:37 -04:00
} ;
} ;
if ( typeof ( elements . cursed _shock ) !== "undefined" ) {
elements . cursed _shock . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
newPixel . charge = 2 ;
if ( newPixel . chargeCD ) {
delete newPixel . chargeCD ;
} ;
} ;
2022-10-04 20:00:47 -04:00
} ;
} ;
2022-10-05 13:52:37 -04:00
} ;
if ( typeof ( elements . offset _fourth _y ) !== "undefined" ) {
elements . offset _fourth _y . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
if ( newElement !== pixel . element ) { //self-exclude
tryMove ( newPixel , nX , nY + 0.25 )
} ;
} ;
} ;
} ;
} ;
if ( typeof ( elements . offset _half _y ) !== "undefined" ) {
elements . offset _half _y . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
if ( newElement !== pixel . element ) { //self-exclude
tryMove ( newPixel , nX , nY + 0.5 )
} ;
} ;
2022-10-04 20:00:47 -04:00
} ;
} ;
2022-10-05 13:52:37 -04:00
} ;
2022-10-04 20:00:47 -04:00
2022-10-05 13:52:37 -04:00
if ( typeof ( elements . offset _three _fourth _y ) !== "undefined" ) {
elements . offset _three _fourth _y . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
if ( newElement !== pixel . element ) { //self-exclude
tryMove ( newPixel , nX , nY + 0.75 )
} ;
} ;
} ;
} ;
} ;
2022-10-11 11:47:30 -04:00
if ( typeof ( elements . find _toggle ) !== "undefined" ) {
2022-10-05 13:52:37 -04:00
if ( typeof ( elements . find _toggle ) !== "find" ) {
elements . find _toggle . behavior = behaviors . WALL ;
elements . find _toggle . tick = function ( pixel ) {
pixel . color = "rgb(255," + marasi ( pixelTicks / 10 ) + ",0)" ;
} ;
} ;
} ;
if ( typeof ( elements . replace ) !== "undefined" ) {
elements . replace . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
if ( newElement === replaceFrom ) {
changePixel ( newPixel , replaceTo ) ;
} ;
} ;
} ;
} ;
} ;
if ( typeof ( elements . alt _replace ) !== "undefined" ) {
elements . alt _replace . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
if ( newElement === replaceFrom ) {
newPixel . element = replaceTo ;
} ;
} ;
} ;
} ;
} ;
if ( typeof ( elements . alt _alt _replace ) !== "undefined" ) {
elements . alt _alt _replace . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
if ( newElement === replaceFrom ) {
newPixel . element = replaceTo ;
newPixel . color = pixelColorPick ( newPixel ) ;
} ;
} ;
} ;
} ;
} ;
if ( typeof ( elements . change ) !== "undefined" ) {
elements . change . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
if ( newElement !== pixel . element ) {
changePixel ( newPixel , changeTo ) ;
} ;
} ;
} ;
} ;
} ;
if ( typeof ( elements . alt _change ) !== "undefined" ) {
elements . alt _change . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
if ( newElement !== pixel . element ) {
newPixel . element = changeTo ;
} ;
} ;
} ;
} ;
} ;
if ( typeof ( elements . alt _alt _change ) !== "undefined" ) {
elements . alt _alt _change . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
if ( newElement !== pixel . element ) {
newPixel . element = changeTo ;
newPixel . color = pixelColorPick ( newPixel ) ;
} ;
} ;
} ;
} ;
} ;
if ( typeof ( elements . prop ) !== "undefined" ) {
elements . prop . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
var newElement = newPixel . element ;
if ( propProperty === "element" ) {
if ( newElement !== pixel . element ) { //self exclude if element is the change
newPixel [ propProperty ] = propValue ;
newPixel . temp = ( elements [ propValue ] . temp || newPixel . temp ) ;
} ;
} else {
newPixel [ propProperty ] = propValue ;
2022-10-04 20:00:47 -04:00
} ;
} ;
} ;
2022-10-05 13:52:37 -04:00
} ;
2022-10-04 20:00:47 -04:00
} ;
2022-10-05 13:52:37 -04:00
if ( typeof ( elements . number _adjuster ) !== "undefined" ) {
elements . number _adjuster . tick = function ( pixel ) {
var pX = pixel . x ;
var pY = pixel . y ;
for ( i = 0 ; i < mooreDonutCoords . length ; i ++ ) {
var coord = mooreDonutCoords [ i ] ;
var oX = coord [ 0 ] ;
var oY = coord [ 1 ] ;
var nX = pX + oX ;
var nY = pY + oY ;
if ( isEmpty ( nX , nY , true ) ) {
continue ;
} else {
var newPixel = pixelMap [ nX ] [ nY ] ;
if ( numberAdjusterProperty !== "element" ) {
//console.log(numberAdjusterValue);
if ( numberAdjusterMode === "set" ) {
newPixel [ numberAdjusterProperty ] = numberAdjusterValue ;
} else if ( numberAdjusterMode === "add" ) {
if ( typeof ( newPixel [ numberAdjusterProperty ] ) === "undefined" ) {
newPixel [ numberAdjusterProperty ] = 0 ;
} ;
newPixel [ numberAdjusterProperty ] += numberAdjusterValue ;
} ;
pixelTempCheck ( newPixel ) ;
} ;
} ;
} ;
} ;
2022-10-04 20:00:47 -04:00
} ;
2022-10-05 13:52:37 -04:00
/ * e l e m e n t s . p o i n t e r . b e h a v i o r = [
"XX|XX|XX" , "XX|CH:cursed_shock|XX" , "XX|XX|XX"
] ; * /