nfg_functions


 * See examples for ideas on how to use these.

code boolean hitDetect(float x1, float y1, float w1, float h1, float x2, float y2, float w2, float h2) { w1 /= 2; h1 /= 2; w2 /= 2; h2 /= 2; if(x1 + w1 >= x2 - w2 && x1 - w1 <= x2 + w2 && y1 + h1 >= y2 - h2 && y1 - h1 <= y2 + h2) { return true; } else { return false; } } code
 * Hit Detect**

code float tween(float v1, float v2, float e) { v1 += (v2-v1)/e; return v1; }
 * Tween**

code

code void blender(PImage p, float x, float y, String s){ int blendMode = 0; String[] blendModes = { "BLEND", "ADD", "SUBTRACT", "LIGHTEST", "DARKEST", "DIFFERENCE", "EXCLUSION", "MULTIPLY", "SCREEN", "OVERLAY", "HARD_LIGHT", "SOFT_LIGHT", "DODGE", "BURN" }; int[] blendModeCodes = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 };  for(int i=0;i<blendModes.length;i++){ if(s==blendModes[i]){ blendMode = blendModeCodes[i]; } }  blend(p,0,0,p.width,p.height,int(x)-(p.width/2),int(y)-(p.height/2),p.width,p.height,blendMode); } code
 * Blend Modes**