package com.haxademic.demo.math;

import com.haxademic.core.app.P;
import com.haxademic.core.app.PAppletHax;
import com.haxademic.core.constants.AppSettings;
import com.haxademic.core.draw.context.DrawUtil;
import com.haxademic.core.draw.image.ImageUtil;
import com.haxademic.core.file.FileUtil;
import com.haxademic.core.math.MathUtil;

import processing.core.PGraphics;
import processing.core.PImage;

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

	PImage img;
	PGraphics pg;


	protected void overridePropsFile() {
		p.appConfig.setProperty( AppSettings.WIDTH, 640 );
		p.appConfig.setProperty( AppSettings.HEIGHT, 640 );
		p.appConfig.setProperty( AppSettings.SHOW_DEBUG, true );
	}

	public void setup() {
		super.setup();
		img = p.loadImage(FileUtil.getFile("images/smiley-big.png"));
		pg = ImageUtil.imageToGraphics(img);
	}

	public void drawApp() {
		background(100,100,255);
		p.pushMatrix();
		DrawUtil.setDrawCenter(p);
		p.translate(p.width/2, p.height/2);
		float radsFromCenter = MathUtil.getRadiansToTarget(p.width/2, p.height/2, p.mouseX, p.mouseY);
		p.debugView.setHelpLine("cos (x)", ""+P.cos(radsFromCenter));
		p.debugView.setHelpLine("sin (y)", ""+P.sin(radsFromCenter));
		p.debugView.setHelpLine("angle", ""+MathUtil.radiansToDegrees(radsFromCenter));

		float radsFromMouse = MathUtil.getRadiansToTarget(p.mouseX, p.mouseY, p.width/2, p.height/2);
		p.rotate(-radsFromCenter);
		p.image(pg, 0, 0);
		p.popMatrix();
	}

}


@@ -279,24 +279,26 @@
 re.file.
-FileUtil
+DemoAssets
 ;%0Aimport
@@ -370,39 +370,8 @@
 ics;
-%0Aimport processing.core.PImage;
 %0A%0Apu
@@ -559,21 +559,8 @@
  %7D%0A%0A
-%09PImage img;%0A
 %09PGr
@@ -571,17 +571,16 @@
 cs pg;%0A%0A
-%0A
 %09protect
@@ -823,72 +823,8 @@
 ();%0A
-%09%09img = p.loadImage(FileUtil.getFile(%22images/smiley-big.png%22));%0A
 %09%09pg
@@ -856,11 +856,33 @@
 ics(
-img
+DemoAssets.smallTexture()
 );%0A%09
@@ -1333,104 +1333,8 @@
 );%0A%0A
-%09%09float radsFromMouse = MathUtil.getRadiansToTarget(p.mouseX, p.mouseY, p.width/2, p.height/2);%0A
 %09%09p.

Clean up demo