function execute(code, scope) {
		// Set currently active scope.
		paper = scope;
		var view = scope.getView(),
			// Only create a tool object if something resembling a tool handler
			// definition is contained in the code.
			tool = /\s+on(?:Key|Mouse)(?:Up|Down|Move|Drag)\b/.test(code)
					? new Tool()
					: null,
			toolHandlers = tool ? tool._events : [],
			// Compile a list of all handlers that can be defined globally
			// inside the PaperScript. These are passed on to the function as
			// undefined arguments, so that their name exists, rather than
			// injecting a code line that defines them as variables.
			// They are exported again at the end of the function.
			handlers = ['onFrame', 'onResize'].concat(toolHandlers),
			// compile a list of paramter names for all variables that need to
			// appear as globals inside the script. At the same time, also
			// collect their values, so we can pass them on as arguments in the
			// function call. 
			params = [],
			args = [],
			func;
		code = compile(code);
		function expose(scope, hidden) {
			// Look through all enumerable properties on the scope and expose
			// these too as pseudo-globals, but only if they seem to be in use.
			for (var key in scope) {
				if ((hidden || !/^_/.test(key)) && new RegExp(
						'\\b' + key.replace(/\$/g, '\\$') + '\\b').test(code)) {
					params.push(key);
					args.push(scope[key]);
				}
			}
		}
		expose({ _$_: _$_, $_: $_, view: view, tool: tool }, true);
		expose(scope);
		// Finally define the handler variable names as parameters and compose
		// the string describing the properties for the returned object at the
		// end of the code execution, so we can retrieve their values from the
		// function call.
		handlers = Base.each(handlers, function(key) {
			// Check for each handler explicitely and only return them if they
			// seem to exist.
			if (new RegExp('\\s+' + key + '\\b').test(code)) {
				params.push(key);
				this.push(key + ': ' + key);
			}
		}, []).join(', ');
		// We need an additional line that returns the handlers in one object.
		if (handlers)
			code += '\nreturn { ' + handlers + ' };';
/*#*/ if (__options.environment == 'browser') {
		var firefox = window.InstallTrigger;
		if (firefox || window.chrome) {
			// On Firefox, all error numbers inside dynamically compiled code
			// are relative to the line where the eval / compilation happened.
			// To fix this issue, we're temporarily inserting a new script
			// tag. We also use this on Chrome to fix an issue with compiled
			// functions:
			// https://code.google.com/p/chromium/issues/detail?id=331655
			var script = document.createElement('script'),
				head = document.head;
			// Add a new-line before the code on Firefox since the error
			// messages appeawr to be aligned to line number 0...
			if (firefox)
				code = '\n' + code;
			script.appendChild(document.createTextNode(
				'paper._execute = function(' + params + ') {' + code + '\n}'
			));
			head.appendChild(script);
			func = paper._execute;
			delete paper._execute;
			head.removeChild(script);
		} else {
			func = Function(params, code);
		}
/*#*/ } else { // !__options.environment == 'browser'
		func = Function(params, code);
/*#*/ } // !__options.environment == 'browser'
		var res = func.apply(scope, args) || {};
		// Now install the 'global' tool and view handlers, and we're done!
		Base.each(toolHandlers, function(key) {
			var value = res[key];
			if (value)
				tool[key] = value;
		});
		if (view) {
			if (res.onResize)
				view.setOnResize(res.onResize);
			// Fire resize event directly, so any user
			// defined resize handlers are called.
			view.fire('resize', {
				size: view.size,
				delta: new Point()
			});
			if (res.onFrame)
				view.setOnFrame(res.onFrame);
			// Automatically update view at the end.
			view.update();
		}
	}
/**
	 * Executes the parsed PaperScript code in a compiled function that receives
	 * all properties of the passed {@link PaperScope} as arguments, to emulate
	 * a global scope with unaffected performance. It also installs global view
	 * and tool handlers automatically for you.
	 *
	 * @name PaperScript.execute
	 * @function
	 * @param {String} code The PaperScript code
	 * @param {PaperScript} scope The scope for which the code is executed
	 */
Executes the parsed PaperScript code in a compiled function that receives
all properties of the passed  PaperScope as arguments, to emulate
a global scope with unaffected performance. It also installs global view
and tool handlers automatically for you.

