diff --git a/mods/stripe_paint.js b/mods/stripe_paint.js index 12b27dfd..977e9544 100644 --- a/mods/stripe_paint.js +++ b/mods/stripe_paint.js @@ -1,109 +1,110 @@ -function averageColors(color1,color2,outputType="rgb",weight1=0.5) { - color1 = convertColorFormats(color1,"json"); - color2 = convertColorFormats(color2,"json"); - theColor = averageColorObjects(color1,color2,weight1); - return convertColorFormats(theColor,outputType); -}; +var modName = "mods/color_tools.js"; +var libraryMod = "mods/code_library.js"; -stripeFixedDefaultProperties = { - color2: "rgb(0,0,0)", - phase: 0, - scale: 1, - angle: 0 -}; - -stripeSpreadingProperties = { - color1: "It doesn't matter what I put here; I'm just sick of writing for loops.", - color2: "stan loona", -}; - -/*stripeSpreadingProperties2 = { - phase: 0, - scale: 1, :eggTF: - angle: 0 -};*/ - -function stripeFunction(pixel) { - if(pixel.color1 == undefined || pixel.color1 == null) { - pixel.color1 = pixel.color; - }; - for(prop in stripeFixedDefaultProperties) { - if(pixel[prop] == undefined || pixel[prop] == null) { - pixel[prop] = stripeFixedDefaultProperties[prop]; - }; +if(enabledMods.includes(libraryMod)) { + stripeFixedDefaultProperties = { + color2: "rgb(0,0,0)", + phase: 0, + scale: 1, + angle: 0 }; - //color1 and color2 self staining - for (var i = 0; i < adjacentCoords.length; i++) { - var x = pixel.x+adjacentCoords[i][0]; - var y = pixel.y+adjacentCoords[i][1]; - if(isEmpty(x,y,true)) { - continue; + stripeSpreadingProperties = { + color1: "It doesn't matter what I put here; I'm just sick of writing for loops.", + color2: "stan loona", + }; + + /*stripeSpreadingProperties2 = { + phase: 0, + scale: 1, :eggTF: + angle: 0 + };*/ + + function stripeFunction(pixel) { + if(pixel.color1 == undefined || pixel.color1 == null) { + pixel.color1 = pixel.color; }; - var otherPixel = pixelMap[x][y]; - for(prop in stripeSpreadingProperties) { - if(otherPixel.element == pixel.element && pixel[prop] && otherPixel[prop]) { - otherPixel[prop] = averageColors(pixel[prop],otherPixel[prop]); + for(prop in stripeFixedDefaultProperties) { + if(pixel[prop] == undefined || pixel[prop] == null) { + pixel[prop] = stripeFixedDefaultProperties[prop]; }; }; - /*for(prop in stripeSpreadingProperties2) { - if(otherPixel.element == pixel.element && pixel[prop] !== undefined && otherPixel[prop] !== undefined) { - otherPixel[prop] = pixel[prop]/2 + otherPixel[prop]/2; - }; :eggTF: - };*/ + + //color1 and color2 self staining + for (var i = 0; i < adjacentCoords.length; i++) { + var x = pixel.x+adjacentCoords[i][0]; + var y = pixel.y+adjacentCoords[i][1]; + if(isEmpty(x,y,true)) { + continue; + }; + var otherPixel = pixelMap[x][y]; + for(prop in stripeSpreadingProperties) { + if(otherPixel.element == pixel.element && pixel[prop] && otherPixel[prop]) { + otherPixel[prop] = lerpColors(pixel[prop],otherPixel[prop]); + }; + }; + /*for(prop in stripeSpreadingProperties2) { + if(otherPixel.element == pixel.element && pixel[prop] !== undefined && otherPixel[prop] !== undefined) { + otherPixel[prop] = pixel[prop]/2 + otherPixel[prop]/2; + }; :eggTF: + };*/ + }; + + var radians = pixel.angle * (Math.PI / 180); + + var colorNumber = (pixel.x*Math.cos(radians))+(pixel.y*Math.sin(radians)); + + var sineWeight = (1+Math.sin(pixel.phase + colorNumber / pixel.scale))/2; + + var preColor = lerpColors(pixel.color1,pixel.color2,"json",sineWeight); + for(colorlet in preColor) { + preColor[colorlet] = Math.round(preColor[colorlet]); + }; + pixel.color = convertColorFormats(preColor,"rgb"); }; - - var radians = pixel.angle * (Math.PI / 180); - var colorNumber = (pixel.x*Math.cos(radians))+(pixel.y*Math.sin(radians)); + stripePaintDesc = `Exactly what it says on the button. +
+ Properties:
    +
  1. color1: The first color of the stripe
  2. +
  3. color2: The second color of the stripe (defaults to black)
  4. +
  5. scale: Relative width of the stripes, compared to the default
  6. +
  7. phase: Offset in the position of the stripes (π/2 = 1 stripe width)
  8. +
  9. angle: Angle in degrees
- var sineWeight = (1+Math.sin(pixel.phase + colorNumber / pixel.scale))/2; + color1 and color2 spread through striped paint like dye does with itself. color1 can be set on initial placement through the color picker, but otherwise, properties must be changed through the console or with prop.js's tools. - var preColor = averageColors(pixel.color1,pixel.color2,"json",sineWeight); - for(colorlet in preColor) { - preColor[colorlet] = Math.round(preColor[colorlet]); + This does not work with HSL color and the game will black screen if one is somehow used. The color conversion functions are a clusterf***.` + + elements.stripe_paint = { + behavior: behaviors.LIQUID, + state: "liquid", + density: 998, + tempHigh: 100, + stateHigh: "smoke", + color: elements.paint.color, + customColor: true, + category: "special", + properties: { + color1: null, + color2: null, + scale: 1, + phase: 0, + angle: 0 + }, + stain: elements.dye.stain, + tick: function(pixel) { + stripeFunction(pixel); + }, + desc: stripePaintDesc }; - pixel.color = convertColorFormats(preColor,"rgb"); +} else { + alert(`The ${libraryMod} mod is required and has been automatically inserted (reload for this to take effect).`) + enabledMods.splice(enabledMods.indexOf(modName),0,libraryMod) + localStorage.setItem("enabledMods", JSON.stringify(enabledMods)); }; - -stripePaintDesc = `Exactly what it says on the button. -
-Properties:
    -
  1. color1: The first color of the stripe
  2. -
  3. color2: The second color of the stripe (defaults to black)
  4. -
  5. scale: Relative width of the stripes, compared to the default
  6. -
  7. phase: Offset in the position of the stripes (π/2 = 1 stripe width)
  8. -
  9. angle: Angle in degrees
- -color1 and color2 spread through striped paint like dye does with itself. color1 can be set on initial placement through the color picker, but otherwise, properties must be changed through the console or with prop.js's tools. - -This does not work with HSL color and the game will black screen if one is somehow used. The color conversion functions are a clusterf***.` - -elements.stripe_paint = { - behavior: behaviors.LIQUID, - state: "liquid", - density: 998, - tempHigh: 100, - stateHigh: "smoke", - color: elements.paint.color, - customColor: true, - category: "special", - properties: { - color1: null, - color2: null, - scale: 1, - phase: 0, - angle: 0 - }, - stain: elements.dye.stain, - tick: function(pixel) { - stripeFunction(pixel); - }, - desc: stripePaintDesc -}; -