package com.haxademic.demo.draw.filters.shaders;

import com.haxademic.core.app.PAppletHax;
import com.haxademic.core.app.config.AppSettings;
import com.haxademic.core.app.config.Config;
import com.haxademic.core.draw.filters.pshader.SaturateHSVFilter;
import com.haxademic.core.draw.filters.pshader.SaturationFilter;
import com.haxademic.core.draw.image.ImageUtil;
import com.haxademic.core.hardware.mouse.Mouse;
import com.haxademic.core.media.DemoAssets;

public class Demo_Saturate
extends PAppletHax {
	public static void main(String args[]) { arguments = args; PAppletHax.main(Thread.currentThread().getStackTrace()[1].getClassName()); }

	protected void config() {
		Config.setProperty( AppSettings.WIDTH, 800 );
		Config.setProperty( AppSettings.HEIGHT, 800 );
	}

	protected void drawApp() {
		p.background(0);
		ImageUtil.drawImageCropFill(DemoAssets.squareTexture(), p.g, true);
		
		// use old saturation for < 1, and HSV saturation for > 1
		float saturate = Mouse.yNorm * 3f;
		if(saturate < 1f) {
			SaturationFilter.instance().setSaturation(saturate);
			SaturationFilter.instance().applyTo(p.g);
		} else {
			SaturateHSVFilter.instance().setSaturation(saturate);
			SaturateHSVFilter.instance().applyTo(p.g);
		}
	}

}
