Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PGraphics cubeA, cubeB;
- float theta, alphaA, alphaB,sz;
- int frames = 240;
- void setup() {
- size(500, 500, P3D);
- //smooth(8);
- cubeA = createGraphics(250, 250, P3D);
- cubeB = createGraphics(250, 250, P3D);
- background(0);
- }
- void draw() {
- background(0);
- drawCubeA();
- drawCubeB();
- alphaA = map(sin(theta), -1, 1, 50, 255);
- alphaB = map(sin(theta+PI), -1, 1, 50, 255);
- sz = map(sin(theta), -1, 1, .5, 1);
- for (int x=0; x<width; x+=cubeA.width) {
- for (int y=0; y<height; y+=cubeA.height) {
- tint(255, alphaA);
- image(cubeA, x, y);
- tint(255, alphaB);
- image(cubeB, x, y);
- }
- }
- theta += TWO_PI/frames;
- //if (frameCount<=frames) saveFrame("image-###.png");
- }
- void drawCubeA() {
- cubeA.beginDraw();
- cubeA.lights();
- cubeA.background(0);
- cubeA.noStroke();
- //cubeA.fill(255,0,0);
- cubeA.pushMatrix();
- cubeA.translate(cubeA.width/2, cubeA.height/2);
- cubeA.rotateX(theta*2);
- cubeA.rotateY(theta*1);
- cubeA.box(cubeA.width*.5);
- cubeA.popMatrix();
- cubeA.endDraw();
- }
- void drawCubeB() {
- cubeB.beginDraw();
- cubeB.lights();
- cubeB.background(0);
- cubeB.noStroke();
- //cubeB.fill(255,255,0);
- cubeB.pushMatrix();
- cubeB.translate(cubeB.width/2, cubeB.height/2);
- cubeB.rotateX(PI+theta*1);
- cubeB.rotateY(theta*2);
- cubeB.box(cubeB.width/2);
- cubeB.popMatrix();
- cubeB.endDraw();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement