• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imageFilledRectangle函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中imageFilledRectangle函数的典型用法代码示例。如果您正苦于以下问题:PHP imageFilledRectangle函数的具体用法?PHP imageFilledRectangle怎么用?PHP imageFilledRectangle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了imageFilledRectangle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: code39

 public static function code39($text, $height = 50, $widthScale = 1)
 {
     // if (!preg_match('/^[A-Z0-9-. $+\/%]+$/i', $text)) {
     //            throw new Exception('Invalid text input.');
     //        }
     // $text = '*' . strtoupper($text) . '*'; // *UPPERCASE TEXT*
     $length = strlen($text);
     $barcode = imageCreate($length * 16 * $widthScale, $height);
     $bg = imagecolorallocate($barcode, 255, 255, 255);
     //sets background to yellow
     imagecolortransparent($barcode, $bg);
     //makes that yellow transparent
     $black = imagecolorallocate($barcode, 0, 0, 0);
     //defines a color for black
     $chars = str_split($text);
     $colors = '';
     foreach ($chars as $char) {
         $colors .= self::$code39[$char];
     }
     foreach (str_split($colors) as $i => $color) {
         if ($color == 'b') {
             // imageLine($barcode, $i, 0, $i, $height-13, $black);
             //                imageFilledRectangle($barcode, $widthScale * $i, 0, $widthScale * ($i+1) -1 , $height-13, $black);
             imageFilledRectangle($barcode, $widthScale * $i, 0, $widthScale * ($i + 1) - 1, $height, $black);
         }
     }
     //16px per bar-set, halved, minus 6px per char, halved (5*length)
     // $textcenter = $length * 5 * $widthScale;
     //$textcenter = ($length * 8 * $widthScale) - ($length * 3);
     //
     //        imageString($barcode, 2, $textcenter, $height-13, $text, $black);
     header("Content-type: image/png");
     // out out the image
     imagepng($barcode);
 }
开发者ID:grissoft,项目名称:aviapochta,代码行数:35,代码来源:barcode.php


示例2: create

 /**
  * 显示验证码
  */
 function create()
 {
     $this->image = imageCreate($this->width, $this->height);
     $this->back = $this->getColor($this->bgcolor);
     imageFilledRectangle($this->image, 0, 0, $this->width, $this->height, $this->back);
     $size = $this->width / $this->charLen - 4;
     if ($size > $this->height) {
         $size = $this->height;
     }
     $left = ($this->width - $this->charLen * ($size + $size / 10)) / $size + 5;
     $code = '';
     for ($i = 0; $i < $this->charLen; $i++) {
         $randKey = rand(0, count($this->arrChr) - 1);
         $randText = $this->arrChr[$randKey];
         $code .= $randText;
         $textColor = imageColorAllocate($this->image, rand(0, 100), rand(0, 100), rand(0, 100));
         $font = $this->fontPath . '/' . rand(1, 5) . ".ttf";
         $randsize = rand($size - $size / 10, $size + $size / 10);
         $location = $left + ($i * $size + $size / 10);
         @imagettftext($this->image, $randsize, rand(-18, 18), $location, rand($size - $size / 10, $size + $size / 10) + 2, $textColor, $font, $randText);
     }
     if ($this->showNoisePix == true) {
         $this->setNoisePix();
     }
     if ($this->showNoiseLine == true) {
         $this->setNoiseLine();
     }
     if ($this->showBorder == true) {
         $this->borderColor = $this->getColor($this->borderColor);
         imageRectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $this->borderColor);
     }
     $this->text = strtolower($code);
 }
开发者ID:beyondye,项目名称:ENPHP,代码行数:36,代码来源:Authcode.php


示例3: king_def

function king_def()
{
    global $king;
    header("Cache-Control: no-cache, must-revalidate");
    // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    // 过去的时间
    header("Content-type: image/png");
    $salt = kc_get('salt', 1, 1);
    $width = $king->config('verifywidth');
    //图片长度
    $height = $king->config('verifyheight');
    //图片高度
    $size = $king->config('verifysize');
    //文字大小
    $num = $king->config('verifynum');
    //文字数量
    $content = $king->config('verifycontent');
    //随机字符
    $array_content = explode('|', $content);
    $array_content = array_diff($array_content, array(null));
    $array_font = kc_f_getdir('system/verify_font', 'ttf|ttc');
    $str = '';
    $img = imageCreate($width, $height);
    //创建一个空白图像
    imageFilledRectangle($img, 0, 0, $width, $height, imagecolorallocate($img, 255, 255, 255));
    //写字
    for ($i = 0; $i < $num; $i++) {
        $code = $array_content[array_rand($array_content)];
        $str .= $code;
        //验证码字符
        $color = imageColorAllocate($img, rand(0, 128), rand(0, 128), rand(0, 128));
        $font = 'verify_font/' . $array_font[array_rand($array_font)];
        //随机读取一个字体
        $left = rand(round($size * 0.2), round($size * 0.4)) + $i * $size;
        imagettftext($img, rand(round($size * 0.7), $size), rand(-20, 20), $left, rand(round($size * 1.2), $size * 1.4), $color, $font, $code);
    }
    //画星号
    $max = $width * $height / 400;
    for ($i = 0; $i < $max; $i++) {
        imagestring($img, 15, rand(0, $width), rand(0, $height), '*', rand(192, 250));
    }
    //画点
    $max = $width * $height / 40;
    for ($i = 0; $i < $max; $i++) {
        imageSetPixel($img, rand(0, $width), rand(0, $height), rand(1, 200));
    }
    //画线
    $max = $width * $height / 800;
    for ($i = 0; $i < $max; $i++) {
        imageline($img, rand(0, $width), rand(0, $height), rand(0, $width), rand(0, $height), rand(0, 255));
    }
    //写验证码到verify中
    $verify = new KC_Verify_class();
    $verify->Put($salt, $str);
    imagePng($img);
    imageDestroy($img);
    $verify->Clear();
}
开发者ID:jonycookie,项目名称:projectm2,代码行数:59,代码来源:verify.php


