fullscreen void setupDotList ()
{
int totalAmount = radiusAmount*dotsPerRadius;
dotList = new PVector [totalAmount];
//println (totalAmount);
}
void createRadius ()
{
randomSeed (actRandomSeed);
noiseSeed (actNoiseSeed);
int dotCounter = 0;
int count = 0;
int amount = radiusAmount;
float radiusNoise = random (3);
while (count < amount)
{
float radius = startRadius + noise (radiusNoise)*noiseRadius;
float zRandom = (-150)+ random (15*count, 17*count);
float zArranged = (-150)+ 16*count;
float m = map(randomZPos, 0,10, 0,1);
m = constrain(m, 0, 1);
float z1 = lerp(zRandom, zArranged, m);
//float z1 = (-150)+ random (15*count, 17*count);
int centerX = 0, centerY = 0;
int dotsPerRadiusCount = 0;
int dotsPerRadiusAmount = dotsPerRadius;
float steps = TWO_PI / dotsPerRadiusAmount;
float angle = 0;
float time = 0+timeSeed;
while (dotsPerRadiusCount < dotsPerRadiusAmount)
{
float noiseValue = noise (time)*noiseZ;
if (count >= amount-2) noiseValue = 0;
float x = centerX + cos (angle) * (radius);
float y = centerY + sin (angle) * (radius);
float z = z1+noiseValue;
dotList [dotCounter] = new PVector (x,y, z);
time += 0.075;
angle += steps;
dotsPerRadiusCount++;
dotCounter++;
}
radiusNoise += 0.13;
count++;
}
}
color hover = color (12,108,129,140);
color out = color (180,53,53,140);
color gray = color (180);
color darkgray = color (70);
color textCLight = color (80),textCDark = color (200), amountTextColor = color (247);
color menuColor = out, fillAlphaColor = out, strokeAlphaColor = out, dotsAmountColor = out, radiusAmountColor = out, radiusSizeColor = out, radiusNoiseColor = out, zColor = out, randomSpacingColor = out, noiseZColor = out, colorAmountColor = out, colorChangingColor = out, lightXColor = out, lightYColor = out, lightZColor = out;
color gridColor = out, backgroundColor = out, ro1Color = out, ro2Color = out;
color color1 = out, color2 = out, color3 = out, resetSettingsColor = out, resetLightsColor = out, resetRotationColor = out, prevColor = out, nextColor = out;
int startText = 20, startX = 130, amountTextX = startX+10, GUIwidth = 500, sliderWidth = GUIwidth-startText-startX, sliderHeight = 16;
int startText2 = startX+sliderHeight+10, startX2 = startX+sliderWidth/2, startText3 = startX2 + sliderHeight+10;
float alphaSteps = (float (sliderWidth) / float (alphaMax));
float dotsSteps = float (sliderWidth) / float (dotsMax-dotsMin);
float radiusAmountSteps = float (sliderWidth) / float (radiusMax- radiusMin);
float radiusSizeSteps = float (sliderWidth) / float (maxRadiusSize + abs (minRadiusSize));
float radiusNoiseSteps = float (sliderWidth) / float (radiusNoiseMax);
float zSteps = float (sliderWidth) / float (zMax);
float randomSpacingSteps = float (sliderWidth) / float (randomSpacingMax);
float noiseZSteps = float (sliderWidth) / float (noiseZMax);
float colorAmountSteps = float (sliderWidth) / float (colorMax-colorMin);
float colorChangingSteps = float (sliderWidth) / float (colorChangingMax-colorMin);
float lightSteps = float (sliderWidth) / float (lightMax + abs(lightMin));
int sliderSpacing = 26;
int menuY = sliderSpacing, fillAlphaY = 2*sliderSpacing, strokeAlphaY = 3*sliderSpacing, dotsAmountY = 4*sliderSpacing, radiusAmountY = 5*sliderSpacing, radiusSizeY = 6*sliderSpacing, radiusNoiseY = 7*sliderSpacing, zY = 8*sliderSpacing, randomSpacingY = 9*sliderSpacing, noiseZY = 10*sliderSpacing;
int colorAmountY = 11*sliderSpacing, colorChangingY = 12*sliderSpacing, lightXY = 13*sliderSpacing, lightYY = 14*sliderSpacing, lightZY = 15*sliderSpacing;
int gridY = 16*sliderSpacing, bgY = gridY, ro1Y = 17*sliderSpacing,ro2Y = ro1Y, colorY=18*sliderSpacing, resetY = 19*sliderSpacing, stationY = 20*sliderSpacing;
float fillAlphaX, strokeAlphaX, dotsAmountX, radiusAmountX, radiusSizeX, radiusNoiseX, zX, randomSpacingX, noiseZX, colorAmountX, colorChangingX, lightXX, lightYX, lightZX, shininessAmountX;
int btnWidth = 90, btn1X = startX, btn2X = btn1X+btnWidth+16, btn3X = btn2X+btnWidth+16;
void showGUI ()
{
// hintergrund
noStroke ();
if (changeBG == false) fill (220, 70);
if (changeBG == true) fill (40, 70);
rect (0, 0, GUIwidth, height);
String nextText, amountText;
textFont (font, textS);
if (changeBG == false) fill (textCLight);
if (changeBG == true) fill (textCDark);
// menu
nextText = "Fill Alpha";
text (nextText, startText, fillAlphaY+textS);
nextText = "Stroke Alpha";
text (nextText, startText, strokeAlphaY+textS);
nextText = "Dots Amount";
text (nextText, startText, dotsAmountY+textS);
nextText = "Radius Amount";
text (nextText, startText, radiusAmountY+textS);
nextText = "Radius Size";
text (nextText, startText, radiusSizeY+textS);
nextText = "Radius Noise";
text (nextText, startText, radiusNoiseY+textS);
nextText = "Z";
text (nextText, startText, zY+textS);
nextText = "Random Spacing";
text (nextText, startText, randomSpacingY+textS);
nextText = "Z Noise";
text (nextText, startText, noiseZY+textS);
nextText = "Color Amount";
text (nextText, startText, colorAmountY+textS);
nextText = "Color Changing";
text (nextText, startText, colorChangingY+textS);
nextText = "Light X";
text (nextText, startText, lightXY+textS);
nextText = "Light Y";
text (nextText, startText, lightYY+textS);
nextText = "Light Z";
text (nextText, startText, lightZY+textS);
if (showFill==true) nextText ="Show Grid";
if (showFill==false) nextText ="Show Fill";
text (nextText, startText2, gridY+textS);
if (changeBG == false) nextText ="Black background >>";
if (changeBG == true) nextText ="White background >>";
text (nextText, startText3, bgY+textS);
nextText ="Rotate 1";
text (nextText, startText2, ro1Y+textS);
nextText ="Rotate 2";
text (nextText, startText3, ro2Y+textS);
nextText ="Space Station";
text (nextText, btn2X, stationY+textS);
// gray background
if (changeBG == false) fill (gray);
if (changeBG == true) fill (darkgray);
rect (startX, fillAlphaY, sliderWidth, sliderHeight);
rect (startX, strokeAlphaY, sliderWidth, sliderHeight);
rect (startX, dotsAmountY, sliderWidth, sliderHeight);
rect (startX, radiusAmountY, sliderWidth, sliderHeight);
rect (startX, radiusSizeY, sliderWidth, sliderHeight);
rect (startX, radiusNoiseY, sliderWidth, sliderHeight);
rect (startX, zY, sliderWidth, sliderHeight);
rect (startX, randomSpacingY, sliderWidth, sliderHeight);
rect (startX, noiseZY, sliderWidth, sliderHeight);
rect (startX, colorAmountY, sliderWidth, sliderHeight);
rect (startX, colorChangingY, sliderWidth, sliderHeight);
rect (startX, lightXY, sliderWidth, sliderHeight);
rect (startX, lightYY, sliderWidth, sliderHeight);
rect (startX, lightZY, sliderWidth, sliderHeight);
rect (startX, gridY, sliderHeight, sliderHeight);
rect (startX2, bgY, sliderHeight, sliderHeight);
rect (startX, ro1Y, sliderHeight, sliderHeight);
rect (startX2, ro2Y, sliderHeight, sliderHeight);
rect (btn1X, colorY, btnWidth, sliderHeight);
rect (btn2X, colorY, btnWidth, sliderHeight);
rect (btn3X, colorY, btnWidth, sliderHeight);
rect (btn1X, resetY, btnWidth, sliderHeight);
rect (btn2X, resetY, btnWidth, sliderHeight);
rect (btn3X, resetY, btnWidth, sliderHeight);
rect (btn1X, stationY, btnWidth, sliderHeight);
rect (btn3X, stationY, btnWidth, sliderHeight);
// colored slider
fill (fillAlphaColor);
rect (startX, fillAlphaY, fillAlphaX, sliderHeight);
fill (strokeAlphaColor);
rect (startX, strokeAlphaY, strokeAlphaX, sliderHeight);
fill (dotsAmountColor);
rect (startX, dotsAmountY, dotsAmountX, sliderHeight);
fill (radiusAmountColor);
rect (startX,radiusAmountY, radiusAmountX, sliderHeight);
fill (radiusSizeColor);
rect (startX, radiusSizeY, radiusSizeX, sliderHeight);
fill (radiusNoiseColor);
rect (startX, radiusNoiseY, radiusNoiseX, sliderHeight);
fill (zColor);
rect (startX, zY, zX, sliderHeight);
fill (randomSpacingColor);
rect (startX, randomSpacingY, randomSpacingX, sliderHeight);
fill (noiseZColor);
rect (startX, noiseZY, noiseZX, sliderHeight);
fill (colorAmountColor);
rect (startX, colorAmountY, colorAmountX, sliderHeight);
fill (colorChangingColor);
rect (startX, colorChangingY, colorChangingX, sliderHeight);
fill (lightXColor);
rect (startX, lightXY, lightXX, sliderHeight);
fill (lightYColor);
rect (startX, lightYY, lightYX, sliderHeight);
fill (lightZColor);
rect (startX, lightZY, lightZX, sliderHeight);
fill (gridColor);
rect (startX, gridY, sliderHeight, sliderHeight);
fill (backgroundColor);
rect (startX2, bgY, sliderHeight, sliderHeight);
fill (ro1Color);
rect (startX, ro1Y, sliderHeight, sliderHeight);
fill (ro2Color);
rect (startX2, ro2Y, sliderHeight, sliderHeight);
fill (resetSettingsColor);
rect (btn1X, resetY, btnWidth, sliderHeight);
fill (resetLightsColor);
rect (btn2X, resetY, btnWidth, sliderHeight);
fill (resetRotationColor);
rect (btn3X, resetY, btnWidth, sliderHeight);
fill (prevColor);
rect (btn1X, stationY, btnWidth, sliderHeight);
fill (nextColor);
rect (btn3X, stationY, btnWidth, sliderHeight);
fill (color1);
rect (btn1X, colorY, btnWidth, sliderHeight);
fill (color2);
rect (btn2X, colorY, btnWidth, sliderHeight);
fill (color3);
rect (btn3X, colorY, btnWidth, sliderHeight);
// amount
textFont (smallFont, textS-2);
fill (amountTextColor);
amountText = str (aFill);
text (amountText, amountTextX, fillAlphaY+textS);
amountText = str (aStroke);
text (amountText, amountTextX, strokeAlphaY+textS);
amountText = str (dotsPerRadius);
text (amountText, amountTextX, dotsAmountY+textS);
amountText = str (radiusAmount);
text (amountText, amountTextX, radiusAmountY+textS);
amountText = nf (startRadius, 1,2);
text (amountText, amountTextX, radiusSizeY+textS);
amountText = str (noiseRadius);
text (amountText, amountTextX, radiusNoiseY+textS);
amountText = nf (zFactor,1,2);
text (amountText, amountTextX, zY+textS);
amountText = nf (randomZPos,1,2);
text (amountText, amountTextX, randomSpacingY+textS);
amountText = str (noiseZ);
text (amountText, amountTextX, noiseZY+textS);
amountText = nf (pow (colorAmount,2),1,0);
text (amountText, amountTextX, colorAmountY+textS);
amountText = str (changingColors);
text (amountText, amountTextX, colorChangingY+textS);
amountText = str (lightX);
text (amountText, amountTextX, lightXY+textS);
amountText = str (lightY);
text (amountText, amountTextX, lightYY+textS);
amountText = str (lightZ);
text (amountText, amountTextX, lightZY+textS);
if (doRotateOne == true) shape (crossShape,startX+2,ro1Y+2,12,12);
if (doRotateTwo == true) shape (crossShape,startX2+2,ro2Y+2,12,12);
amountText = "Reset Settings";
text (amountText, btn1X+10, resetY+textS);
amountText = "Colors 01";
text (amountText, btn1X+10, colorY+textS);
amountText = "Colors 02";
text (amountText, btn2X+10, colorY+textS);
amountText = "Colors 03";
text (amountText, btn3X+10, colorY+textS);
amountText = "Reset Lights";
text (amountText, btn2X+10, resetY+textS);
amountText = "Reset Rotation";
text (amountText, btn3X+10, resetY+textS);
amountText = "<< Previous";
text (amountText, btn1X+10, stationY+textS);
amountText = "Next >>";
text (amountText, btn3X+10, stationY+textS);
}
void GUIEvent ()
{
if (mouseX >= startX && mouseX <=startX+sliderWidth&& mouseY >= fillAlphaY && mouseY <= fillAlphaY+sliderHeight)
{
fillAlphaColor = hover;
if (mouseIsReleased == true) fillAlphaX = mouseX-startX;
fillAlphaX = constrain (fillAlphaX, 0, sliderWidth);
}
else fillAlphaColor = out;
if (mouseX >= startX && mouseX <=startX+sliderWidth&& mouseY >= strokeAlphaY && mouseY <= strokeAlphaY+sliderHeight)
{
strokeAlphaColor = hover;
if (mouseIsReleased == true) strokeAlphaX = mouseX-startX;
strokeAlphaX = constrain (strokeAlphaX, 0, sliderWidth);
}
else strokeAlphaColor = out;
if (mouseX >= startX && mouseX <=startX+sliderWidth&& mouseY >= dotsAmountY && mouseY <= dotsAmountY+sliderHeight)
{
dotsAmountColor = hover;
if (mouseIsReleased == true) dotsAmountX = mouseX-startX;
dotsAmountX = constrain (dotsAmountX, 0, sliderWidth);
newArray = true;
}
else dotsAmountColor = out;
if (mouseX >= startX && mouseX <=startX+sliderWidth&& mouseY >= radiusAmountY && mouseY <= radiusAmountY+sliderHeight)
{
radiusAmountColor = hover;
if (mouseIsReleased == true) radiusAmountX = mouseX-startX;
radiusAmountX = constrain (radiusAmountX, 0, sliderWidth);
newArray = true;
}
else radiusAmountColor = out;
if (mouseX >= startX && mouseX <=startX+sliderWidth&& mouseY >= radiusSizeY && mouseY <= radiusSizeY+sliderHeight)
{
radiusSizeColor = hover;
if (mouseIsReleased == true) radiusSizeX = mouseX-startX;
radiusSizeX = constrain (radiusSizeX, 0, sliderWidth);
newDots = true;
}
else radiusSizeColor = out;
if (mouseX >= startX && mouseX <=startX+sliderWidth&& mouseY >= radiusNoiseY && mouseY <= radiusNoiseY+sliderHeight)
{
radiusNoiseColor = hover;
if (mouseIsReleased == true) radiusNoiseX = mouseX-startX;
radiusNoiseX = constrain (radiusNoiseX, 0, sliderWidth);
newDots = true;
}
else radiusNoiseColor = out;
if (mouseX >= startX && mouseX <=startX+sliderWidth&& mouseY >= zY && mouseY <= zY+sliderHeight)
{
zColor = hover;
if (mouseIsReleased == true) zX = mouseX-startX;
zX = constrain (zX, 0, sliderWidth);
}
else zColor = out;
if (mouseX >= startX && mouseX <=startX+sliderWidth&& mouseY >= randomSpacingY && mouseY <= randomSpacingY+sliderHeight)
{
randomSpacingColor = hover;
if (mouseIsReleased == true) randomSpacingX = mouseX-startX;
randomSpacingX = constrain (randomSpacingX, 0, sliderWidth);
newDots = true;
}
else randomSpacingColor = out;
if (mouseX >= startX && mouseX <=startX+sliderWidth&& mouseY >= noiseZY && mouseY <= noiseZY+sliderHeight)
{
noiseZColor = hover;
if (mouseIsReleased == true) noiseZX = mouseX-startX;
noiseZX = constrain (noiseZX, 0, sliderWidth);
newDots = true;
}
else noiseZColor = out;
if (mouseX >= startX && mouseX <=startX+sliderWidth&& mouseY >= colorAmountY && mouseY <= colorAmountY+sliderHeight)
{
colorAmountColor = hover;
if (mouseIsReleased == true) colorAmountX = mouseX-startX;
colorAmountX = constrain (colorAmountX, 0, sliderWidth);
newColors = true;
}
else colorAmountColor = out;
if (mouseX >= startX && mouseX <=startX+sliderWidth&& mouseY >= colorChangingY && mouseY <= colorChangingY+sliderHeight)
{
colorChangingColor = hover;
if (mouseIsReleased == true) colorChangingX = mouseX-startX;
colorChangingX = constrain (colorChangingX, 0, sliderWidth);
newColors = true;
}
else colorChangingColor = out;
if (mouseX >= startX && mouseX <=startX+sliderWidth&& mouseY >= lightXY && mouseY <= lightXY+sliderHeight)
{
lightXColor = hover;
if (mouseIsReleased == true) lightXX = mouseX-startX;
lightXX = constrain (lightXX, 0, sliderWidth);
}
else lightXColor = out;
if (mouseX >= startX && mouseX <=startX+sliderWidth&& mouseY >= lightYY && mouseY <= lightYY+sliderHeight)
{
lightYColor = hover;
if (mouseIsReleased == true) lightYX = mouseX-startX;
lightYX = constrain (lightYX, 0, sliderWidth);
}
else lightYColor = out;
if (mouseX >= startX && mouseX <=startX+sliderWidth&& mouseY >= lightZY && mouseY <= lightZY+sliderHeight)
{
lightZColor = hover;
if (mouseIsReleased == true) lightZX = mouseX-startX;
lightZX = constrain (lightZX, 0, sliderWidth);
}
else lightZColor = out;
if (mouseX >= startX && mouseX <=startX+sliderHeight&& mouseY >= gridY && mouseY <= gridY+sliderHeight)
{
gridColor = hover;
if (mouseIsReleased == true)
{
if (showFill == true) showFill = false;
else if (showFill == false) showFill = true;
}
}
else gridColor = out;
if (mouseX >= startX2 && mouseX <=startX2+sliderHeight&& mouseY >= bgY && mouseY <= bgY+sliderHeight)
{
backgroundColor = hover;
if (mouseIsReleased == true)
{
if (changeBG == true) {
changeBG = false;
bgColor = color (0,0,93);
}
else if (changeBG == false) {
changeBG = true;
bgColor = color (0,0,7);
}
}
}
else backgroundColor = out;
if (mouseX >= startX && mouseX <=startX+sliderHeight&& mouseY >= ro1Y && mouseY <= ro1Y+sliderHeight)
{
ro1Color = hover;
if (mouseIsReleased == true)
{
if (doRotateOne == true) {
doRotateOne = false;
doRotate = false;
doRotateTwo = false;
}
else if (doRotateOne == false) {
doRotateOne = true;
doRotate = true;
doRotateTwo = false;
}
}
}
else ro1Color = out;
if (mouseX >= startX2 && mouseX <=startX2+sliderHeight&& mouseY >= ro2Y && mouseY <= ro2Y+sliderHeight)
{
ro2Color = hover;
if (mouseIsReleased == true)
{
if (doRotateTwo == true) {
doRotateTwo = false;
doRotate = false;
doRotateOne = false;
}
else if (doRotateTwo == false) {
doRotateTwo = true;
doRotate = true;
doRotateOne = false;
}
}
}
else ro2Color = out;
if (mouseX >= btn1X && mouseX <=btn1X+btnWidth&& mouseY >= resetY && mouseY <= resetY+sliderHeight)
{
resetSettingsColor = hover;
if (mouseIsReleased == true) setupPresets ();
}
else resetSettingsColor = out;
if (mouseX >= btn1X && mouseX <=btn1X+btnWidth&& mouseY >= colorY && mouseY <= colorY+sliderHeight)
{
color1 = hover;
if (mouseIsReleased == true)
{
img1color = true;
img2color = false;
img3color = false;
colors();
}
}
else color1 = out;
if (mouseX >= btn2X && mouseX <=btn2X+btnWidth&& mouseY >= colorY && mouseY <= colorY+sliderHeight)
{
color2 = hover;
if (mouseIsReleased == true)
{
img1color = false;
img2color = true;
img3color = false;
colors();
}
}
else color2 = out;
if (mouseX >= btn3X && mouseX <=btn3X+btnWidth&& mouseY >= colorY && mouseY <= colorY+sliderHeight)
{
color3 = hover;
if (mouseIsReleased == true)
{
img1color = false;
img2color = false;
img3color = true;
colors();
}
}
else color3 = out;
if (mouseX >= btn2X && mouseX <=btn2X+btnWidth&& mouseY >= resetY && mouseY <= resetY+sliderHeight)
{
resetLightsColor = hover;
if (mouseIsReleased == true) setupLight ();
}
else resetLightsColor = out;
if (mouseX >= btn3X && mouseX <=btn3X+btnWidth&& mouseY >= resetY && mouseY <= resetY+sliderHeight)
{
resetRotationColor = hover;
if (mouseIsReleased == true) setupRotation ();
}
else resetRotationColor = out;
if (mouseX >= btn1X && mouseX <=btn1X+btnWidth&& mouseY >= stationY && mouseY <= stationY+sliderHeight)
{
prevColor = hover;
if (mouseIsReleased == true) {
actRandomSeed -= 1;
actNoiseSeed -= 1;
createRadius ();
}
}
else prevColor = out;
if (mouseX >= btn3X && mouseX <=btn3X+btnWidth&& mouseY >= stationY && mouseY <= stationY+sliderHeight)
{
nextColor = hover;
if (mouseIsReleased == true) {
actRandomSeed += 1;
actNoiseSeed += 1;
createRadius ();
}
}
else nextColor = out;
}
void calGUI ()
{
aFill = int (fillAlphaX/alphaSteps);
aStroke = int (strokeAlphaX/alphaSteps);
dotsPerRadius = int (dotsAmountX/dotsSteps);
dotsPerRadius = constrain (dotsPerRadius, dotsMin,dotsMax);
dotsAmountX = dotsSteps*dotsPerRadius;
radiusAmount = int ( radiusAmountX/radiusAmountSteps );
radiusAmount = constrain (radiusAmount, radiusMin,radiusMax);
radiusAmountX = radiusAmountSteps*radiusAmount;
startRadius = (radiusSizeX+(minRadiusSize*radiusSizeSteps))/radiusSizeSteps;
zFactor = zX/zSteps;
noiseRadius = int (radiusNoiseX/radiusNoiseSteps);
randomZPos = randomSpacingX/randomSpacingSteps;
noiseZ = int (noiseZX/noiseZSteps);
colorAmount = int (colorAmountX/colorAmountSteps);
colorAmount = constrain (colorAmount, colorMin,colorMax);
colorAmountX = colorAmountSteps*colorAmount;
changingColors = int (colorChangingX/colorChangingSteps);
changingColors = constrain (changingColors, colorMin,colorChangingMax);
colorChangingX = colorChangingSteps*changingColors;
lightX = int ((lightXX+(lightMin*lightSteps))/lightSteps);
lightY = int ((lightYX+(lightMin*lightSteps))/lightSteps);
lightZ = int ((lightZX+(lightMin*lightSteps))/lightSteps);
if (newArray == true)
{
setupDotList ();
createRadius ();
newArray = false;
}
if (newDots == true)
{
createRadius ();
newDots = false;
}
if (newColors == true)
{
colors();
newColors = false;
}
}
void menu ()
{
String nextText, amountText;
textFont (font, textS);
if (changeBG == false) fill (textCLight);
if (changeBG == true) fill (textCDark);
// menu
nextText = "Menu";
text (nextText, startText, menuY+textS);
noStroke();
// gray background
if (changeBG == false) fill (gray);
if (changeBG == true) fill (darkgray);
rect (0, menuY, sliderHeight, sliderHeight);
// colored slider
fill (menuColor);
rect (0, menuY, sliderHeight, sliderHeight);
if (mouseX >= 0 && mouseX <=sliderHeight&& mouseY >= menuY && mouseY <= menuY+sliderHeight)
{
menuColor = hover;
if (mouseIsReleased == true)
{
if (showGUI == true) showGUI = false;
else if (showGUI == false) showGUI = true;
}
}
else menuColor = out;
}
void createGUIPosition ()
{
fillAlphaX = (aFill*alphaSteps);
strokeAlphaX = (aStroke*alphaSteps);
dotsAmountX = dotsSteps*dotsPerRadius;
radiusAmountX = radiusAmountSteps*radiusAmount;
radiusSizeX = (startRadius*radiusSizeSteps)-(minRadiusSize*radiusSizeSteps);
radiusNoiseX = radiusNoiseSteps*noiseRadius;
zX = zSteps*zFactor;
randomSpacingX =randomSpacingSteps*randomZPos ;
noiseZX = noiseZSteps*noiseZ;
colorAmountX = colorAmountSteps*colorAmount;
colorChangingX = colorChangingSteps*changingColors;
lightXX = (lightSteps*lightX)-(lightMin*lightSteps);
lightYX = (lightSteps*lightY)-(lightMin*lightSteps);
lightZX = (lightSteps*lightZ)-(lightMin*lightSteps);
lightXX = constrain (lightXX, lightMin, lightMax);
lightYX = constrain (lightYX, lightMin, lightMax);
lightZX = constrain (lightZX, lightMin, lightMax);
minMax ();
}
void colors ()
{
if(img1color== true) img=img1;
if(img2color== true) img=img2;
if(img3color== true) img=img3;
img.loadPixels ();
int count = 0;
int rowCount = 0;
int columnCount = 0;
int rowMax = colorAmount, columnMax = rowMax;
float xSpacing = float (img.width / columnMax), ySpacing = float (img.height / rowMax);
colorList = new color [rowMax * columnMax];
while (rowCount < rowMax)
{
columnCount = 0;
while (columnCount < columnMax)
{
int index = int ((columnCount*xSpacing)+(rowCount*ySpacing)*img.width);
float h = hue (img.pixels [index]);
float s = saturation (img.pixels [index]);
float b = brightness (img.pixels [index]);
colorList [count] = color (h,s,b);
columnCount++;
count++;
}
rowCount++;
}
}
void mouseReleased()
{
mouseIsReleased = true;
}
void keyPressed ()
{
if (keyCode == KeyEvent.VK_SPACE) setupPresets ();
if (keyCode == KeyEvent.VK_ALT) setupLight ();
if (keyCode == KeyEvent.VK_CONTROL) setupRotation ();
// alpha --------------------------------------------------------------------
if (keyCode == KeyEvent.VK_U && showFill == true)
{
aFill -= 1;
minMax ();
}
if (keyCode == KeyEvent.VK_I && showFill == true)
{
aFill += 1;
minMax ();
}
if (keyCode == KeyEvent.VK_O && showFill == false)
{
aStroke -= 1;
minMax ();
}
if (keyCode == KeyEvent.VK_P && showFill == false)
{
aStroke += 1;
minMax ();
}
// radius & dots --------------------------------------------------------------------
if (keyCode == KeyEvent.VK_T)
{
startRadius -= 1;
createRadius ();
}
if (keyCode == KeyEvent.VK_Z)
{
startRadius += 1;
createRadius ();
}
if (keyCode == KeyEvent.VK_1)
{
noiseRadius -= 1;
if (noiseRadius>1) startRadius += 0.5;
minMax ();
createRadius ();
}
if (keyCode == KeyEvent.VK_2)
{
noiseRadius += 1;
if (noiseRadius<400) startRadius -= 0.5;
minMax ();
createRadius ();
}
if (keyCode == KeyEvent.VK_3)
{
noiseZ -= 1;
minMax ();
createRadius ();
}
if (keyCode == KeyEvent.VK_4)
{
noiseZ += 1;
minMax ();
createRadius ();
}
if (keyCode == KeyEvent.VK_5)
{
randomZPos -= 0.1;
minMax ();
createRadius ();
}
if (keyCode == KeyEvent.VK_6)
{
randomZPos += 0.1;
minMax ();
createRadius ();
}
if (keyCode == KeyEvent.VK_M)
{
radiusAmount += 1;
minMax ();
setupDotList ();
createRadius ();
}
if (keyCode == KeyEvent.VK_N)
{
radiusAmount -= 1;
minMax ();
setupDotList ();
createRadius ();
}
if (keyCode == KeyEvent.VK_K)
{
dotsPerRadius -= 1;
minMax ();
setupDotList ();
createRadius ();
}
if (keyCode == KeyEvent.VK_L)
{
dotsPerRadius += 1;
minMax ();
setupDotList ();
createRadius ();
}
// seed control --------------------------------------------------------------------
if (keyCode == KeyEvent.VK_UP&& showFill == false)
{
timeSeed += 0.075;
createRadius ();
}
if (keyCode == KeyEvent.VK_DOWN&& showFill == false)
{
timeSeed -= 0.075;
createRadius ();
}
if (keyCode == KeyEvent.VK_RIGHT)
{
actRandomSeed += 1;
actNoiseSeed += 1;
createRadius ();
}
if (keyCode == KeyEvent.VK_LEFT)
{
actRandomSeed -= 1;
actNoiseSeed -= 1;
createRadius ();
}
// tiefe --------------------------------------------------------------------
if (keyCode == KeyEvent.VK_PLUS)
{
zFactor += 0.01;
minMax ();
}
if (keyCode == KeyEvent.VK_MINUS)
{
zFactor -= 0.01;
minMax ();
}
// licht --------------------------------------------------------------------
if (keyCode == KeyEvent.VK_Q) lightX -= 10;
if (keyCode == KeyEvent.VK_W) lightX += 10;
if (keyCode == KeyEvent.VK_A) lightY -= 10;
if (keyCode == KeyEvent.VK_S) lightY += 10;
if (keyCode == KeyEvent.VK_Y) lightZ -= 10;
if (keyCode == KeyEvent.VK_X) lightZ += 10;
// füllung und hintergrund --------------------------------------------------------------------
if (keyCode == KeyEvent.VK_V) {
if (showFill == true) showFill = false;
else if (showFill == false) showFill = true;
}
if (keyCode == KeyEvent.VK_B) {
if (changeBG == true) {
changeBG = false;
bgColor = color (0,0,93);
}
else if (changeBG == false) {
changeBG = true;
bgColor = color (0,0,7);
}
}
// farbe --------------------------------------------------------------------
if (keyCode == KeyEvent.VK_D)
{
colorAmount -= 1;
minMax ();
colors();
}
if (keyCode == KeyEvent.VK_F)
{
colorAmount += 1;
minMax ();
colors();
}
if (keyCode == KeyEvent.VK_7)
{
img1color = true;
img2color = false;
img3color = false;
colors();
}
if (keyCode == KeyEvent.VK_8)
{
img1color = false;
img2color = true;
img3color = false;
colors();
}
if (keyCode == KeyEvent.VK_9)
{
img1color = false;
img2color = false;
img3color = true;
colors();
}
// farbwechsel --------------------------------------------------------------------
if (keyCode == KeyEvent.VK_G)
{
changingColors -= 1;
minMax ();
}
if (keyCode == KeyEvent.VK_H)
{
changingColors += 1;
minMax ();
}
// rotation --------------------------------------------------------------------
if (keyCode == KeyEvent.VK_R)
{
if (doRotateOne == true)
{
doRotate = false;
doRotateOne = false;
}
else if (doRotateOne == false)
{
doRotate = true;
doRotateOne = true;
}
}
if (keyCode == KeyEvent.VK_E)
{
if (doRotateTwo == true)
{
doRotate = false;
doRotateTwo = false;
}
else if (doRotateTwo == false)
{
doRotateTwo = true;
doRotate = true;
}
}
// GUI --------------------------------------------------------------------
if (keyCode == KeyEvent.VK_0)
{
if (showGUI == true)
{
showGUI = false;
}
else if (doRotate == false)
{
showGUI = true;
}
}
if (keyCode == KeyEvent.VK_TAB)
{
setTimestamp();
saveFrame( "export/" + myName + "_" + time + ".png" );
}
createGUIPosition ();
}
void setTimestamp()
{
year = nf( year(), 4 );
month = nf( month(), 2 );
day = nf( day(), 2 );
hour = nf( hour(), 2 );
minute = nf( minute(), 2 );
second = nf( second(), 2 );
time = year + "_" + month + "_" + day + "_" + hour + "_" + minute + "_" + second;
}
import peasy.*;
//import processing.opengl.*;
// Arrays --------------------------------------------------------------------
PVector dotList [];
color colorList [];
//Data --------------------------------------------------------------------
PImage img, img1, img2, img3, bg;
PFont font, smallFont;
PShape crossShape;
// start amount --------------------------------------------------------------------
int actRandomSeed = 5, actNoiseSeed = 2;
float timeSeed = 0;
int radiusAmount = 20, dotsPerRadius = 300, textS = 12;
float startRadius = 10, randomZPos = 0, zFactor =1, shininessAmount = 4;
int noiseRadius = 280, noiseZ = 50;
int aFill = 180, aStroke = 60;
int lightX = 0, lightY = 0, lightZ = 0;
color bgColor;
int colorAmount = 12, changingColors = 50;
float rotation = 0, rotationX = 0, rotationY = 0, rotationZ = 0;
// Min & Max --------------------------------------------------------------------
int minRadiusSize = -500, radiusMin = 2, dotsMin = 2, colorMin = 1, lightMin = -400;
int alphaMax = 255, dotsMax = 360, radiusMax = 70, maxRadiusSize = 1000, radiusNoiseMax = 600, zMax = 3, randomSpacingMax = 10, noiseZMax = 400, colorMax = 40, colorChangingMax = 200, lightMax = 400;
//Timestamp --------------------------------------------------------------------
String myName = "diana_lange";
String time, year, month, day, hour, minute, second;
//True or False --------------------------------------------------------------------
boolean showFill = true, changeBG = true, doRotate = true, doRotateOne = false, doRotateTwo = true, showGUI = true, mouseIsReleased = false, newArray = false, newDots = false, newColors = false;
boolean img1color = false, img2color = true, img3color = false;
// Classes --------------------------------------------------------------------
PeasyCam cam;
void setup ()
{
size (900, 700, P3D);
colorMode (HSB, 360, 100, 100);
background (0,0,7);
loop();
frameRate (25);
// hints for OPENGL --------------------------------------------------------------------
hint(ENABLE_NATIVE_FONTS);
hint(DISABLE_OPENGL_ERROR_REPORT);
hint(ENABLE_OPENGL_4X_SMOOTH);
hint(DISABLE_OPENGL_2X_SMOOTH);
// Camera --------------------------------------------------------------------
cam = new PeasyCam(this, 0, 0, 0,400);
cam.setMinimumDistance(10);
cam.setMaximumDistance(9000);
// Data --------------------------------------------------------------------
img = loadImage ("img1.jpg");
img1 = loadImage ("img1.jpg");
img2 = loadImage ("img2.jpg");
img3 = loadImage ("img3.jpg");
bg = loadImage ("bg.png");
bg.resize (700, 700);
bgColor = color (0,0,7);
font = createFont ("Arial", textS);
smallFont = createFont ("Arial", textS-2);
font = loadFont ("Verdana-60.vlw");
smallFont = loadFont ("Verdana-60.vlw");
crossShape = loadShape ("cross.svg");
// Presets --------------------------------------------------------------------
setupPresets ();
setupDotList ();
createRadius ();
colors();
createGUIPosition ();
}
void draw ()
{
background (bgColor);
pushMatrix();
// Lights and texture --------------------------------------------------------------------
cam.beginHUD();
if (showFill == true)
{
directionalLight(0, 0, 90, 640, 360, -280);
directionalLight(0, 0, 90, -570+lightX, 20+lightY, -660+lightZ);
shininess(shininessAmount);
emissive(15);
}
//specular( 10);
cam.endHUD();
// hints for OPENGL --------------------------------------------------------------------
hint(ENABLE_NATIVE_FONTS);
hint(DISABLE_OPENGL_ERROR_REPORT);
hint(ENABLE_OPENGL_4X_SMOOTH);
hint(DISABLE_OPENGL_2X_SMOOTH);
// rotation--------------------------------------------------------------------
rotate (radians (rotation));
rotateX (radians (rotationX));
rotateY (radians (rotationY));
rotateZ (radians (rotationZ));
if (doRotate == true) rotation ();
// draw Space Station--------------------------------------------------------------------
visualize ();
popMatrix();
cam.beginHUD();
noLights();
menu ();
calGUI ();
if (showGUI == true)
{
showGUI ();
GUIEvent ();
}
mouseIsReleased = false;
cam.endHUD();
}
void rotation ()
{
if (mousePressed == false)
{
if (doRotateTwo == true) rotation += 0.4;
if (doRotateOne == true)
{
rotation -= 1;
rotationX += 0.1;
rotationY += 0.05;
rotationZ += 0.025;
}
}
if (rotation >= 360) rotation = 0;
if (rotationX >= 360) rotationX = 0;
if (rotationY >= 360) rotationY = 0;
if (rotationZ >= 360) rotationZ = 0;
}
void setupPresets ()
{
// Presets--------------------------------------------------------------------
actRandomSeed = 5;
actNoiseSeed = 2;
timeSeed = 0;
radiusAmount = 20;
dotsPerRadius = 300;
startRadius = 10;
randomZPos = 0;
noiseRadius = 280;
noiseZ = 50;
zFactor = 1;
aFill = 180;
aStroke = 60;
colorAmount = 12;
changingColors = 50;
shininessAmount =4;
setupDotList ();
createRadius ();
colors();
createGUIPosition ();
}
void setupLight ()
{
lightX = 0;
lightY = 0;
lightZ = 0;
createGUIPosition ();
}
void setupRotation ()
{
rotation = 0;
rotationX = 0;
rotationY = 0;
rotationZ = 0;
}
void minMax ()
{
aStroke = constrain(aStroke, 0,alphaMax);
aFill = constrain (aFill, 0,alphaMax);
startRadius = constrain (startRadius, minRadiusSize, maxRadiusSize);
noiseRadius = constrain (noiseRadius,1,radiusNoiseMax);
noiseZ = constrain (noiseZ,1,noiseZMax);
randomZPos = constrain (randomZPos,0,randomSpacingMax);
radiusAmount = constrain (radiusAmount, radiusMin,radiusMax);
dotsPerRadius = constrain (dotsPerRadius, dotsMin,dotsMax);
zFactor = constrain (zFactor,0,zMax);
colorAmount = constrain (colorAmount, colorMin,colorMax);
changingColors = constrain (changingColors, colorMin,colorChangingMax);
}
void visualize ()
{
int count = 0;
int radiusCount = 0;
int dotsPerRadiusCount = 0;
int radiusMax = radiusAmount;
int dotsPerRadiusMax = dotsPerRadius;
PVector checkDotLeft, checkDotRight, checkDotLeftR, checkDotRightR, firstDot = dotList [0], firstDotR = dotList [0];
randomSeed (actRandomSeed);
noStroke();
//beginShape ();
while (radiusCount < radiusMax)
{
dotsPerRadiusCount = 0;
float colorCounter = 0;
int randomColor = int ( random(colorList.length));
color fillColor = color (colorList [randomColor]);
while (dotsPerRadiusCount < dotsPerRadiusMax)
{
int nextDot = count +1;
int nextRadius = dotsPerRadius;
checkDotLeft = dotList [count];
checkDotRight = dotList [count];
checkDotLeftR = dotList [count];
checkDotRightR = dotList [count];
if (dotsPerRadiusCount < dotsPerRadius-1)
{
checkDotRight = dotList [count+1];
}
if (radiusCount < radiusMax-1)
{
checkDotLeftR = dotList [count+dotsPerRadius];
if (dotsPerRadiusCount == 0)
{
firstDot = dotList [count];
firstDotR = dotList [count+dotsPerRadius];
}
if (dotsPerRadiusCount < dotsPerRadius-1)
{
checkDotRightR = dotList [count+dotsPerRadius+1];
}
}
if (dotsPerRadiusCount >= dotsPerRadius-1)
{
checkDotRight = firstDot;
checkDotRightR = firstDotR;
}
float x1 = (checkDotLeft.x), y1 = (checkDotLeft.y), z1 = (checkDotLeft.z)*zFactor;
float x2 = (checkDotRight.x), y2 = (checkDotRight.y), z2 = (checkDotRight.z)*zFactor;
float x3 = (checkDotRightR.x), y3 = (checkDotRightR.y), z3 = (checkDotRightR.z)*zFactor;
float x4 = (checkDotLeftR.x), y4 = (checkDotLeftR.y), z4 = (checkDotLeftR.z)*zFactor;
if (radiusCount < radiusMax-1)
{
beginShape ();
if (showFill == true)
{
fill (fillColor,aFill);
noStroke ();
}
else if (showFill == false)
{
strokeWeight (0.5);
noFill ();
if (changeBG == true) stroke (0,0,97, aStroke);
else stroke (0,0,5, aStroke);
}
vertex (x1,y1,z1);
vertex (x2,y2,z2);
vertex (x3,y3,z3);
vertex (x4,y4,z4);
endShape();
}
dotsPerRadiusCount++;
colorCounter+= random (0.15, 5);
if (colorCounter >= changingColors)
{
colorCounter = 0;
randomColor = int ( random(colorList.length));
fillColor = color (colorList [randomColor]);
}
count++;
}
radiusCount++;
}
//endShape();
}
Improved version. I've added the GUI and some controls. Use PeasyCam for drag and drop, as usual.
Type doesn't look that good using P3D and loadFont. Better use OPENGL and createFont.
Please have a look at the video:
http://www.vimeo.com/16614423