Mike and I expanded on my Highlights project last week and came up with this. I’m still not sure why it’s taking so long to play.
//global variables
int ballWidth = 10;
Circle myCircle;
Circle circle2;
void setup()
{
size (600, 600);
smooth();
background(0);
//frameRate(30);
myCircle = new Circle(10, 400, 10);
circle2 = new Circle(590, 200, 10);
}
void draw()
{
background(0);
//draw colored balls
for (int i=0; i * ballWidth < width; i++)
{
for (int a=0; a * ballWidth < height; a++)
{
int ballX = ballWidth*i + ballWidth/2;
int ballY = ballWidth*a + ballWidth/2;
fill(map(ballX,0,width, 0,255), frameCount, map(ballY, 0, height, 0, 255));
ellipse(ballX, ballY, ballWidth, ballWidth);
}
}
//determine coordinates of the highlights
/*float column = random(0, width/ballWidth);
int newColumn = int(column);
int randomX = newColumn * ballWidth+ ballWidth/2;
float columnY = random(0, height/ballWidth);
int newColumnY = int(columnY);
int randomY = newColumnY * ballWidth + ballWidth/2;*/
//draw highlights
//drawHighlight(randomX, randomY);
//drawHorizontalHighlight(randomX, randomY);
myCircle.moveIt();
myCircle.showIt();
drawHighlight(myCircle.x, myCircle.y);
drawHorizontalHighlight(myCircle.x, myCircle.y);
circle2.moveIt();
circle2.showIt();
drawHighlight(circle2.x, circle2.y);
drawHorizontalHighlight(circle2.x, circle2.y);
}//end draw
void drawHighlight (int _x, int _y)
{
for (int d=0; d*ballWidth <= width; d++)
{
//bottom spoke
fill(255, 255, 255, 100);
ellipse(_x, _y+ d*ballWidth, ballWidth, ballWidth);
fill(255, 255, 255, 70);
ellipse(_x + ballWidth, _y+ d*ballWidth, ballWidth, ballWidth);
ellipse(_x - ballWidth, _y+ d*ballWidth, ballWidth, ballWidth);
fill(255, 255, 255, 40);
ellipse(_x + 2*ballWidth, _y+ d*ballWidth, ballWidth, ballWidth);
ellipse(_x - 2*ballWidth, _y+ d*ballWidth, ballWidth, ballWidth);
}
for (int d=0; d*ballWidth <= width; d++)
{
//top spoke
fill(255, 255, 255, 100);
ellipse(_x, _y- d*ballWidth, ballWidth, ballWidth);
fill(255, 255, 255, 70);
ellipse(_x + ballWidth, _y- d*ballWidth, ballWidth, ballWidth);
ellipse(_x - ballWidth, _y- d*ballWidth, ballWidth, ballWidth);
fill(255, 255, 255, 40);
ellipse(_x + 2*ballWidth, _y- d*ballWidth, ballWidth, ballWidth);
ellipse(_x - 2*ballWidth, _y- d*ballWidth, ballWidth, ballWidth);
}
}//end drawHighlight
void drawHorizontalHighlight (int _x, int _y)
{
for (int d=0; d*ballWidth <= height; d++)
{
//left spoke
fill(255, 255, 255, 100);
ellipse(_x +d*ballWidth, _y, ballWidth, ballWidth);
fill(255, 255, 255, 70);
ellipse(_x + d*ballWidth, _y+ ballWidth, ballWidth, ballWidth);
ellipse(_x + d*ballWidth, _y- ballWidth, ballWidth, ballWidth);
fill(255, 255, 255, 40);
ellipse(_x + d*ballWidth, _y+ 2*ballWidth, ballWidth, ballWidth);
ellipse(_x + d*ballWidth, _y- 2*ballWidth, ballWidth, ballWidth);
}
for (int d=0; d*ballWidth <= height; d++)
{
//right spoke
fill(255, 255, 255, 100);
ellipse(_x - d*ballWidth, _y, ballWidth, ballWidth);
fill(255, 255, 255, 70);
ellipse(_x - d*ballWidth, _y + ballWidth, ballWidth, ballWidth);
ellipse(_x - d*ballWidth, _y- ballWidth, ballWidth, ballWidth);
fill(255, 255, 255, 40);
ellipse(_x - d*ballWidth, _y+ 2*ballWidth, ballWidth, ballWidth);
ellipse(_x - d*ballWidth, _y- 2*ballWidth, ballWidth, ballWidth);
}
}//end drawHorizontalHighlight
// Cirlce Class
class Circle
{
int x;
int y;
int xSpeed = 30;
int ySpeed = 30;
int circleSize;
color circleColor;
Circle(int _x, int _y, int _size)
{
x = _x + 5;
y = _y + 5;
circleSize = _size;
//circleColor = color(random(255));
circleColor = 255;
}
void moveIt()
{
x = x + xSpeed;
y = y + ySpeed;
if (x > width || x < 0)
{
xSpeed = xSpeed * -1;
}
if (y > height || y < 0)
{
ySpeed = ySpeed * -1;
}
}
void showIt()
{
fill(circleColor);
ellipse(x, y, circleSize, circleSize);
}
}