Applying the same texture to multiple shapes
in
Core Library Questions
•
1 month ago
Is this possible? I figured it would save memory but it doesn't seem to work. I can easily just make multiple texture variables but then I'd have to load the same movie 3 times... anyway I'm sure this is possible, here's what I have so far-
- import processing.video.*;
- Movie waves;
- float radius, step;
- int points, numShapes;
- void setup() {
- size(1280, 720, P2D);
- background(0);
- waves = new Movie(this, "kaleida.mov");
- waves.loop();
- radius = 200;
- points = 3;
- shapes = 3;
- step = TAU / points;
- }
- void draw() {
- background(0);
- for(int h = 0; h < numShapes; h++){
- pushMatrix();
- stroke(255);
- strokeWeight(2);
- translate(width/2, height/2);
- textureMode(NORMAL);
- beginShape();
- texture(waves);
- rotate(h*45);
- for (int i = 0; i < points+1; i++) {
- float theta = step * i;
- float x = (cos(theta) * radius) + radius;
- float y = (sin(theta) * radius) + radius;
- float tx = x/waves.width+0.5;
- float ty = y/waves.height+0.5;
- vertex(x, y, tx, ty);
- }
- endShape();
- popMatrix();
- }
- frame.setTitle(int(frameRate) + " fps");
- }
- void movieEvent(Movie m) {
- m.read();
- }
1