You are here

function theme_textimage_colored_string in Textimage 7.3

Render a text string, color formatted.

Optionally, uses Luma algorithms to determine best color match for foreground and border colors.

3 theme calls to theme_textimage_colored_string()
theme_textimage_background_effect_summary in effects/textimage_background.inc
Renders 'textimage_background' image effect summary.
theme_textimage_gif_transparency_effect_summary in effects/textimage_gif_transparency.inc
Renders 'textimage_gif_transparency' image effect summary.
theme_textimage_text_effect_summary in effects/textimage_text.inc
Renders 'textimage_background' image effect summary.

File

./textimage.module, line 972
Textimage - Provides text to image manipulations.

Code

function theme_textimage_colored_string($variables) {
  drupal_add_css(drupal_get_path('module', 'textimage') . '/misc/css/textimage.admin.css');

  // Set background color.
  if (!empty($variables['background_color'])) {
    $background_color = drupal_substr($variables['background_color'], 0, 7);
    $background_color_css = "background-color:{$background_color};";
  }
  else {
    $background_color = "#FFFFFF";
    $background_color_css = NULL;
  }

  // Set text.
  $text = $variables['text'];

  // Set text foreground color. If 'matchLuma' is specified, resolves
  // best color against background.
  if ($variables['foreground_color'] == 'matchLuma') {
    $foreground_color = textimage_match_luma($background_color);
  }
  else {
    $foreground_color = drupal_substr($variables['foreground_color'], 0, 7);
  }

  // Set border css if required.  If 'matchLuma' is specified for border
  // color, resolves best color against background.
  $border_css = NULL;
  if ($variables['border']) {
    if ($variables['border_color'] == 'matchLuma') {
      $border_color = textimage_match_luma($background_color);
    }
    else {
      $border_color = drupal_substr($variables['border_color'], 0, 7);
    }
    $border_css = "border-color:{$border_color};";
  }
  return "<span class=\"textimage-colored-string\" style=\"{$background_color_css} color:{$foreground_color}; {$border_css} \">{$text}</span>";
}