JavaScript Workspace
X

Menu
Shell Workspace
X

Menu
JavaScript Workspace
X

Menu
/home/lively/LivelyKernel/users/robertkrahn/csc130/tutorials.css
X

Menu
Welcome to CS 130!
In this lab, you'll learn about the basic objects we'll be using throughout the term, and the environment we'll be using for teaching, development, and experiment. To start: you are (obviously) looking at a web page. But it's a special web page: everything is changeable, everything is live. To see this, first, pick up the rectangle and move it around.
All Text is Live
Well, you have seen that before. But when you clicked on that text, what actually went on was that the text sent a message to the Rectangle to change its color. We can also do that. Select the following text and click 'cmd-d' (Mac) or 'ctrl-d' (Windows/Linux): $morph('example-rectangle').changeColor() That was an example of sending a message (changeColor) to an Object (the rectangle). In fact, it was really sending two messages to two different objects. The first message, $morph was sent to the world -- it said "find me an Object named example-rectangle". The world then returned the rectangle, and we told it to change color. Let's try sending some other messages. How about: $morph('example-rectangle').setExtent(pt(150,150 )) As you can guess, the pt(150, 150) told the rectangle how big to be. pt(150, 150) is another object -- it's a point, with x coordinate 150 and y coordinate 150. Change the x and y values to change the size of the rectangle... $morph('example-rectangle').setExtent(pt(50,50 )) How about rotating it? $morph('example-rectangle').setRotation(Math.PI/4) Notice that we use radians (2 PI is a complete circle) rather than degrees... And moving it? $morph('example-rectangle').setPosition(pt(40,40)) Some messages make the object send back a value....we use cmd-p (ctrl-p) to see the value. Try this $morph('example-rectangle').getPosition() ...or this... $morph('example-rectangle').getRotation() note again it's in radians. For degrees, $morph('example-rectangle').getRotation() * 180/Math.PI ...or this... Math.PI/4 ...or this... 3/2
More than that, every piece of text is potentially executable. Try clicking on this: Change My Color!
<lively.morphic.World#1>
PartsBin
Parts
Search
Tools
Stepping
Preferences
Debugging
Wiki
Documentation
Report a bug
Run command...
Save world as ...
Save world