/*
	vcomment.js : part of the ICST Ambisonics tools 
	- replaces lcd-based version

	(c) 2021 ICST Zurich University of the Arts
*/
autowatch=0;mgraphics.init();mgraphics.relative_coords=0;mgraphics.autofill=0;var fontsize=jsarguments[1];var myText=jsarguments[2];var alpha=jsarguments[3];var rotation_angle=-90.0;var textbox=[];var fontface="Arial";var color=[0.1,0.1,0.1,1.0];var bgcolor=[1.0,1.0,1.0,0.0];var shifttext=[0,0];function paint(){onresize();with(mgraphics){var box=text_measure(myText);if(bgcolor[3]>0.0){set_source_rgba(bgcolor);rectangle(0,0,box[1],box[0]);fill()}set_source_rgba(color);select_font_face(fontface);set_font_size(fontsize);move_to(fontsize+shifttext[0],box[0]+shifttext[1]);rotate(rotation_angle*0.0174532925199432);show_text(myText)}}function onresize(){mgraphics.select_font_face(fontface);mgraphics.set_font_size(fontsize);textbox=mgraphics.text_measure(myText);box.size(textbox[1],textbox[0])}function set(s){myText=s;mgraphics.redraw()}function set_color(){var col=arrayfromargs(messagename,arguments);color[0]=col[1];color[1]=col[2];color[2]=col[3];color[3]=col[4];mgraphics.redraw()}function set_bgcolor(){var col=arrayfromargs(messagename,arguments);bgcolor[0]=col[1];bgcolor[1]=col[2];bgcolor[2]=col[3];bgcolor[3]=col[4];mgraphics.redraw()}function set_font_face(s){fontface=s;mgraphics.redraw()}function set_font_size(f){fontsize=Math.max(f,6.5);mgraphics.redraw()}function get_fontlist(){fontlist=mgraphics.getfontlist();outlet(0,"clear");for(var i=0;i<fontlist.length;i+=1){outlet(0,"append",fontlist[i])}}function shift(){var shi=arrayfromargs(messagename,arguments);shifttext[0]=shi[1];shifttext[1]=shi[2];mgraphics.redraw()}function save(){embedmessage("set",myText);embedmessage("set_font_face",fontface);embedmessage("set_font_size",fontsize);embedmessage("set_color",color[0],color[1],color[2],color[3]);embedmessage("set_bgcolor",bgcolor[0],bgcolor[1],bgcolor[2],bgcolor[3]);embedmessage("shift",shifttext[0],shifttext[1]);mgraphics.redraw()}