From 181b0cd0d07ca36cefc105409204dc64410c2ca4 Mon Sep 17 00:00:00 2001 From: Adelbert Silla Date: Mon, 29 Apr 2013 08:50:17 +0800 Subject: [PATCH] Added text_color option. --- DependencyInjection/Configuration.php | 1 + Generator/CaptchaGenerator.php | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index bac834d..cf87657 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -43,6 +43,7 @@ class Configuration implements ConfigurationInterface ->scalarNode('max_behind_lines')->defaultValue(null)->end() ->scalarNode('interpolation')->defaultValue(true)->end() ->arrayNode('background_color')->prototype('scalar')->end() + ->arrayNode('text_color')->prototype('scalar')->end() ->end() ; diff --git a/Generator/CaptchaGenerator.php b/Generator/CaptchaGenerator.php index e419580..08cde2d 100644 --- a/Generator/CaptchaGenerator.php +++ b/Generator/CaptchaGenerator.php @@ -98,6 +98,15 @@ class CaptchaGenerator $this->builder->setMaxFrontLines($options['max_front_lines']); $this->builder->setMaxBehindLines($options['max_behind_lines']); + if ($options['text_color'] != array()) { + if (count($options['text_color'])!=3) { + throw new \RuntimeException('text_color should be an array of r, g and b'); + } + + $color = $options['text_color']; + $this->builder->setTextColor($color[0], $color[1], $color[2]); + } + if ($options['background_color'] != array()) { if (count($options['background_color'])!=3) { throw new \RuntimeException('background_color should be an array of r, g and b');