Changeset 2184

Show
Ignore:
Timestamp:
08/30/2007 11:18:16 AM (17 months ago)
Author:
xue
Message:

Added text shadow option.

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/demos/quickstart/protected/pages/Controls/Captcha.page

    r2182 r2184  
    2121 
    2222<p> 
    23 To specify the appearance of the generated token image, set <tt>TokenImageTheme</tt> to be an integer between 0 and 31. You may try the following example to see how this value affects the generated token image. The size of the generated token image is determined by <tt>TokenFontSize</tt>. In particular, the image width is proportional to the font size. You may also set <tt>Width</tt> to scale the generated image to your desired size, but the scaled image may not look good. By setting <tt>ChangingTokenBackground</tt> to true, the image background of the token will be variating even though the token is the same during postbacks. 
     23To specify the appearance of the generated token image, set <tt>TokenImageTheme</tt> to be an integer between 0 and 63. You may try the following example to see how this value affects the generated token image. The size of the generated token image is determined by <tt>TokenFontSize</tt>. In particular, the image width is proportional to the font size. You may also set <tt>Width</tt> to scale the generated image to your desired size, but the scaled image may not look good. By setting <tt>ChangingTokenBackground</tt> to true, the image background of the token will be variating even though the token is the same during postbacks. 
    2424</p> 
    2525 
  • trunk/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php

    r2175 r2184  
    77                if(!$this->IsPostBack) 
    88                { 
    9                         $this->CaptchaList->DataSource=range(0,31); 
     9                        $this->CaptchaList->DataSource=range(0,63); 
    1010                        $this->CaptchaList->dataBind(); 
    1111                } 
  • trunk/framework/Web/UI/WebControls/TCaptcha.php

    r2182 r2184  
    3333 * 
    3434 * To specify the appearance of the generated token image, set {@link setTokenImageTheme TokenImageTheme} 
    35  * to be an integer between 0 and 31. And to adjust the generated image size, set {@link setTokenFontSize TokenFontSize} 
     35 * to be an integer between 0 and 63. And to adjust the generated image size, set {@link setTokenFontSize TokenFontSize} 
    3636 * (you may also set {@link TWebControl::setWidth Width}, but the scaled image may not look good.) 
    3737 * By setting {@link setChangingTokenBackground ChangingTokenBackground} to true, the image background 
     
    9292         * Bit 3: whether we should add some scribbles to the image (1) or not (0). 
    9393         * Bit 4: whether the image background should be morphed (1) or not (0). 
    94          * @param integer the theme of the token image. It must be an integer between 0 and 31. 
     94         * Bit 5: whether the token text should cast a shadow (1) or not (0). 
     95         * @param integer the theme of the token image. It must be an integer between 0 and 63. 
    9596         */ 
    9697        public function setTokenImageTheme($value) 
    9798        { 
    9899                $value=TPropertyValue::ensureInteger($value); 
    99                 if($value>=0 && $value<=31) 
     100                if($value>=0 && $value<=63) 
    100101                        $this->setViewState('TokenImageTheme',$value,0); 
    101102                else 
    102                         throw new TConfigurationException('captcha_tokenimagetheme_invalid',0,31); 
     103                        throw new TConfigurationException('captcha_tokenimagetheme_invalid',0,63); 
    103104        } 
    104105 
  • trunk/framework/Web/UI/WebControls/assets/captcha.php

    r2182 r2184  
    1616define('THEME_HAS_SCRIBBLE',0x0008); 
    1717define('THEME_MORPH_BACKGROUND',0x0010); 
     18define('THEME_SHADOWED_TEXT',0x0020); 
    1819 
    1920require_once(dirname(__FILE__).'/captcha_key.php'); 
     
    103104        imagefilter($image,IMG_FILTER_GAUSSIAN_BLUR); 
    104105 
     106        $hasShadow=($theme&THEME_SHADOWED_TEXT); 
    105107    for($i=0;$i<$length;$i++) 
    106108        { 
    107109        $color=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220)); 
    108         imagettftext($image,rand($fontWidth-10,$fontWidth),rand(-30, 30),$padding+$i*$fontWidth,rand($fontHeight-15,$fontHeight-10),$color,$font,$token[$i]); 
     110        $size=rand($fontWidth-10,$fontWidth); 
     111        $angle=rand(-30,30); 
     112        $x=$padding+$i*$fontWidth; 
     113        $y=rand($fontHeight-15,$fontHeight-10); 
     114        imagettftext($image,$size,$angle,$x,$y,$color,$font,$token[$i]); 
     115        if($hasShadow) 
     116                imagettftext($image,$size,$angle,$x+2,$y+2,$color,$font,$token[$i]); 
    109117        imagecolordeallocate($image,$color); 
    110118    }