Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int r = 50;
- void setup() {
- size(600, 600);
- }
- void draw() {
- background(-1);
- fill(0);
- for (int i = -1; i <= height/r; i++) {
- pushMatrix();
- translate(0, i*r);
- triangleWave();
- popMatrix();
- }
- }
- void triangleWave() {
- for (int j = 0; j < width; j+=10) {
- float x = j;
- float angle = 10*PI*j/width;
- float y = r*sin(angle + radians(frameCount));
- triangle(x, y);
- }
- }
- void triangle(float x, float y) {
- pushMatrix();
- translate(x, y);
- beginShape();
- int side_num = 3;
- for (int i = 0; i < side_num; i++) {
- float newR = map(abs(y), r, 0, 5, r/3);
- float pointX = newR * sin(i*TWO_PI/side_num + PI);
- float pointY = newR * cos(i*TWO_PI/side_num + PI);
- vertex(pointX, pointY);
- }
- endShape(CLOSE);
- popMatrix();
- }
Add Comment
Please, Sign In to add comment