timer(toBvr(1.0)), substitute for startLen
flipSnd.loop().pan(mul(toBvr(dir), varries from -dir to +dir.
sub(mul(toBvr(panRate), localTime), toBvr(1)))));
}
Pastes a picture on a unit-sized page while preserving its
aspect ratio. The picture is left-centered. The extra
space is filled with paper texture. |
public static ImageBvr normalPic(ImageBvr pic) {
Bbox2Bvr picBbox = pic.boundingBox();
Point2Bvr ur = picBbox.getMax();
NumberBvr dim = maxNumBvr(ur.getX(), ur.getY());
ImageBvr croppedTex = paperTex.tile().crop(point2(neg(dim), neg(dim)),
point2(dim, dim));
return overlay(pic, croppedTex).mapToUnitSquare();
}
Constructs a number behavior which is a certain number
or 0 depending on if the given key is pressed or not. |
static NumberBvr keyIntegral(int key) {
NumberBvr cAngleRate = toBvr(Math.PI/8); rate of motion of camera angle
NumberBvr factor = (NumberBvr)cond(keyState(key), cAngleRate, toBvr(0));
return integral(factor);
}
Takes a page of the album and renders it into an image
based on consistent camera and lights. Animates the camera
based on the up and down arrow keys. |
static ImageBvr renderPage(GeometryBvr page) {
create an interactive angle to animate the camera |
NumberBvr initialAngle = toBvr(Math.PI/20);
NumberBvr cameraAngle = add(initialAngle,
sub(keyIntegral(Event.UP),
keyIntegral(Event.DOWN)));
use the angle to rotate the camera |
Transform3Bvr cameraTrans = rotate(xVector3, cameraAngle);
CameraBvr camera = perspectiveCamera(toBvr(5),
toBvr(4)).transform(cameraTrans);
scale the resulting image, map 1 unit to 50 pixels |
Transform2Bvr scaleTrans = scale2(mul(toBvr(PAGESIZE),pixelBvr));
GeometryBvr scene = union(ambientLight, page);
return scene.render(camera).transform(scaleTrans);
}
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.