sims.experimental.BlankSlateApp

previous next

BlankSlateApp has a LabCanvas and Terminal, and lets you experiment building things with scripts. Below is a sample script to try.

NOTE: This will only work on simple-compiled versions of this app; advanced-compiled versions cannot execute JavaScript.

var r = PointMass.makeSquare(4);
var dr = new DisplayShape(r).setStrokeStyle('red').setThickness(4);
displayList.add(dr);
r.setPosition(new Vector(0, 0));
var clock = new Clock();
var timer = new Timer();
var callback = function () {
    r.setAngle(Math.sin(clock.getTime()));
    simCanvas.paint();
};
timer.setCallBack(callback);
clock.resume();
timer.startFiring();

A script can be provided in the query portion of the URL (after the question mark) for this page. For example, the following URL contains the above script.


http://www.myphysicslab.com/develop/build/sims/experimental/BlankSlateApp_en.html?var r=PointMass.makeSquare(4);
var dr=new DisplayShape(r);displayList.add(dr);dr.strokeStyle='red';r.setPosition(new Vector(0,0));
var clock=new Clock();var timer=new Timer();
timer.setCallBack(function(){r.setAngle(Math.sin(clock.getTime()));simCanvas.paint();});
clock.resume();
Valid HTML 4.01