Presentation is loading. Please wait.

Presentation is loading. Please wait.

B. RAMAMURTHY Simulating Motion and Implementing Animation.

Similar presentations


Presentation on theme: "B. RAMAMURTHY Simulating Motion and Implementing Animation."— Presentation transcript:

1 B. RAMAMURTHY Simulating Motion and Implementing Animation

2 Processing Features for Motion/animation fill(), nofill() in color commands loop(), noloop() : this is for controlling draw() function frameRate() height, width Displaying text on the screen translate () rotate()

3 Display Text on Screen PFont f; // STEP 1 Declare PFont variable void setup() { size(200,200); f = createFont("Arial",16,true); // STEP 2 Create Font } int x= 10; int y = 100; void draw() { background(255); textFont(f,16); // STEP 3 Specify font fill(0); // STEP 4 Specify font color text("Hello Strings!", x, y); // STEP 5 Display Text }

4 Print text on the terminal window These are useful for debugging print( string); println(string) Example: println (“Position of the animal is” + x, “ “ + y);

5 frameRate() Observe naming convention “frame” “Rate” Specifies the number of frames to be displayed every second: default is 60 sec void setup() { frameRate(4); } int pos = 0; void draw() { background(204); pos++; line(pos, 20, pos, 80); if (pos > width) { pos = 0; }

6 loop() and noloop() And redraw() draw() function by default keeps looping without any control. You make control it using loop() and noloop() function calls You can also call draw to execute only once by calling redraw() function

7 translate and rotate Last class we looked at translating (moving x and y) by moving the object. You can also simulate this by moving the grid, that’s what translate(x,y) function does. You can also rotate the object by rotating the grid. It takes the parameters in radians. We think is degrees. We have a function radians() to convert degrees to radians. Lets look at some examples.


Download ppt "B. RAMAMURTHY Simulating Motion and Implementing Animation."

Similar presentations


Ads by Google