Previous Topic Tutorial Home Page Next Topic
Construct an Image of an Elapsed Time Counter


Returns an elapsed-seconds counter as an image.
ImageBvr createCounterImage() {

Convert localTime to a string and ignore fractional part.
FontStyleBvr fs = defaultFont.color(white).bold();

render into an image
ImageBvr underlyingImage = stringImage(localTime.toString(toBvr(0)),fs);

Scale into a unit square [0,1]. Note that as the size of the the string grows, for example going from 1 digit to 2, the scale adapts to fit the resulting image in the unit square.
return underlyingImage.mapToUnitSquare();
}

This is a time-varying solid-colored image, infinite in extent.
ImageBvr createBackgroundColorCycler() {
NumberBvr hue1 = mul(localTime, toBvr(0.2));
ColorBvr col1 = colorHsl(hue1, toBvr(0.5), toBvr(0.5));
return solidColorImage(col1);
}


© 1998 Microsoft Corporation. All rights reserved. Terms of Use.

Previous Topic Tutorial Home Page Next Topic