Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- color bg = #ECD078;
- color cs =#D95B43, cm = #C02942, cl=#542437 ;
- float div_m, div_s, div_l;
- myRect[] s_rects = {
- };
- myRect[] m_rects = {
- };
- myRect[] l_rects = {
- };
- void setup() {
- size(500, 400);
- background(bg);
- stroke(0);
- rectMode(CENTER);
- float sz;
- float theta = 0;
- div_s = 16;
- div_m = 11;
- div_l = 6;
- for (int i=1; i < div_s; i++) {
- sz = width/div_s;
- myRect s_rect = new myRect(float(i), sz, theta, cs);
- s_rects = (myRect[])append(s_rects, s_rect);
- theta += TAU/div_s;
- }
- for (int i=1; i < div_m; i++) {
- sz = width/div_m;
- myRect m_rect = new myRect(float(i), sz, theta, cm);
- m_rects = (myRect[])append(m_rects, m_rect);
- theta += TAU/div_m;
- }
- for (int i=1; i < div_l; i++) {
- sz = width/div_l;
- myRect l_rect = new myRect(float(i), sz, theta, cl);
- l_rects = (myRect[])append(l_rects, l_rect);
- theta += TAU/div_l;
- }
- }
- void draw() {
- background(bg);
- for (int i=0; i < l_rects.length; i++) {
- l_rects[i].display();
- }
- for (int i=0; i < m_rects.length; i++) {
- m_rects[i].display();
- }
- for (int i=0; i < s_rects.length; i++) {
- s_rects[i].display();
- }
- }
- class myRect {
- float sz_x, sz_y, x, y;
- float i, theta;
- color col;
- myRect(float _i, float _sz, float _theta, color _col) {
- y = height/2;
- sz_x = _sz;
- i = _i;
- theta = _theta;
- col = _col;
- }
- void display() {
- fill(col);
- strokeWeight(2);
- stroke(#ffffff);
- x = i * sz_x;
- sz_y = map(sin(theta), -1, 1, sz_x, sz_x*1.7);
- rect(x, y, sz_x, sz_y);
- theta -= 0.07;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement