zoukankan      html  css  js  c++  java
  • PHP绘图案例讲解验证码制作

    <?php
    header("Content-type: image/png");//声明浏览器解析为图片
    $width=200;
    $height=100;
    $color1=imagecreate($width,$height); //绘制一个画布
    
    
        imagecolorallocate($color1, 60, 60, 40);//设置此选项后,画的点或者是线连接之后回成团,带颜色
        $color_T=imagecolorallocate($color1, rand(200,255), rand(200,255), rand(200,255));//随机数取颜色
        //矩形边框的颜色
        $color_B=imagecolorallocate($color1, rand(200,255), rand(200,255), rand(200,255));
        //字体颜色
        $colorString=imagecolorallocate($color1, rand(10,100), rand(10,100), rand(10,100));
        //画点    循环
        for($i=0;$i<100;$i++){
            imagesetpixel($color1, rand(0,$width-1), rand(0,$height-1),
                imagecolorallocate($color1, rand(100,200), rand(100,200), rand(100,200)));//画点函数
        }
        //画线
        for ($j=0;$j<5;$j++){
            imageline($color1, rand(0,$width-30),rand(0,$height), rand(0,$width/2),rand(0,$height),
                imagecolorallocate($color1, rand(100,200), rand(100,200), rand(100,200)));//画线函数
        }
    
        //写字
        /* imagestring($color1, 50, 0, 0, 'abcf', $colorString); *///两个不同的写字函数
        imagettftext($color1, 30,20, 0, 40, $colorString,'COMSC.TTF', 'abcv');//两个不同的写字函数
        //-------------------------------------------------------
        imagefill($color1, 0, 0, $color_T);//图像着色
        //画一个矩形
        imagerectangle($color1,0,0,$width-1, $height-1, $color_B);
        imagepng($color1);
    
  • 相关阅读:
    20.multi_case04
    Linux 性能监测:Memory
    Linux 性能监测:介绍
    Linux 性能监测:CPU
    服务器压力上不去原因分析
    Oracle数据库shutdown immediate被hang住的几个原因
    性能测试需求指标分析方法
    关于spotlight for Windows和spotlight for oracle的使用
    Oracle性能监控脚本(sql)
    Oracle 常用性能监控SQL语句
  • 原文地址:https://www.cnblogs.com/xiaozhang666/p/11141676.html
Copyright © 2011-2022 走看看