示例4: updateBackground

    /**
     * Generates a wallpaper with the latest data and updates desktop background
     *
     * @param array $data Array with the latest build history per project
     */
    private function updateBackground($data)
    {
        $this->updatedAt = microtime(true);
        $this->image = imagecreatetruecolor($this->get('image_width'), $this->get('image_height'));
        imageantialias($this->image, true);
        $this->initializeColors();
        imagefill($this->image, 0, 0, $this->get('background_color'));
        $numProject = 0;
        foreach ($data['projects'] as $project => $builds) {
            // the most recent build is always shown on top
            rsort($builds);
            $x1 = $this->get('horizontal_padding') + ($this->get('bar_width') + $this->get('horizontal_gutter')) * $numProject;
            $x2 = $x1 + $this->get('bar_width');
            // plot each project slug
            $this->addTextToImage(substr($project, 0, $this->get('max_number_letters')), $x1, $this->get('vertical_padding') - 0.2 * $this->get('font_size'));
            foreach ($builds as $i => $build) {
                $y1 = $this->get('vertical_padding') + $this->get('font_size') + ($this->get('bar_height') + $this->get('vertical_gutter')) * $i;
                $y2 = $y1 + $this->get('bar_height');
                $color = 'ok' == $build ? $this->get('success_color') : $this->get('failure_color');
                // plot a bar for each project build
                imageFilledRectangle($this->image, $x1, $y1, $x2, $y2, $color);
            }
            $numProject++;
        }
        $this->addTextToImage('Last update: ' . $data['last_update'], $this->get('horizontal_padding'), $this->get('image_height') - $this->get('font_size'));
        // Hack: two different images are needed to update the wallpaper
        // One holds the current wallpaper and the other is the new one
        // If you use just one image and modify it, the OS doesn't reload it
        if (file_exists($this->evenBackgroundImagePath)) {
            $this->imagePath = $this->oddBackgroundImagePath;
            unlink($this->evenBackgroundImagePath);
        } elseif (file_exists($this->oddBackgroundImagePath)) {
            $this->imagePath = $this->evenBackgroundImagePath;
            unlink($this->oddBackgroundImagePath);
        } else {
            $this->imagePath = $this->oddBackgroundImagePath;
        }
        imagepng($this->image, $this->imagePath);
        imagedestroy($this->image);
        // Wallpaper is reloaded via AppleScript
        $scriptPath = $this->dir . '/update-background.scpt';
        file_put_contents($scriptPath, <<<END
tell application "System Events"
    tell current desktop
        set picture to POSIX file "file://localhost/{$this->imagePath}"
    end tell
end tell
END
);
        system("osascript {$scriptPath}");
    }
开发者ID:hyperlator,项目名称:Sismo,代码行数:56,代码来源:WallpaperNotifier.php


示例5: placeholder

 /**
  * Placeholder code adapted from dummyimage.com
  */
 public static function placeholder($width, $height)
 {
     $file_format = 'gif';
     $width = $width;
     $height = $height;
     $text_angle = 0;
     $font = Load::getModulePath('media') . 'assets/mplus-1c-medium.ttf';
     $img = imageCreate($width, $height);
     $bg_color = imageColorAllocate($img, 196, 196, 196);
     $fg_color = imageColorAllocate($img, 94, 94, 94);
     $lines = 1;
     $text = $width . 'x' . $height;
     $fontsize = max(min($width / strlen($text) * 1.15, $height * 0.5), 5);
     $textBox = self::_imagettfbbox_t($fontsize, $text_angle, $font, $text);
     $textWidth = ceil(($textBox[4] - $textBox[1]) * 1.07);
     $textHeight = ceil((abs($textBox[7]) + abs($textBox[1])) * 1);
     $textX = ceil(($width - $textWidth) / 2);
     $textY = ceil(($height - $textHeight) / 2 + $textHeight);
     imageFilledRectangle($img, 0, 0, $width, $height, $bg_color);
     imagettftext($img, $fontsize, $text_angle, $textX, $textY, $fg_color, $font, $text);
     $offset = 60 * 60 * 24 * 14;
     //14 Days
     $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
     header($ExpStr);
     //Set a far future expire date. This keeps the image locally cached by the user for less hits to the server.
     header('Cache-Control:	max-age=120');
     header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - $offset) . " GMT");
     header('Content-type: image/' . $file_format);
     //Set the header so the browser can interpret it as an image and not a bunch of weird text.
     switch ($file_format) {
         case 'gif':
             imagegif($img);
             break;
         case 'png':
             imagepng($img);
             break;
         case 'jpg':
             imagejpeg($img);
             break;
         case 'jpeg':
             imagejpeg($img);
             break;
     }
     imageDestroy($img);
     exit;
 }
