[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] help update for Pen, String, Color, SCUserView



Hello,

the help for gui drawing in Pen, String and Color is outdated since we have the famous SCUserView, which is able to do graphics also in a dedicated view.

Could someone please change the descriptive text in these helpfiles to this?

The following methods must be called within an SCWindow-drawHook or a SCUserView-drawFunc function, and will only be visible once the window or the view is refreshed. Each call to SCWindow-refresh SCUserView-refresh will 'overwrite' all previous drawing by executing the currently defined function.
_______

And this is a draft for a helpfile for SCUserView:

SCUserView

superclass: SCView

SCUserView is a user-adjustable View mainly for modulating drawHooks.


keyDownFunc_
set a.multiply(b)the function which should be evaluated if the view is in focus and a key is pressed.
drawFunc_
	set the function which should be evaluated if the view is refreshed.
	this happens every time the whole window is refreshed
	(manually by calling SCWindow-refresh or e.g. by resizing the window)
	
	(
	var func;
	
	func = {|me|
		Pen.use{
			// clipping into the boundingbox
			Pen.moveTo((me.bounds.left)@(me.bounds.top));
			Pen.lineTo(((me.bounds.left)@(me.bounds.top))
					+ (me.bounds.width@0));
			Pen.lineTo(((me.bounds.left)@(me.bounds.top))
					+ (me.bounds.width@xxxxxxxxxxxxxxxx));
			Pen.lineTo(((me.bounds.left)@(me.bounds.top))
					+ (0@xxxxxxxxxxxxxxxx));
			Pen.lineTo((me.bounds.left)@(me.bounds.top));
			Pen.clip;
			
			// draw background
			Color.gray(0.5).set;
			Pen.moveTo((me.bounds.left)@(me.bounds.top));
			Pen.lineTo(((me.bounds.left)@(me.bounds.top))
					+ (me.bounds.width@0));
			Pen.lineTo(((me.bounds.left)@(me.bounds.top))
					+ (me.bounds.width@xxxxxxxxxxxxxxxx));
			Pen.lineTo(((me.bounds.left)@(me.bounds.top))
					+ (0@xxxxxxxxxxxxxxxx));
			Pen.lineTo((me.bounds.left)@(me.bounds.top));
			Pen.fill;			

			Pen.translate(100, 100);
			10.do{
				Color.red(rrand(0.0, 1), rrand(0.0, 0.5)).set;
Pen.addArc((400.exprand(2))@(100.rand), rrand(10, 100), 2pi.rand, pi);
				Pen.perform([\stroke, \fill].choose);
			}
		}
	};

	w = SCWindow.new.front;
	w.view.background_(Color.white);
	3.do{|i|
		v = SCUserView(w, Rect(20+(i*120), 100, 100, 100));
		//v.background_(Color.white); // not affecting anything...
		v.drawFunc = func;
	};
	w.refresh;
	)

	
mouseBeginTrackFunc_
set the function which should be evaluated if the mouse is at the beginning of a tracking
mouseTrackFunc_
	set the function which should be evaluated if the mouse is tracked
mouseEndTrackFunc_
set the function which should be evaluated if the mouse is at the end of a tracking
	
	
	(
	var drawFunc, beginTrackFunc, endTrackFunc, trackFunc, sat = 0, absX;
	
	drawFunc = {|me|
		Pen.use{
			// clipping into the boundingbox
			Pen.moveTo((me.bounds.left)@(me.bounds.top));
			Pen.lineTo(((me.bounds.left)@(me.bounds.top))
					+ (me.bounds.width@0));
			Pen.lineTo(((me.bounds.left)@(me.bounds.top))
					+ (me.bounds.width@xxxxxxxxxxxxxxxx));
			Pen.lineTo(((me.bounds.left)@(me.bounds.top))
					+ (0@xxxxxxxxxxxxxxxx));
			Pen.lineTo((me.bounds.left)@(me.bounds.top));
			Pen.clip;
			
			// draw background
			Color.gray(sat).set;
			Pen.moveTo((me.bounds.left)@(me.bounds.top));
			Pen.lineTo(((me.bounds.left)@(me.bounds.top))
					+ (me.bounds.width@0));
			Pen.lineTo(((me.bounds.left)@(me.bounds.top))
					+ (me.bounds.width@xxxxxxxxxxxxxxxx));
			Pen.lineTo(((me.bounds.left)@(me.bounds.top))
					+ (0@xxxxxxxxxxxxxxxx));
			Pen.lineTo((me.bounds.left)@(me.bounds.top));
			Pen.fill;			

			Pen.translate(100, 100);
			10.do{
				Color.red(rrand(0.0, 1), rrand(0.0, 0.5)).set;
Pen.addArc((400.exprand(2))@(100.rand), rrand(10, 100), 2pi.rand, pi);
				Pen.perform([\stroke, \fill].choose);
			}
		}
	};
	beginTrackFunc = {|me, x, y, mod|
		absX = x;
		postf("begin path: x=%\n",absX);
	};
	endTrackFunc = {|me, x, y, mod|
		postf("end path: (absX-x)=%\n", (absX-x))
	};
	trackFunc = {|me, x, y, mod|
		sat = ((absX-x)/100);
		me.refresh;
	};

	w = SCWindow.new.front;
	w.view.background_(Color.white);
	3.do{|i|
		v = SCUserView(w, Rect(20+(i*120), 100, 100, 100));
		//v.background_(Color.white); // not affecting anything...
		v.drawFunc = drawFunc;
		v.mouseBeginTrackFunc = beginTrackFunc;
		v.mouseEndTrackFunc = endTrackFunc;
		v.mouseTrackFunc = trackFunc;
	};
	w.refresh;
	)



_______

thanx in advance
Till