///////////////////////////// OBJECT CREATION, sending messages to IanniX ////////////////////////////////

//please start from an empty score in Iannix app.

~inx = Iannix.new;// localhost by default

/* //another machine:

~inx = Iannix("192.168.0.49", 1234);//port must be Iannix app. input port (default: 1234)

*/

//~inx.connect("192.168.0.49", 1234); //alternative: connect an existing Iannix instance to another Iannix port, and listen to iannix transports

~inx.resetScore(zoom: 300, total: true); //just in case... ( ! deletes everything in the Iannix application score !)

// At instantiation time, a Iannix instance builds an object dictionary, using their ID as keys

~line = ~inx.curve([[1, 2, 0], [2,3,-1], [3, 0, 2], 8@10]); //four Points (1@2 is a shortcut for Point(1, 2);

(

~line2 = ~inx.curve([

[-4, -1],

[-2, 1],

[[1, 1], [2, 2, 0, 2]], //2D beziers line: xy values, and 4 beziers points ( 2 start tangent values + 2 end tangent values)

[1, -1, 2], //3D point

[[-4 ,-1, 0], [ 0, -2, 2 , 5, 0, 0]] //3D bezier line: xyz values, and 6 beziers points ( 3 start tangent values + 3 end tangent values)

])

)

~line2.label_("line"+ ~line2.id);

~line2.id; //get this line id

~inx.objects; //the object dictionnary is filled in...

~line.remove; //remove this curve

~line2.remove; // and the other one

//3 point creation examples:

~points = 10.collect {|x| (x+1)@5.0.rand2 }; //some points, related to x += 1, using Point instances

~points = 10.collect {|x| [(x+1), 5.0.rand2, 5.rand2] }; //points as arrays of coordinates, using the z plane

~points = 10.collect {|x| [[(x+1), 5.0.rand2, 5.rand2], {rrand(-4, 4)}!6]}; //idem, with beziers

~line = ~inx.curve; //without points for now;

~line.points_(pointsArray: ~points); //adding points, or modifying existing points

~line.group_("supacollida");

~curs = ~inx.cursor(~line); //put a cursor on the line

~line.childs; // the just created cursor

~curs.duration_(10); // the time for this cursor to reach the end of the curve, in seconds

~curs.width_(5).size_(4 ); //changing some specifications

~curs.label_("I'm here");

~curs.active(false); //true by default, false for object inactivation

~curs.active(true); //actived again

~curs.loopPattern_([1, -1, 2, -4]); //speed array, negative value for reverse speed

~curs.group_("supacollida");

~inx.activate("supacollida", false) ; // deactivating a group (so all objects inside this group)

~inx.activate("supacollida") ; // reactivating a group

~inx.remove("supacollida"); //remove all objects affected to this group

~line.points_(5.collect {|x| (x+1)@5.0.rand2 });// random change of the 5 first points of this line;

~line.width_(10);

~line.lineStyle_(0x0F00);

~line.lineStyle_(nil); //as reset to plain

~curs.lineStyle_(0x0F00)

~line.remove; //also remove its child, if any

~line = ~inx.curve.fromSVGpath2([1@1, 1@2, -1@2, -1 @ -2, -2@0], 1);

~line.fromImage(Document.current.dir++"\/SCcube.png", 0.03); //wait a little...

~inx.zoom(300);

~line.position_(2, 3, -10);

~line.color_(Color.red);

~curs.color_(Color.blue);

~curs.allMessages; // the arguments this object will send from Iannix app , i.e

~curs.messages_(["cursor_value_x", "cursor_value_y"]) //add two valid arguments to the Iannix app messages for this object

~inx.rotate(x:45, y: 30, z: 100) ; // rotation of the score: changing the point of view

~inx.rotate; //restoring default view

~inx.resetScore(300); //remove anything created from sclang

10.do { ~inx.trigger(10.rand, 10.rand, 10.rand).color_(Color.rand) }; //10 triggers on the xyz planes

//see IannixObject, IannixCursor, IannixCurve et IannixTrigger for more details on those objects

//Info on existing objects in Iannix app (still buggy)

~inx.info;

//transport

~inx.play;

~inx.play(speed:3);

~inx.play(speed:-1); //reverse

~inx.stop;

~inx.fastrewind;

~inx.speed_(0.4);

(

//glyph, depuis un score vide dans Iannix.app

~inx !? {~inx.removeAll(true) };

~inx = Iannix.new;

~inx.zoom(500);

~inx.center(10);

~xPos = 0; ~dist = 3;

"supacollida".do {|char|

var ln;

~xPos = ~dist + ~xPos;

char = char.asString;

ln = ~inx.curve.fromText(char, 0.1, "Arial").position_(~xPos).width_(3).color_(Color.rand);

if ((char=="i") || (char=="l")) {~dist = 1.5}{~dist = 3};

~inx.cursor(ln).speed_(rrand(1, 4.0)).color_(Color.rand);

2.do { ~inx.trigger(~xPos + ~dist.rand, 2.0.rand).size_(0.1) };

};

)

~inx.play;

~inx.stop;

// the end

~inx.objects.postcs;"";

~inx.resetScore(true);