开发者ID:simudream,项目名称:caffeine,代码行数:49,代码来源:image.php


示例6: _image

 /**
  * Make image
  *
  */
 protected function _image()
 {
     $this->_image = imagecreate($this->config['width'], $this->config['height']);
     imageFilledRectangle($this->_image, 0, 0, $this->config['width'], $this->config['height'], $this->_color($this->config['bgColor']));
     $seed = $this->_seed();
     $fonts = $this->_fonts();
     $_SESSION[$this->config['sessionValueKey']] = $seed;
     $_SESSION[$this->config['sessionTtlKey']] = time() + $this->config['ttl'];
     for ($i = 0; $i < $this->config['length']; $i++) {
         $char = substr($seed, $i, 1);
         $x = $this->config['padding'] + $i * ($this->config['size'] + $this->config['space']);
         $y = mt_rand(0.7 * $this->config['height'], 0.9 * $this->config['height']);
         $charColor = imageColorAllocate($this->_image, mt_rand(50, 155), mt_rand(50, 155), mt_rand(50, 155));
         imagettftext($this->_image, $this->config['size'], mt_rand(-18, 18), $x, $y, $charColor, $fonts[$i], $char);
     }
     $this->_noise();
 }
开发者ID:jianchengdu,项目名称:dangjia,代码行数:21,代码来源:Captcha.php


示例7: textToImg

function textToImg($text, $backRGB, $strRGB, $fontPath, $fontSize, $margin)
{
    // 大きさを測定
    $result = imageTTFBBox($fontSize, 0, $fontPath, $text);
    // 幅と高さを取得
    $width = abs($result[4]) + abs($result[6]) + $margin * 2;
    $height = abs($result[1]) + abs($result[7]) + $margin * 2;
    // イメージリソースを生成
    $img = imageCreateTrueColor($width, $height);
    // 色を生成
    $backColor = imageColorAllocate($img, $backRGB['red'], $backRGB['green'], $backRGB['blue']);
    $strColor = imageColorAllocate($img, $strRGB['red'], $strRGB['green'], $strRGB['blue']);
    // 背景を塗りつぶす
    imageFilledRectangle($img, 0, 0, $width, $height, $backColor);
    // 文字を描く
    imageTTFText($img, $fontSize, 0, $margin + abs($result[0]), $margin + abs($result[7]), $strColor, $fontPath, $text);
    return $img;
}
开发者ID:prince-0203,项目名称:JPMCPvP-Info,代码行数:18,代码来源:nyancounter.php


