rework
add arbitrary angle, phase, second color, and scale
This commit is contained in:
parent
667ef07534
commit
7cbb19573f
|
|
@ -5,12 +5,35 @@ function averageColors(color1,color2,outputType="rgb",weight1=0.5) {
|
||||||
return convertColorFormats(theColor,outputType);
|
return convertColorFormats(theColor,outputType);
|
||||||
};
|
};
|
||||||
|
|
||||||
function stripeFunction(pixel,sineParamFunction) {
|
stripeFixedDefaultProperties = {
|
||||||
if(pixel.oldColor == undefined || pixel.oldColor == null) {
|
color2: "rgb(0,0,0)",
|
||||||
pixel.oldColor = pixel.color;
|
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];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
//oldColor self staining
|
//color1 and color2 self staining
|
||||||
for (var i = 0; i < adjacentCoords.length; i++) {
|
for (var i = 0; i < adjacentCoords.length; i++) {
|
||||||
var x = pixel.x+adjacentCoords[i][0];
|
var x = pixel.x+adjacentCoords[i][0];
|
||||||
var y = pixel.y+adjacentCoords[i][1];
|
var y = pixel.y+adjacentCoords[i][1];
|
||||||
|
|
@ -18,36 +41,50 @@ function stripeFunction(pixel,sineParamFunction) {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
var otherPixel = pixelMap[x][y];
|
var otherPixel = pixelMap[x][y];
|
||||||
if(otherPixel.element == pixel.element && pixel.oldColor && otherPixel.oldColor) {
|
for(prop in stripeSpreadingProperties) {
|
||||||
otherPixel.oldColor = averageColors(pixel.oldColor,otherPixel.oldColor);
|
if(otherPixel.element == pixel.element && pixel[prop] && otherPixel[prop]) {
|
||||||
|
otherPixel[prop] = averageColors(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 sineWeight = (1+Math.sin(sineParamFunction(pixel)))/2;
|
var radians = pixel.angle * (Math.PI / 180);
|
||||||
var preColor = averageColors(pixel.oldColor,"rgb(0,0,0)","json",sineWeight);
|
|
||||||
|
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 = averageColors(pixel.color1,pixel.color2,"json",sineWeight);
|
||||||
for(colorlet in preColor) {
|
for(colorlet in preColor) {
|
||||||
preColor[colorlet] = Math.round(preColor[colorlet]);
|
preColor[colorlet] = Math.round(preColor[colorlet]);
|
||||||
};
|
};
|
||||||
pixel.color = convertColorFormats(preColor,"rgb");
|
pixel.color = convertColorFormats(preColor,"rgb");
|
||||||
};
|
};
|
||||||
|
|
||||||
function horizontalSpf(pixel) {
|
stripePaintDesc = `Exactly what it says on the button.
|
||||||
return pixel.y;
|
<br/>
|
||||||
};
|
Properties: <ol>
|
||||||
|
<li>color1: The first color of the stripe</li>
|
||||||
|
<li>color2: The second color of the stripe (defaults to black)</li>
|
||||||
|
<li>scale: Relative width of the stripes, compared to the default</li>
|
||||||
|
<li>phase: Offset in the position of the stripes (π/2 = 1 stripe width)</li>
|
||||||
|
<li>angle: Angle in degrees<ul>
|
||||||
|
<li>0 = vertical line</li>
|
||||||
|
<li>45 = bottom left to top right</li>
|
||||||
|
<li>90 = horizontal line</li>
|
||||||
|
<li>135 = top left to bottom right...</li>
|
||||||
|
</ul></li></ol>
|
||||||
|
|
||||||
function verticalSpf(pixel) {
|
color1 and color2 spread through striped paint like dye does with itself. <u>color1</u> can be set <em>on initial placement</em> through the color picker, but otherwise, properties must be changed through the console or with prop.js's tools.
|
||||||
return pixel.x;
|
|
||||||
};
|
|
||||||
|
|
||||||
function diagonalSpf(pixel) {
|
<small><em style="color: #ff5555;">This does not work with HSL color and the game will black screen if one is somehow used.</em> The color conversion functions are a clusterf***.</small>`
|
||||||
return pixel.x+pixel.y;
|
|
||||||
};
|
|
||||||
|
|
||||||
function diagonalAltSpf(pixel) {
|
elements.stripe_paint = {
|
||||||
return pixel.x-pixel.y;
|
|
||||||
};
|
|
||||||
|
|
||||||
elements.horizontal_stripe_paint = {
|
|
||||||
behavior: behaviors.LIQUID,
|
behavior: behaviors.LIQUID,
|
||||||
state: "liquid",
|
state: "liquid",
|
||||||
density: 998,
|
density: 998,
|
||||||
|
|
@ -55,66 +92,18 @@ elements.horizontal_stripe_paint = {
|
||||||
stateHigh: "smoke",
|
stateHigh: "smoke",
|
||||||
color: elements.paint.color,
|
color: elements.paint.color,
|
||||||
customColor: true,
|
customColor: true,
|
||||||
category: "stripe paint",
|
category: "special",
|
||||||
properties: {
|
properties: {
|
||||||
oldColor: null
|
color1: null,
|
||||||
|
color2: null,
|
||||||
|
scale: 1,
|
||||||
|
phase: 0,
|
||||||
|
angle: 0
|
||||||
},
|
},
|
||||||
stain: elements.dye.stain,
|
stain: elements.dye.stain,
|
||||||
tick: function(pixel) {
|
tick: function(pixel) {
|
||||||
stripeFunction(pixel,horizontalSpf);
|
stripeFunction(pixel);
|
||||||
},
|
},
|
||||||
|
desc: stripePaintDesc
|
||||||
};
|
};
|
||||||
|
|
||||||
elements.vertical_stripe_paint = {
|
|
||||||
behavior: behaviors.LIQUID,
|
|
||||||
state: "liquid",
|
|
||||||
density: 998,
|
|
||||||
tempHigh: 100,
|
|
||||||
stateHigh: "smoke",
|
|
||||||
color: elements.paint.color,
|
|
||||||
customColor: true,
|
|
||||||
category: "stripe paint",
|
|
||||||
properties: {
|
|
||||||
oldColor: null
|
|
||||||
},
|
|
||||||
stain: elements.dye.stain,
|
|
||||||
tick: function(pixel) {
|
|
||||||
stripeFunction(pixel,verticalSpf);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
elements.diagonal_stripe_paint = {
|
|
||||||
behavior: behaviors.LIQUID,
|
|
||||||
state: "liquid",
|
|
||||||
density: 998,
|
|
||||||
tempHigh: 100,
|
|
||||||
stateHigh: "smoke",
|
|
||||||
color: elements.paint.color,
|
|
||||||
customColor: true,
|
|
||||||
category: "stripe paint",
|
|
||||||
properties: {
|
|
||||||
oldColor: null
|
|
||||||
},
|
|
||||||
stain: elements.dye.stain,
|
|
||||||
tick: function(pixel) {
|
|
||||||
stripeFunction(pixel,diagonalSpf);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
elements.diagonal_2_stripe_paint = {
|
|
||||||
behavior: behaviors.LIQUID,
|
|
||||||
state: "liquid",
|
|
||||||
density: 998,
|
|
||||||
tempHigh: 100,
|
|
||||||
stateHigh: "smoke",
|
|
||||||
color: elements.paint.color,
|
|
||||||
customColor: true,
|
|
||||||
category: "stripe paint",
|
|
||||||
properties: {
|
|
||||||
oldColor: null
|
|
||||||
},
|
|
||||||
stain: elements.dye.stain,
|
|
||||||
tick: function(pixel) {
|
|
||||||
stripeFunction(pixel,diagonalAltSpf);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
Loading…
Reference in New Issue