Skip to content

Commit

Permalink
feat: scales breathe now
Browse files Browse the repository at this point in the history
  • Loading branch information
gar354 committed Oct 6, 2023
1 parent ad75819 commit 318553c
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions Scales.pde
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
// feel free to change these!
int rows = 10;
int columns = 10;
float shapeLength = 60.0;
float spacing = 59.0;
float increment = .006;
int rows = 20;
int columns = 20;
float minLength = 200.0;
float maxLength = 100.0;
float increment = .01;
float alpha = 240.0;
// =========================
int xSize;
int ySize;
float currentshapeLength;
float time = 0.0;
int timeOffset = 0;
color shapeColor = color(0, 0, 0);
color targetColor = color(0, 0, 0);
int offset = 0;

float currentLength = minLength;
float lengthDiv = currentLength / 2;
void setup() {
offset = (int)spacing / 2;
offset = (int)minLength / 2;
xSize = offset * columns;
ySize = offset * rows;
surface.setSize(xSize, ySize);
Expand All @@ -24,11 +25,16 @@ void setup() {

void draw() {
background(255);
lengthDiv = currentLength / 2;
for (int y = 0; y < rows; y++) {
int flippedY = rows - y - 1;
for (int x = 0; x < columns; x++) {
scale(x * offset + offset / 2, flippedY * offset + offset / 2);
scale(x * lengthDiv, flippedY * lengthDiv);
}
time += increment;
float weight = ((cos(time) + 1) / 2);
alpha = ceil(lerp(255.0, 0.0, weight));
currentLength = ceil(lerp(minLength, maxLength, weight));
}
incrementColor();
if (millis() - timeOffset > 1000) { // change color every second
Expand All @@ -38,14 +44,9 @@ void draw() {
}

void scale(float x, float y) {
fill(shapeColor, alpha);
// draw diamond shape
beginShape();
vertex(x, y - offset);
vertex(x - offset, y - offset);
vertex(x, y + offset);
vertex(x + offset, y - offset);
endShape();
fill(shapeColor, alpha);
ellipse(x, y + lengthDiv, currentLength, currentLength);
rect(x - lengthDiv * 0.5, y - lengthDiv * 0.5, lengthDiv, lengthDiv);
}

void mousePressed() {
Expand Down

0 comments on commit 318553c

Please sign in to comment.