示例8: createTestImage

 /**
  * Create test image.
  *
  * @param string $filename
  * @return void
  */
 protected function createTestImage($filename)
 {
     $filename = $this->getFullPath($filename);
     if (!file_exists($filename)) {
         // Create an image with the specified dimensions
         $image = imageCreate(300, 200);
         // Create a color (this first call to imageColorAllocate
         //  also automatically sets the image background color)
         $colorYellow = imageColorAllocate($image, 255, 255, 0);
         // Draw a rectangle
         imageFilledRectangle($image, 50, 50, 250, 150, $colorYellow);
         $directory = dirname($filename);
         if (!file_exists($directory)) {
             mkdir($directory, 0777, true);
         }
         imageJpeg($image, $filename);
         // Release memory
         imageDestroy($image);
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:26,代码来源:MediaGallery.php


示例9: getPNG

 public function getPNG()
 {
     // создаем картинку
     $image = imageCreate($this->width + $this->widthLegend, $this->height);
     $backColor = imageColorAllocate($image, $this->colorBG >> 16, ($this->colorBG >> 8) % 256, $this->colorBG % 256);
     $centerColor = imageColorAllocate($image, $this->colorCenter >> 16, ($this->colorCenter >> 8) % 256, $this->colorCenter % 256);
     $pointsColor = imageColorAllocate($image, $this->colorPoints >> 16, ($this->colorPoints >> 8) % 256, $this->colorPoints % 256);
     $legendColor = imageColorAllocate($image, $this->colorLegend >> 16, ($this->colorLegend >> 8) % 256, $this->colorLegend % 256);
     // background
     imageFilledRectangle($image, 0, 0, $this->width, $this->height, $backColor);
     imageRectangle($image, $this->width, 0, $this->widthLegend + $this->width - 1, $this->height - 1, $legendColor);
     // добавляем масштаб в легенду
     imageLine($image, $this->width + 10, $this->height - $this->fontSize * 2 - 1, $this->width + 10, $this->height - $this->fontSize * 2 + 1, $legendColor);
     imageLine($image, $this->width + 10, $this->height - $this->fontSize * 2, $this->width + 20, $this->height - $this->fontSize * 2, $legendColor);
     imageLine($image, $this->width + 20, $this->height - $this->fontSize * 2 - 1, $this->width + 20, $this->height - $this->fontSize * 2 + 1, $legendColor);
     imageTTFText($image, $this->fontSize, 0, $this->width + $this->fontSize + 20, $this->height - $this->fontSize * 1.5, $legendColor, $this->pathToFont, "{$this->metersIn10Pix} {$this->metersLabel}");
     // center
     imageFilledEllipse($image, $this->centerWidth, $this->centerHeight, $this->sizePoints, $this->sizePoints, $centerColor);
     imageTTFText($image, $this->fontSize, 0, $this->centerWidth, $this->centerHeight + $this->fontSize + $this->sizePoints, $centerColor, $this->pathToFont, "0");
     imageTTFText($image, $this->fontSize, 0, $this->width + $this->fontSize, $this->fontSize * 2, $legendColor, $this->pathToFont, "0 - {$this->centerLabel}");
     // points
     $i = 1;
     foreach ($this->pointsBased as $v) {
         $angle = $v->getPoint()->getAzimuth() - 90;
         // угол для тригонометрии
         $pointWidth = $this->centerWidth + $this->k * ($v->getPoint()->getDistance() * cos(deg2rad($angle)));
         $pointHeight = $this->centerHeight + $this->k * ($v->getPoint()->getDistance() * sin(deg2rad($angle)));
         // рисуем точку
         imageEllipse($image, $pointWidth, $pointHeight, $this->sizePoints, $this->sizePoints, $pointsColor);
         // подпись
         imageTTFText($image, $this->fontSize, 0, $pointWidth, $pointHeight + $this->fontSize + $this->sizePoints, $pointsColor, $this->pathToFont, $i);
         // в легенду
         imageTTFText($image, $this->fontSize, 0, $this->width + $this->fontSize, $this->fontSize * 2 * ($i + 1), $legendColor, $this->pathToFont, "{$i} - " . $v->getTitle());
         $i++;
     }
     ob_start();
     imagePng($image);
     $str = ob_get_clean();
     return $str;
 }
开发者ID:arsenyru,项目名称:geodata,代码行数:40,代码来源:Visual.php


示例10: show

 public static function show()
 {
     $width = self::$width;
     $height = self::$height;
     $len = self::$len;
     $bgcolor = self::$bgcolor;
     $noise = self::$noise;
     $noisenum = self::$noisenum;
     $border = self::$border;
     $bordercolor = self::$bordercolor;
     self::$_image = imageCreate($width, $height);
     $back = self::getcolor($bgcolor);
     imageFilledRectangle(self::$_image, 0, 0, $width, $height, $back);
     $size = $width / $len;
     if ($size > $height) {
         $size = $height;
     }
     $left = ($width - $len * ($size + $size / 10)) / $size;
     for ($i = 0; $i < $len; $i++) {
         $randtext = self::vchar();
         self::$_code .= $randtext;
         $textColor = imageColorAllocate(self::$_image, rand(0, 100), rand(0, 100), rand(0, 100));
         $font = dirname(__FILE__) . "/3.ttf";
         $randsize = rand($size - $size / 5, $size - $size / 10);
         $location = $left + ($i * $size + $size / 10);
         imagettftext(self::$_image, $randsize, rand(-18, 18), $location, rand($size - $size / 100, $size + $size / 100), $textColor, $font, $randtext);
     }
     if ($noise == true) {
         self::setnoise();
     }
     self::setCode(self::$_code);
     //setrawcookie("code",$code,time()+3600,"/");
     //setcookie("code", $code, time()+120);
     $bordercolor = self::getcolor($bordercolor);
     if ($border == true) {
         imageRectangle(self::$_image, 0, 0, $width - 1, $height - 1, $bordercolor);
     }
     return self::$_image;
 }
开发者ID:isonz,项目名称:fxptpcn,代码行数:39,代码来源:Vcode.class.php


示例11: show

 /**
  * 显示验证码
  *
  */
 function show()
 {
     $this->image = imageCreate($this->width, $this->height);
     $this->back = $this->getColor($this->bgcolor);
     imageFilledRectangle($this->image, 0, 0, $this->width, $this->height, $this->back);
     $size = $this->width / $this->charLen - 4;
     if ($size > $this->height) {
         $size = $this->height;
     }
     $left = ($this->width - $this->charLen * ($size + $size / 10)) / $size + 5;
     $code = '';
     for ($i = 0; $i < $this->charLen; $i++) {
         $randKey = rand(0, count($this->arrChr) - 1);
         $randText = $this->arrChr[$randKey];
         $code .= $randText;
         $textColor = imageColorAllocate($this->image, rand(0, 100), rand(0, 100), rand(0, 100));
         $font = $this->fontPath . "1.ttf";
         $randsize = rand($size - $size / 10, $size + $size / 10);
         $location = $left + ($i * $size + $size / 10);
         imagestring($this->image, mt_rand(3, 5), $location, 5, $randText, imagecolorallocate($this->image, mt_rand(0, 100), mt_rand(0, 150), mt_rand(0, 200)));
         //imagettftext($this->image, $randsize, rand(- 18, 18), $location, rand($size - $size / 10, $size + $size / 10) + 2, $textColor, $font, $code);
     }
     if ($this->showNoisePix == true) {
         $this->setNoisePix();
     }
     if ($this->showNoiseLine == true) {
         $this->setNoiseLine();
     }
     if ($this->showBorder == true) {
         $this->borderColor = $this->getColor($this->borderColor);
         imageRectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $this->borderColor);
     }
     $this->CI->session->set_userdata('auth_code', $code);
     ob_clean();
     header("Content-type: image/jpeg");
     imagejpeg($this->image);
     imagedestroy($this->image);
 }
开发者ID:Chiachy,项目名称:hr_ecjtu_net,代码行数:42,代码来源:Authcode.php


示例12: output

 private function output($saveStr = false)
 {
     $this->image = ImageCreate($this->larguaImagem, $this->alturaImagem);
     $background = $this->color($this->corDeFundo);
     imageFilledRectangle($this->image, 0, 0, $this->larguaImagem, $this->alturaImagem, $background);
     srand($this->make_seed());
     # space in chars
     $percent80 = $this->larguaImagem - $this->larguaImagem * 0.15;
     #$textSpace = ceil(($this->larguaImagem-40)/$this->maxChars) ;
     $textSpace = ceil($percent80 / $this->maxChars);
     $topMargim = $this->alturaImagem > 20 ? $this->alturaImagem / 2.2 : 5;
     # generate chars
     for ($i = 0; $i < $this->maxChars; $i++) {
         $this->gerarValor = str_shuffle($this->gerarValor);
         shuffle($this->hexcolors);
         shuffle($this->fonts);
         # select a char on array
         $char = $this->gerarValor[0];
         # rotarion of chars
         $rotate = $this->rotateImg > 1 ? rand(-9, 10) : 0;
         # join chars value
         $saveStr .= $char;
         # make captcha
         imagettftext($this->image, $this->fontSize, $rotate, 10 + $i * $textSpace, rand($this->alturaImagem, $topMargim), $this->randcolor(), "{$this->serverRoot}{$this->path}{$this->fonts[0]}", $char);
     }
     for ($k = 0; $k < $this->maxChars / 2; $k++) {
         if ($this->noSquare == 0) {
             $this->randsquare();
         }
         $this->randline();
     }
     header("Content-type: image/jpeg");
     imagejpeg($this->image);
     imagedestroy($this->image, '', 100);
     return $saveStr;
 }
开发者ID:vortexacm,项目名称:acmback,代码行数:36,代码来源:class.captcha.php


示例13: draw_rectangle

 function draw_rectangle($x1, $y1, $x2, $y2, $color, $filled)
 {
     if ($filled) {
         imageFilledRectangle($this->image, $x1, $y1, $x2, $y2, $color);
     } else {
         imageRectangle($this->image, $x1, $y1, $x2, $y2, $color);
     }
 }
开发者ID:cjbayliss,项目名称:alloc,代码行数:8,代码来源:task_graph.inc.php


示例14: abs

// this works because Julian dates specify an absolute number
// of days -> the difference between Julian birthday and
// "Julian today" gives the number of days alive
$daysGone = abs(gregorianToJD($birthMonth, $birthDay, $birthYear) - gregorianToJD(date("m"), date("d"), date("Y")));
// create image
$image = imageCreate($diagramWidth, $diagramHeight);
// allocate all required colors
$colorBackgr = imageColorAllocate($image, 192, 192, 192);
$colorForegr = imageColorAllocate($image, 255, 255, 255);
$colorGrid = imageColorAllocate($image, 0, 0, 0);
$colorCross = imageColorAllocate($image, 0, 0, 0);
$colorPhysical = imageColorAllocate($image, 0, 0, 255);
$colorEmotional = imageColorAllocate($image, 255, 0, 0);
$colorIntellectual = imageColorAllocate($image, 0, 255, 0);
// clear the image with the background color
imageFilledRectangle($image, 0, 0, $diagramWidth - 1, $diagramHeight - 1, $colorBackgr);
// calculate start date for diagram and start drawing
$nrSecondsPerDay = 60 * 60 * 24;
$diagramDate = time() - $daysToShow / 2 * $nrSecondsPerDay + $nrSecondsPerDay;
for ($i = 1; $i < $daysToShow; $i++) {
    $thisDate = getDate($diagramDate);
    $xCoord = $diagramWidth / $daysToShow * $i;
    // draw day mark and day number
    imageLine($image, $xCoord, $diagramHeight - 25, $xCoord, $diagramHeight - 20, $colorGrid);
    imageString($image, 3, $xCoord - 5, $diagramHeight - 16, $thisDate["mday"], $colorGrid);
    $diagramDate += $nrSecondsPerDay;
}
// draw rectangle around diagram (marks its boundaries)
imageRectangle($image, 0, 0, $diagramWidth - 1, $diagramHeight - 20, $colorGrid);
// draw middle cross
imageLine($image, 0, ($diagramHeight - 20) / 2, $diagramWidth, ($diagramHeight - 20) / 2, $colorCross);
开发者ID:ASeptiadi,项目名称:TugasBesar,代码行数:31,代码来源:biorhythm.php


示例15: imageFilledRectangle

 protected function imageFilledRectangle($x1, $y1, $x2, $y2, $color)
 {
     $color = $this->gdColor($color);
     if ($color === false) {
         return false;
     }
     return imageFilledRectangle($this->image, $x1, $y1, $x2, $y2, $color);
 }
开发者ID:osfed,项目名称:l4crud,代码行数:8,代码来源:class_image_gd.php


示例16: cforms2_reset_captcha


//.........这里部分代码省略.........
        $angle = mt_rand($min_angle, $max_angle);
        $bbox = ImageTTFBBox($size, $angle, $font, $char);
        $char_width = max($bbox[2], $bbox[4]) - min($bbox[0], $bbox[6]);
        $char_height = max($bbox[1], $bbox[3]) - min($bbox[7], $bbox[5]);
        $codelen = $codelen + $char_width + $char_padding;
        $image_width += $char_width + $char_padding;
        $image_height = max($image_height, $char_height);
        $data[] = array('char' => $char, 'size' => $size, 'angle' => $angle, 'height' => $char_height, 'width' => $char_width);
    }
    ### calculate the final image size, adding some padding
    $x_padding = 12;
    if ($img_sz_type == 1) {
        $image_width += $x_padding * 2;
        $image_height = $image_height * 1.5 + 2;
    } else {
        $image_width = $img_sz_width;
        $image_height = $img_sz_height;
    }
    ### build the image, and allocte the colors
    $im = ImageCreate($image_width, $image_height);
    $d1 = $d2 = $d3 = 0;
    while ($d1 < 50 and $d2 < 50 and $d3 < 50) {
        $r = mt_rand(200, 255);
        $g = mt_rand(200, 255);
        $b = mt_rand(200, 255);
        $d1 = abs($r - $g);
        $d2 = abs($r - $b);
        $d3 = abs($g - $b);
    }
    ImageColorAllocate($im, $r, $g, $b);
    $color_border = ImageColorAllocate($im, $border_r, $border_g, $border_b);
    ImageColorAllocate($im, round($r * 0.85), round($g * 0.85), round($b * 0.85));
    ImageColorAllocate($im, round($r * 0.95), round($g * 0.95), round($b * 0.95));
    ImageColorAllocate($im, round($r * 0.9), round($g * 0.9), round($b * 0.9));
    $d1 = mt_rand(0, 50);
    $d2 = mt_rand(0, 50);
    $d3 = mt_rand(0, 50);
    $d1 = $d2 = $d3 = 0;
    while ($d1 < 100 and $d2 < 100 and $d3 < 100) {
        $r = mt_rand(0, 150);
        $g = mt_rand(0, 150);
        $b = mt_rand(0, 150);
        $d1 = abs($r - $g);
        $d2 = abs($r - $b);
        $d3 = abs($g - $b);
    }
    switch ($col_txt_type) {
        case 1:
            $col_txt = ImageColorAllocate($im, $r, $g, $b);
            break;
        case 2:
            $col_txt = ImageColorAllocate($im, 0, 0, 0);
            break;
        case 3:
            $col_txt = ImageColorAllocate($im, 255, 255, 255);
            break;
        case 4:
            $col_txt = ImageColorAllocate($im, $col_txt_r, $col_txt_g, $col_txt_b);
            break;
    }
    $image_data = getimagesize($im_bg_url);
    $image_type = $image_data[2];
    if ($image_type == 1) {
        $img_src = imagecreatefromgif($im_bg_url);
    } elseif ($image_type == 2) {
        $img_src = imagecreatefromjpeg($im_bg_url);
    } elseif ($image_type == 3) {
        $img_src = imagecreatefrompng($im_bg_url);
    }
    if ($im_bg_type == 1) {
        imagesettile($im, $img_src);
        imageFilledRectangle($im, 0, 0, $image_width, $image_height, IMG_COLOR_TILED);
    } else {
        imagecopyresampled($im, $img_src, 0, 0, 0, 0, $image_width, $image_height, $image_data[0], $image_data[1]);
    }
    $pos_x = ($image_width - $codelen) / 2;
    foreach ($data as $d) {
        $pos_y = ($image_height + $d['height']) / 2;
        ImageTTFText($im, $d['size'], $d['angle'], $pos_x, $pos_y, $col_txt, $font, $d['char']);
        $pos_x += $d['width'] + $char_padding;
    }
    ### a nice border
    ImageRectangle($im, 0, 0, $image_width - 1, $image_height - 1, $color_border);
    // There can be some output from other loaded PHP files, therefore clean output.
    ob_end_clean();
    switch ($output_type) {
        case 'jpeg':
            Header('Content-type: image/jpeg');
            ImageJPEG($im, NULL, 100);
            break;
        case 'png':
        default:
            Header('Content-type: image/png');
            ImagePNG($im);
            break;
    }
    flush();
    ImageDestroy($im);
    die;
}
开发者ID:vanie3,项目名称:sierra-wordpress,代码行数:101,代码来源:cforms-captcha.php