@name PaperScript.execute
@function
@param {String} code The PaperScript code
@param {PaperScript} scope The scope for which the code is executed
Executes the parsed PaperScript code in a compiled function that receives all properties of the passed PaperScope as arguments to emulate a global scope with unaffected performance . It also installs global view and tool handlers automatically for you . @name PaperScript . execute @function @param { String } code The PaperScript code @param { PaperScript } scope The scope for which the code is executed
function execute(code, scope) {
		paper = scope;
		var view = scope.getView(),
			tool = /\s+on(?:Key|Mouse)(?:Up|Down|Move|Drag)\b/.test(code)
					? new Tool()
					: null,
			toolHandlers = tool ? tool._events : [],
			handlers = ['onFrame', 'onResize'].concat(toolHandlers),
			params = [],
			args = [],
			func;
		code = compile(code);
		function expose(scope, hidden) {
			for (var key in scope) {
				if ((hidden || !/^_/.test(key)) && new RegExp(
						'\\b' + key.replace(/\$/g, '\\$') + '\\b').test(code)) {
					params.push(key);
					args.push(scope[key]);
				}
			}
		}
		expose({ _$_: _$_, $_: $_, view: view, tool: tool }, true);
		expose(scope);
		handlers = Base.each(handlers, function(key) {
			if (new RegExp('\\s+' + key + '\\b').test(code)) {
				params.push(key);
				this.push(key + ': ' + key);
			}
		}, []).join(', ');
		if (handlers)
			code += '\nreturn { ' + handlers + ' };';
 if (__options.environment == 'browser') {
		var firefox = window.InstallTrigger;
		if (firefox || window.chrome) {
			var script = document.createElement('script'),
				head = document.head;
			if (firefox)
				code = '\n' + code;
			script.appendChild(document.createTextNode(
				'paper._execute = function(' + params + ') {' + code + '\n}'
			));
			head.appendChild(script);
			func = paper._execute;
			delete paper._execute;
			head.removeChild(script);
		} else {
			func = Function(params, code);
		}
 } else { 
		func = Function(params, code);
 } 
		var res = func.apply(scope, args) || {};
		Base.each(toolHandlers, function(key) {
			var value = res[key];
			if (value)
				tool[key] = value;
		});
		if (view) {
			if (res.onResize)
				view.setOnResize(res.onResize);
			view.fire('resize', {
				size: view.size,
				delta: new Point()
			});
			if (res.onFrame)
				view.setOnFrame(res.onFrame);
			view.update();
		}
	}
function execute ( code , scope ) { paper = scope ; var view = scope . getView ( ) , tool = / \s+on(?:Key|Mouse)(?:Up|Down|Move|Drag)\b / . test ( code ) ? new Tool ( ) : null , toolHandlers = tool ? tool . _events : [ ] , handlers = [ 'onFrame' , 'onResize' ] . concat ( toolHandlers ) , params = [ ] , args = [ ] , func ; code = compile ( code ) ; function expose ( scope , hidden ) { for ( var key in scope ) { if ( ( hidden || ! / ^_ / . test ( key ) ) && new RegExp ( '\\b' + key . replace ( / \$ / g , '\\$' ) + '\\b' ) . test ( code ) ) { params . push ( key ) ; args . push ( scope [ key ] ) ; } } } expose ( { _$_ : _$_ , $_ : $_ , view : view , tool : tool } , true ) ; expose ( scope ) ; handlers = Base . each ( handlers , function ( key ) { if ( new RegExp ( '\\s+' + key + '\\b' ) . test ( code ) ) { params . push ( key ) ; this . push ( key + ': ' + key ) ; } } , [ ] ) . join ( ', ' ) ; if ( handlers ) code += '\nreturn { ' + handlers + ' };' ; if ( __options . environment == 'browser' ) { var firefox = window . InstallTrigger ; if ( firefox || window . chrome ) { var script = document . createElement ( 'script' ) , head = document . head ; if ( firefox ) code = '\n' + code ; script . appendChild ( document . createTextNode ( 'paper._execute = function(' + params + ') {' + code + '\n}' ) ) ; head . appendChild ( script ) ; func = paper . _execute ; delete paper . _execute ; head . removeChild ( script ) ; } else { func = Function ( params , code ) ; } } else { func = Function ( params , code ) ; } var res = func . apply ( scope , args ) || { } ; Base . each ( toolHandlers , function ( key ) { var value = res [ key ] ; if ( value ) tool [ key ] = value ; } ) ; if ( view ) { if ( res . onResize ) view . setOnResize ( res . onResize ) ; view . fire ( 'resize' , { size : view . size , delta : new Point ( ) } ) ; if ( res . onFrame ) view . setOnFrame ( res . onFrame ) ; view . update ( ) ; } }
Executes the parsed PaperScript code in a compiled function that receives
 all properties of the passed {@link PaperScope} as arguments, to emulate
 a global scope with unaffected performance.
Executes the parsed PaperScript code in a compiled function that receives all properties of the passed { @link PaperScope } as arguments to emulate a global scope with unaffected performance .
// Set currently active scope. // Only create a tool object if something resembling a tool handler // definition is contained in the code. // Compile a list of all handlers that can be defined globally // inside the PaperScript. These are passed on to the function as // undefined arguments, so that their name exists, rather than // injecting a code line that defines them as variables. // They are exported again at the end of the function. // compile a list of paramter names for all variables that need to // appear as globals inside the script. At the same time, also // collect their values, so we can pass them on as arguments in the // function call.  // Look through all enumerable properties on the scope and expose // these too as pseudo-globals, but only if they seem to be in use. // Finally define the handler variable names as parameters and compose // the string describing the properties for the returned object at the // end of the code execution, so we can retrieve their values from the // function call. // Check for each handler explicitely and only return them if they // seem to exist. // We need an additional line that returns the handlers in one object. /*#*/ // On Firefox, all error numbers inside dynamically compiled code // are relative to the line where the eval / compilation happened. // To fix this issue, we're temporarily inserting a new script // tag. We also use this on Chrome to fix an issue with compiled // functions: // https://code.google.com/p/chromium/issues/detail?id=331655 // Add a new-line before the code on Firefox since the error // messages appeawr to be aligned to line number 0... /*#*/ // !__options.environment == 'browser' /*#*/ // !__options.environment == 'browser' // Now install the 'global' tool and view handlers, and we're done! // Fire resize event directly, so any user // defined resize handlers are called. // Automatically update view at the end.