Creating Textures

Creating Textures

This is discussed in detail in the notebook "" supplied with MathLive. Essentially, the first step is to create a binary file, and we make use of the Mathematica function FromCharacterCode[] to do so. Further information regarding about binary files can be obtained by looking at the BinaryFiles package. However, this is not necessary in order to create some simple textures, and the following will suffice for many interesting examples.

First we need to create some standard header information:

headerdata =  {16^^59,16^^a6,16^^6a,16^^95








The next step is to create a suitable colour map. Here is one example tested to produce vivid if rather tasteless colours.

huefunc[x_] := 255*Which[x<1,x,x<3,1,x<4,4-x,True,0];

rgb[x_] := Floor[{huefunc[Mod[x+2,6]],huefunc[x], huefunc[Mod[x-2,6]]}];

colormap = Flatten[Transpose[Table[rgb[x],{x,0,6,6/255.0}]]];

The notebook "" also contains a convenient way of visualizing this colour map.

Next we need to create some data that the colour map will use to create a colour map of the data. We will make some completely random data (note that the array is 128 by 128 --- this array size is a fixed parameter in this version of MathLive):

randomdata =  Flatten[Table[2*Ceiling[100*Random[]],{128},{128}]];

outline = OpenWrite["random.ras"];



WriteString[outline,FromCharacterCode[randomdata]]; Close[outline]

The file "random.ras" may be opened and used as a texture in the usual way.

Texture maps provide an interesting way of transferring Mathematica animation information to the MathLive environment. The notebook contains an example of the creation of an animated colour map that can be used to dump a "glowing'' fractal onto any surface!

datasheet technical notebooks demos

about us contact new index
internet software virtual reality programming