示例17: makeThumb

 function makeThumb($width = 128, $height = 128)
 {
     $image_info = $this->getInfo($this->src_image_name);
     if (!$image_info) {
         return false;
     }
     $src_image_type = $image_info["type"];
     $img = $this->createImage($src_image_type, $this->src_image_name);
     if (!$img) {
         return false;
     }
     $width = $width == 0 ? $image_info["width"] : $width;
     $height = $height == 0 ? $image_info["height"] : $height;
     $width = $width > $image_info["width"] ? $image_info["width"] : $width;
     $height = $height > $image_info["height"] ? $image_info["height"] : $height;
     $srcW = $image_info["width"];
     $srcH = $image_info["height"];
     if ($srcH * $width > $srcW * $height) {
         $width = round($srcW * $height / $srcH);
     } else {
         $height = round($srcH * $width / $srcW);
     }
     //*
     $new = @imagecreatetruecolor($width, $height);
     $white = @imagecolorallocate($new, 0xff, 0xff, 0xff);
     @imagefilltoborder($new, 0, 0, $white, $white);
     if ($new) {
         $backgroundColor = @imageColorAllocate($new, 255, 255, 255);
         @imageFilledRectangle($new, 0, 0, $width - 1, $height - 1, $backgroundColor);
         ImageCopyResampled($new, $img, 0, 0, 0, 0, $width, $height, $image_info["width"], $image_info["height"]);
     } else {
         $new = imagecreate($width, $height);
         $backgroundColor = @imageColorAllocate($new, 255, 255, 255);
         @imageFilledRectangle($new, 0, 0, $width - 1, $height - 1, $backgroundColor);
         ImageCopyResized($new, $img, 0, 0, 0, 0, $width, $height, $image_info["width"], $image_info["height"]);
     }
     //*/
     if ($this->save_file) {
         switch ($src_image_type) {
             case 1:
                 if ($this->gif_enable) {
                     $src_img = ImageGIF($new, $this->save_file);
                 } else {
                     $src_img = ImagePNG($new, $this->save_file);
                 }
                 break;
             case 2:
                 $src_img = ImageJPEG($new, $this->save_file, $this->jpeg_quality);
                 break;
             case 3:
                 $src_img = ImagePNG($new, $this->save_file);
                 break;
             default:
                 $src_img = ImageJPEG($new, $this->save_file, $this->jpeg_quality);
                 break;
         }
     } else {
         switch ($src_image_type) {
             case 1:
                 if ($this->gif_enable) {
                     header("Content-type: image/gif");
                     $src_img = ImageGIF($new);
                 } else {
                     header("Content-type: image/png");
                     $src_img = ImagePNG($new);
                 }
                 break;
             case 2:
                 header("Content-type: image/jpeg");
                 $src_img = ImageJPEG($new, "", $this->jpeg_quality);
                 break;
             case 3:
                 header("Content-type: image/png");
                 $src_img = ImagePNG($new);
                 break;
             default:
                 header("Content-type: image/jpeg");
                 $src_img = ImageJPEG($new, "", $this->jpeg_quality);
                 break;
         }
     }
     ImageDestroy($new);
     ImageDestroy($img);
     return true;
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:85,代码来源:mdl.gdimage.php


示例18: foreach

    foreach ($per_host as $index => $percent) {
        $week_day++;
        if ($week_day > 6) {
            $week_day -= 7;
        }
        if ($index / 2 == (int) ($index / 2)) {
            $color = imageColorAllocate($img, 249, 243, 70);
            $color2 = imageColorAllocate($img, 242, 226, 42);
            $color3 = imageColorAllocate($img, 226, 210, 34);
        } else {
            $color = imageColorAllocate($img, 11, 215, 252);
            $color2 = imageColorAllocate($img, 7, 203, 239);
            $color3 = imageColorAllocate($img, 7, 187, 219);
        }
        $y1 = round($imageW - $imageW * $percent + 12);
        imageFilledRectangle($img, $x1, $y1, $x2, $y2, $color);
        $points = array(0 => $x1, 1 => $y1, 2 => $x1 + 3, 3 => $y1 - 5, 4 => $x1 + $collW + 3, 5 => $y1 - 5, 6 => $x2, 7 => $y1);
        imageFilledPolygon($img, $points, 4, $color2);
        $points = array(0 => $x2, 1 => $y1, 2 => $x1 + $collW + 3, 3 => $y1 - 5, 4 => $x1 + $collW + 3, 5 => $y2 - 5, 6 => $x2, 7 => $y2);
        imageFilledPolygon($img, $points, 4, $color3);
        // imageTTFtext($img, 7, 90, $x1+8, 50, $colorBlack, BASEDIR.'/assets/fonts/font.ttf', $host_data[$index]);
        imagestringup($img, 1, $x1 + 3, 52, $host_data[$index], $colorBlack);
        imageTTFtext($img, 6, 0, $x1 + 3, 66, $colorBlack, BASEDIR . '/assets/fonts/font.ttf', $arr_week[$week_day]);
        $x1 += $collW;
        $x2 += $collW;
    }
    //Header("Content-type: image/gif");
    ImageGIF($img, BASEDIR . $imagecache);
    ImageDestroy($img);
}
echo '<img src="' . $imagecache . '?' . date_fixed(SITETIME, "dmY") . '" alt="Неделя" /><br /><br />';
开发者ID:visavi,项目名称:rotorcms4,代码行数:31,代码来源:counter7.php


