Reference:Strings.inc

From POV-Wiki
Jump to navigation Jump to search

This include contains macros for manipulating and generating text strings.

CRGBStr(C, MinLen, Padding) and CRGBFTStr(C, MinLen, Padding): These macros convert a color to a string. The format of the output string is "rgb < R, G, B>" or "rgbft < R, G, B, F, T>", depending on the macro being called.

Parameters:

  • C = The color to be turned into a string.
  • MinLen = The minimum length of the individual components, analogous to the second parameter of str().
  • Padding = The padding to use for the components, see the third parameter of the str() function for details.

Str(A): This macro creates a string containing a float with the systems default precision. It is a shortcut for using the str() function.

Parameters:

  • A = The float to be converted to a string.

VStr2D(V), VStr(V): These macros create strings containing vectors using POV syntax (<X,Y,Z>) with the default system precision. VStr2D() works with 2D vectors, VStr() with 3D vectors. They are shortcuts for using the vstr() function.

Parameters:

  • V = The vector to be converted to a string.

Vstr2D(V,L,P), Vstr(V,L,P): These macros create strings containing vectors using POV syntax (<X,Y,Z>) with user specified precision. Vstr2D() works with 2D vectors, Vstr() with 3D vectors. They are shortcuts for using the vstr() function. The function of L and P is the same as in vstr specified in String Functions.

Parameters:

  • V = The vector to be converted to a string.
  • L = Minimum length of the string and the type of left padding used if the string's representation is shorter than the minimum.
  • P = Number of digits after the decimal point.

Triangle_Str(A, B, C) and Smooth_Triangle_Str(A, NA, B, NB, C, NC): These macros take vertex and normal information and return a string representing a triangle in POV-Ray syntax. They are mainly useful for generating mesh files.

Parameters:

  • A, B, C = Triangle vertex points.
  • NA, NB, NC = Triangle vertex normals (Smooth_Triangle_Str() only).

Parse_String(String): This macro takes a string, writes it to a file, and then includes that file. This has the effect of parsing that string: "Parse_String("MyColor")" will be seen by POV-Ray as "MyColor".

Parameters:

  • String = The string to be parsed.