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);
    
  • 相关阅读:
    无名信号量在多线程间的同步
    ftok函数例子
    strerror和perror函数详解
    lockf函数的使用
    背包问题-2动态规划【正解】
    递归思想即背包问题
    生产者消费者问题(基于线程和无名信号量)
    eclipse 安装python后pydev不出现
    Eclipse+pydev解决中文显示和注释问题的方法大全
    MyEclipse10配置PyDev进行Python开发
  • 原文地址:https://www.cnblogs.com/xiaozhang666/p/11141676.html
Copyright © 2011-2022 走看看