Code

<pre><code> ----------begin_max5_patcher---------- 796.3ocyWEsaaBCE8YxWAxR6MFx1fCDdaeGUSUFvo0sfIBLcYqp+6CaGnzFf R6XInHPx12Xetm64d8km2XAhKNxp.1Q12XaY87FKK8TpIrNM1BjSOljQqzlA DreUD+.vwrjjcTpmNonVHYk1P6v10JpkYLo72GXl8GvERfiMn8QMz9mmLVTm arWeJ9ml8.UlbOWb2skrDoYWvdXWnismu5cfm5MF5B61HdpFOMX76jVjruPH EzbMN.+njSy5uRE+O5UPpMtCMbQKXHp4dYyF0KmYxR4rpJ5crynIuQImwnBz TTwNk6ifZtf.0CBGlK7WFt.+E3B8+dI8aOjVA3RZB8Ds.fLrSiAC4CsNVRQd NSXhKfufeY.KXPzCmHpYhS96ZQ933GMH9QKD9GSiFtjwJerKBSfaQN1glDWr JtMlLEStd5zw3Czhly55iCI3v4QGnqHcT2HtpmUs7QXAuYoJPHhlAfvoJk6E 7wDwAZYy7MWBcKSPiyX8yCynwrrjLdxi8iOiPcbIK+zch.l.o7QG0qrB3a70 dojKobq4RMLo4A44F.WRsGIzk.gFVmDnqBEXX8fdr9gRVUSYEpjWH5ug8hFg AeNYotj246dOngPcBB8kYXD5Lf8OqnGo0krBZZLUb2nTsdwOOcifnN9VeY01 Ik3aCVlbczJKWuOMzn.0MrraRh.ckx0wawvHDjDECgwQAgPXjONIBSIrHOrW XTr+9WqFLf0XbxtnT398Q6YLXTJgR5LeOKDFY9MfYeyuyv2k+ubEbFQ9me7A aAS5lUj7J+dd4lIB93YlCfTIAgASF68W9j.84.x3h2+gNZ7pl+sjVUQcYRqe epMR6WQaJqRxEckGuo6aM5Yy87zTlnunLkWozoZOENXvatngLCznRgtPv4cG 0v3QotQWD3ntZ5CgyEjclCbTh90Dd7BVW3ASVW3AcAwi+JKa+sYxWe8CZF3I bMhmKS4PufYfmKX8GLYcU+A8e81TSmGzCGdhUVcZO0PoowrGJJUC25nGxElg 5tUAkrm3s1aLfV1zYkrosp5RSGQGC2B1nNmW17W.xGq6MA -----------end_max5_patcher----------- </code></pre>

Nexus Examples: some HTML code for NexusUI interfaces

</pre>

<!doctype html>
<html>
	<head>
		<title>Projection/Misrepresentation</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
		<script src="jquery.js" type="text/javascript"></script>
		<script src="nexusUI.js" type="text/javascript"></script>
	</head>
	<body>

		<style>

			body {
				background-color:#000;
			}
			p {
				color:#2cf;
			}
			.mess {
				width:100px;
				height:30px;
			}

			.sideways {

				transform:rotate(90deg);
				-ms-transform:rotate(90deg); /* IE 9 */
				-webkit-transform:rotate(90deg); /* Safari and Chrome */
				display:inline-block;
			}

		</style>

		<script>

			nx.onload = function() {
				nx.colorize("#2cf");
				nx.colorize("fill", "#554");
				nx.colorize("black", "#ddd");
			//	nx.colorize("white", "#113");

				nx.setTransmissionProtocol("ajax");
				nx.setTransmitCommand("nexusOSCRelay.php");
			}

		</script>

		<div>		

					<p>Sprinkle</p>
					<canvas nx="position" id="Sprinkle" style="width:600px;height:30px;"></canvas>
					<canvas nx="button" style="width:30px;height:30px;"></canvas>

					<p>Pixel</p>
					<canvas nx="position" id="Pixel" style="width:600px;height:30px;"></canvas>
					<canvas nx="button" style="width:30px;height:30px;"></canvas>

					<p>Saturation</p>
					<canvas nx="position" id="Saturation" style="width:600px;height:30px;"></canvas>
					<canvas nx="button" style="width:30px;height:30px;"></canvas>

					<p>Brightness</p>
					<canvas nx="position" id="Brightness" style="width:600px;height:30px;"></canvas>
					<canvas nx="button" style="width:30px;height:30px;"></canvas>

					<p>Contrast</p>
					<canvas nx="position" id="Contrast" style="width:600px;height:30px;"></canvas>
					<canvas nx="button" style="width:30px;height:30px;"></canvas>

					<p>Snow</p>
					<canvas nx="position" id="Snow" style="width:600px;height:30px;"></canvas>
					<canvas nx="toggle" id="toggle2" style="width:30px;height:30px;"></canvas>

					<p style="color:#006600;">Sig</p>
					<canvas nx="toggle" id="toggle1" style="width:50px;height:50px;"></canvas>

					<p style="color:#006600;">Sine1</p>
					<canvas nx="position" id="Sine1" style="width:600px;height:30px;"></canvas>
					<canvas nx="button" style="width:30px;height:30px;"></canvas>

					<p style="color:#006600;">Sine2</p>
					<canvas nx="position" id="Sine2" style="width:600px;height:30px;"></canvas>
					<canvas nx="button" style="width:30px;height:30px;"></canvas>

					<p style="color:#006600;">Sine3</p>
					<canvas nx="position" id="Sine3" style="width:600px;height:30px;"></canvas>
					<canvas nx="button" style="width:30px;height:30px;"></canvas>

	</body>
</html>

Max and javaScript

I wanted to post this bit of javaScript that I am using in the Max programming environment. Using the Max js object to do javaScript is awesome! It helps me to accomplish very tedious tasks (tedious if I do them with native max objects) such as if() and for() loops.

I found the few tutorials on the js object to be a little lacking in details, such as how to distinguish between data from different inlets.

I’ve posted the code below, but the most helpful thing I discovered was that by coding:

</pre>if(inlet==0){}

would allow me to test which inlet I was receiving from.

</pre>
/*This is very simple code for subtracting the elements one a list
from the corresponding elements in another list.
for my purposes I didn't need the lists to be the same length so.
*/
inlets = 2; //2 inlets one for each list
outlets = 1;

var leftArray = [];
var rightArray= [];
var diffArray= [];

function list(){

	if (inlet==0) {	//this if statement detects if the inlet is the first
		leftArray = arrayfromargs(arguments); //this stores the list in an arrray
	}

	if (inlet==1) { //this detects if the inlet is the second
		rightArray = arrayfromargs(arguments);//stored in an array
	}

	for (var i=0; i<leftArray.length; i++) {

		var toStore = leftArray[i] - rightArray[i]; //find difference

		if (toStore<0) {
			toStore = toStore * -1;
		}	//store the differences in an array

		diffArray[i] = toStore;
	}

	bang(); //call the bang function
}

function bang() {
	outlet(0, diffArray); //print out the stored array
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s