package com.haxademic.sketch.test;

import com.haxademic.core.app.PAppletHax;
import com.haxademic.core.constants.AppSettings;
import com.haxademic.core.draw.image.ImageSequenceMovieClip;
import com.haxademic.core.file.FileUtil;

import processing.core.PImage;

public class ImageSequenceMovieClipTest
extends PAppletHax {
	public static void main(String args[]) { PAppletHax.main(Thread.currentThread().getStackTrace()[1].getClassName()); }
	
	protected ImageSequenceMovieClip imageSequence;

	protected void overridePropsFile() {
		p.appConfig.setProperty( AppSettings.WIDTH, 1344 );
		p.appConfig.setProperty( AppSettings.HEIGHT, 600 );
		p.appConfig.setProperty( AppSettings.FULLSCREEN, false );
		p.appConfig.setProperty( AppSettings.SMOOTHING, AppSettings.SMOOTH_HIGH );
		p.appConfig.setProperty( AppSettings.RETINA, false );
	}

	public void setup() {
		super.setup();
		
		String imagePath = FileUtil.getFile("images/floaty-blob.anim/"); // File.separator
		imageSequence = new ImageSequenceMovieClip(imagePath, "png", 18);
	}
	
	public void drawApp() {
		p.background(0);
		
		imageSequence.preCacheImages();
		if(p.frameCount == 100) imageSequence.play();
		
		imageSequence.update();
		PImage frameImg = (imageSequence.isPlaying() == true) ? imageSequence.image() : imageSequence.getFrame(imageSequence.numImageFiles() - 1);
		p.image(frameImg, 0, 0);
		p.text(""+imageSequence.isFinished(), 20, 20);
	}
	
}

@@ -19,19 +19,23 @@
 mic.
-sketch.test
+demo.draw.image
 ;%0A%0Ai
@@ -272,16 +272,21 @@
 c class 
+Demo_
 ImageSeq
@@ -303,12 +303,8 @@
 Clip
-Test
 %0Aext
@@ -742,96 +742,22 @@
 gs.S
-MOOTHING, AppSettings.SMOOTH_HIGH );%0A%09%09p.appConfig.setProperty( AppSettings.RETINA, fals
+HOW_DEBUG, tru
 e );
@@ -783,32 +783,22 @@
 etup
-() %7B%0A%09%09super.setup();%0A%09%09
+FirstFrame() %7B
 %0A%09%09S
@@ -864,26 +864,8 @@
 /%22);
- // File.separator
 %0A%09%09i
@@ -985,42 +985,8 @@
 %0A%09%09%0A
-%09%09imageSequence.preCacheImages();%0A
 %09%09if
@@ -1003,13 +1003,18 @@
 unt 
+%25 100 
 == 
-10
+5
 0) i
@@ -1034,19 +1034,16 @@
 play();%0A
-%09%09%0A
 %09%09imageS
@@ -1054,123 +1054,119 @@
 nce.
-update();%0A%09%09PImage frameImg = (imageSequence.isPlaying() == true) ? imageSequence.image() : imageSequence.getFram
+preCacheImages();%0A%09%09imageSequence.update();%0A%09%09%0A%09%09p.image(imageSequence.image(), 0, 0);%0A%09%09p.debugView.setValu
 e(
+%22
 imag
@@ -1179,69 +1179,23 @@
 nce.
-numImageFiles() - 1);%0A%09%09p.image(frameImg, 0, 0);%0A%09%09p.text(%22%22+
+isFinished()%22, 
 imag
@@ -1220,16 +1220,8 @@
 ed()
-, 20, 20
 );%0A%09

Clean up demo