Do the same for this code. Don’t remove my comments, only improve them
// VERY VERY BAD
//int a = 50;
//int a2 = 51;
//int a3 = 54;
//int a4 = 55;
//int a5 = 56;
//int a6 = 57;
int[] myArray = new int[4];
float[] myFloats;
boolean[] myBooleans;
boolean a;
void settings()
{
size(myArray.length * 50, myArray.length * 50);
}
void setup()
{
// LAST ELEMENT
// myArray[myArray.length - 1];
//println(“EMPTY ARRAY\n-------------\n”);
//for (int i = 0; i < myArray.length; i++)
//{
// Message(myArray, i);
//}
for (int i = 0; i < myArray.length; i++)
{
myArray[i] = i * 50;
}
//println(“\nFULL ARRAY\n-------------\n”);
//for (int i = 0; i < myArray.length; i++)
//{
// Message(myArray, i);
//}
}
void draw()
{
// clean the whole screen with a white rectangle
fill(255);
noStroke();
blendMode(BLEND);
rect(0, 0, width, height);
stroke(0);
// We know that mouseX ranges from 0 (left side of the canvas)
// to width (right side of the canvas).
// We want our multiplier to range from 1 to 10
// Therefore we re-map mouseX using (0,width) as the start range
// and (1,10) as the target range
float multiplier = map(mouseX, 0, width, 1, 10);
blendMode(MULTIPLY);
//for (int i = 0; i < myArray.length; i++)
//{
// // Here we remap the i value, from the length of the array
// // whatever that is,
// // to the (0,255) range, which represents (black, white)
// //float col = map(i, 0, myArray.length, 0, 255);
// //fill(col);
// circle(myArray[i], height/2, multiplier*i);
//}
for (int i = 0; i < myArray.length; i++)
{
// Here we remap the i value, from the length of the array
// whatever that is,
// to the (0,255) range, which represents (black, white)
// float col = map(i, 0, myArray.length, 0, 255);
// fill(col);
for (int j = 0; j<myArray.length; j++)
circle(x, y , multiplier*i);
}
}
void Message(int[] array, int index)
{
println(“Index ” + index + ”: ” + array[index]);
}