saveFrame() only capturing Background Image
              in 
             Programming Questions 
              •  
              7 months ago    
            
 
           
             I'm having an issue with background image, when I save a frame. The background image is all that shows.
            
             
            
            
              
           
 
            
           
             The saveframe() works fine when I use a plain white background though.
            
            - import ddf.minim.*;
 - import ddf.minim.analysis.*;
 - PFont font;
 - PImage bg;
 - final static byte FPS = 60;
 - final static int maxDots = 300;
 - final static int maxCircles = 4;
 - final static int maxCircleSize = 1200;
 - final static ArrayList<PVector> dotList = new ArrayList<PVector>();
 - final static ArrayList<PVector> targetPosList = new ArrayList<PVector>();
 - final static ArrayList<PVector> currentPos = new ArrayList<PVector>();
 - final static ArrayList<PVector> circleList = new ArrayList<PVector>();
 - final static ArrayList<PVector> targetCircleList = new ArrayList<PVector>();
 - final static ArrayList<PVector> circleCurrentPos = new ArrayList<PVector>();
 - float distance;
 - Minim minim;
 - AudioPlayer player;
 - BeatDetect beat;
 - FFT fft;
 - void setup() {
 - bg = loadImage("gradient.jpg");
 - size(displayWidth, displayHeight, OPENGL);
 - smooth(4);
 - noCursor();
 - frameRate(FPS);
 - minim = new Minim(this);
 - player = minim.loadFile("testmp3.mp3");
 - player.play();
 - fft = new FFT(player.bufferSize(), player.sampleRate());
 - fft.logAverages(60, 7);
 - font = loadFont("AktivGrotesk-Bold-48.vlw");
 - textFont(font, 32);
 - for (int i = 0; i < maxCircles ; i++) {
 - circleList.add (new PVector( random(0, width), random(0, height), random(600, maxCircleSize) ));
 - circleCurrentPos.add(new PVector( circleList.get(circleList.size()-1).x, circleList.get(circleList.size()-1).y));
 - targetCircleList.add (new PVector( random(0, width), random(0, height) ));
 - }
 - }
 - boolean sketchFullScreen() {
 - return true;
 - }
 - void connectPoints()
 - {
 - stroke(0, 40);
 - strokeWeight(1.75);
 - for (int i = dotList.size()-1; i > 0; i--) {
 - for (int z = dotList.size()-1; z > 0; z--) {
 - distance = dist(currentPos.get(i).x, currentPos.get(i).y, currentPos.get(z).x, currentPos.get(z).y);
 - if (distance < 70) {
 - line(currentPos.get(i).x, currentPos.get(i).y, currentPos.get(z).x, currentPos.get(z).y);
 - }
 - }
 - }
 - }
 - void draw() {
 - background(bg);
 - fill(255);
 - text("I Giorni - Ludivico Einaudi", 30, height - 45);
 - fft.forward(player.mix);
 - int dotAmount = round(constrain(map(fft.getAvg(15), 0, 20, 0, maxDots), 0, maxDots));
 - float circleSize = map(fft.getAvg(4), 0, 20, 0.94, 1);
 - float circleAlpha = constrain(map(fft.getAvg(4), 0, 20, 7, 20), 0, 20);
 - int circleAmount = round(constrain(map(fft.getAvg(4), 0, 3, 0, maxCircles), 0, maxCircles));
 - int amt = dotAmount/maxDots;
 - float speedMagnitude = lerp(0.0006, 0.0024, amt);
 - for (int i = dotList.size()-1; i > 0; i--) {
 - currentPos.get(i).x = currentPos.get(i).x + (dotList.get(i).x - targetPosList.get(i).x)*speedMagnitude;
 - currentPos.get(i).y = currentPos.get(i).y + (dotList.get(i).y - targetPosList.get(i).y)*speedMagnitude;
 - // point(currentPos.get(i).x, currentPos.get(i).y );
 - }
 - for (int i = circleList.size()-1; i > 0; i--) {
 - stroke(0, 0);
 - fill(0, circleAlpha);
 - circleCurrentPos.get(i).x = circleCurrentPos.get(i).x + (circleList.get(i).x - targetCircleList.get(i).x)*(speedMagnitude/4);
 - circleCurrentPos.get(i).y = circleCurrentPos.get(i).y + (circleList.get(i).y - targetCircleList.get(i).y)*(speedMagnitude/4);
 - ellipse(circleCurrentPos.get(i).x, circleCurrentPos.get(i).y, circleList.get(i).z*circleSize, circleList.get(i).z*circleSize);
 - }
 - connectPoints();
 - for (int i = dotList.size()-1; i > 0; i--) {
 - if (
 - currentPos.get(i).x > width ||
 - currentPos.get(i).x < 0 ||
 - currentPos.get(i).y > height ||
 - currentPos.get(i).y < 0) {
 - currentPos.remove(i);
 - dotList.remove(i);
 - targetPosList.remove(i);
 - }
 - }
 - for (int i = circleList.size()-1; i > 0; i--) {
 - if (
 - circleCurrentPos.get(i).x > width+1400 ||
 - circleCurrentPos.get(i).x < 0-1400 ||
 - circleCurrentPos.get(i).y > height+1400 ||
 - circleCurrentPos.get(i).y < 0-1400) {
 - circleCurrentPos.remove(i);
 - circleList.remove(i);
 - targetCircleList.remove(i);
 - circleList.add (new PVector( dotList.get(i).x, dotList.get(i).y, random(400, maxCircleSize) ));
 - circleCurrentPos.add(new PVector( dotList.get(dotList.size()-1).x, dotList.get(dotList.size()-1).y));
 - targetCircleList.add (new PVector( targetPosList.get(i).x, targetPosList.get(i).y ));
 - }
 - }
 - int dotsDifference = dotAmount - dotList.size();
 - int circleDifference = circleAmount - circleList.size();
 - for (int i = 0; i < dotsDifference; i++) {
 - dotList.add (new PVector( random(0, width), random(0, height) ));
 - currentPos.add(new PVector( dotList.get(dotList.size()-1).x, dotList.get(dotList.size()-1).y));
 - targetPosList.add (new PVector( random(width), random(height) ));
 - }
 - for(int i = 0; i < player.bufferSize() - 1; i++)
 - {
 - strokeWeight(6);
 - stroke(255, 100);
 - float x1 = map(i, 0, player.bufferSize(), 0, width);
 - float x2 = map(i+1, 0, player.bufferSize(), 0, width);
 - line(x1, (height/2) + player.mix.get(i)*50, x2, (height/2) + player.left.get(i+1)*50);
 - }
 - }
 - void mousePressed() {
 - saveFrame("output-####.tga");
 - }
 
 
              
              1  
            
 
            