Brian Dunning's FileMaker Custom Functions

ContrastText ( foregroundText ; bgRedPercent ; bgGreenPercent ; bgBluePercen

Colors foregroundText black or white as appropriate for the specified background color.

  Average rating: 4.0 (34 votes) Log in to vote

Joe Rovang   Joe Rovang

Share on Facebook Share on Twitter

  Sample input:
ContrastText ( "Text" ; 0 ; 0 ; .5 )
  Sample output:
{{colored white}}

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)


This function will color foregroundText black or white, depending on the background color specified using the respective percentage parameters. (Color percentages must be specified as values between 0 and 1.)

This could come in handy if you have a background color generated dynamically (in my solution, I did this using a TextColor-based calculation field set to output a block character at a very large font size). If your colors are generated by HSB (hue/saturation/brightness, also known as HSV/HSL), try my HSBtoRGB() function to convert those values to RGB percentages as input parameters for this function.

Feel free to adjust the luminance values embedded in the function, especially if your color perception or monitor settings are atypical!



Log in to post comments.


Note: these functions are not guaranteed or supported by Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.