示例19: check_selection_main

function check_selection_main()
{
    //global $b_row;
    # check the status of the block.
    ###################################################
    if (USE_LOCK_TABLES == 'Y') {
        $sql = "LOCK TABLES blocks WRITE, temp_orders WRITE, currencies READ, prices READ, banners READ";
        $result = mysql_query($sql) or die(" <b>Dear Webmaster: The current MySQL user does not have permission to lock tables. Please give this user permission to lock tables, or turn off locking in the Admin. To turn off locking in the Admin, please go to Main Config and look under the MySQL Settings.<b>");
    } else {
        // poor man's lock
        $sql = "UPDATE `config` SET `val`='YES' WHERE `key`='SELECT_RUNNING' AND `val`='NO' ";
        $result = mysql_query($sql) or die(mysql_error());
        if (mysql_affected_rows() == 0) {
            // make sure it cannot be locked for more than 30 secs
            // This is in case the proccess fails inside the lock
            // and does not release it.
            $unix_time = time();
            // get the time of last run
            $sql = "SELECT * FROM `config` where `key` = 'LAST_SELECT_RUN' ";
            $result = @mysql_query($sql);
            $t_row = @mysql_fetch_array($result);
            if ($unix_time > $t_row['val'] + 30) {
                // release the lock
                $sql = "UPDATE `config` SET `val`='NO' WHERE `key`='SELECT_RUNNING' ";
                $result = @mysql_query($sql) or die(mysql_error());
                // update timestamp
                $sql = "REPLACE INTO config (`key`, `val`) VALUES ('LAST_SELECT_RUN', '{$unix_time}')  ";
                $result = @mysql_query($sql) or die(mysql_error());
            }
            usleep(5000000);
            // this function is executing in another process. sleep for half a second
            check_selection_main();
            return;
        }
    }
    ####################################################
    $upload_image_file = get_tmp_img_name();
    $size = getimagesize($upload_image_file);
    $new_size = get_required_size($size[0], $size[1]);
    $block_id = $_REQUEST['block_id'];
    //print_r($_REQUEST);
    // get width and height of uploaded image
    //echo "[".$size[0]." ".$size[1]."] ";
    //echo $block_id;
    if (function_exists("imagecreatetruecolor")) {
        $dest = imagecreatetruecolor(BLK_WIDTH, BLK_HEIGHT);
        $whole_image = imagecreatetruecolor($new_size[0], $new_size[1]);
    } else {
        $dest = imagecreate(BLK_WIDTH, BLK_HEIGHT);
        $whole_image = imagecreate($new_size[0], $new_size[1]);
    }
    $parts = split('\\.', $upload_image_file);
    $ext = strtolower(array_pop($parts));
    //echo $ext."($upload_image_file)\n";
    switch ($ext) {
        case 'jpeg':
        case 'jpg':
            $upload_image = imagecreatefromjpeg($upload_image_file);
            break;
        case 'gif':
            $upload_image = imagecreatefromgif($upload_image_file);
            break;
        case 'png':
            $upload_image = imagecreatefrompng($upload_image_file);
            break;
    }
    // create the requ
    //$imagebg = imageCreateFromPNG (SERVER_PATH_TO_ADMIN.'temp/block.png'); // transparent PNG
    //echo GRID_BLOCK;
    $imagebg = imageCreateFromstring(GRID_BLOCK);
    imageSetTile($whole_image, $imagebg);
    imageFilledRectangle($whole_image, 0, 0, $new_size[0], $new_size[1], IMG_COLOR_TILED);
    imagecopy($whole_image, $upload_image, 0, 0, 0, 0, $size[0], $size[1]);
    //imagepng($whole_image);
    for ($i = 0; $i < $size[1]; $i += BLK_HEIGHT) {
        for ($j = 0; $j < $size[0]; $j += BLK_WIDTH) {
            $map_x = $j + $_REQUEST['map_x'];
            $map_y = $i + $_REQUEST['map_y'];
            $r_x = $map_x;
            $r_y = $map_y;
            //echo "map_x: $map_x map_y: $map_y \n";
            $GRD_WIDTH = BLK_WIDTH * G_WIDTH;
            $cb = $map_x / BLK_WIDTH + $map_y / BLK_HEIGHT * ($GRD_WIDTH / BLK_WIDTH);
            $in_str = $in_str . "{$comma}{$cb}";
            $comma = ',';
            $block_info[$cb]['map_x'] = $map_x;
            $block_info[$cb]['map_y'] = $map_y;
            // bool imagecopy ( resource dst_im, resource src_im, int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h )
            imagecopy($dest, $whole_image, 0, 0, $j, $i, BLK_WIDTH, BLK_HEIGHT);
            //echo "imagecopy ( $dest, $whole_image, 0, 0, $j, $i, ".BLK_HEIGHT.", '".BLK_WIDTH."' );";
            ob_start();
            imagepng($dest);
            $data = ob_ge 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imageGIF函数代码示例发布时间:2022-05-15
下一篇:
PHP imageFill函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap