zoukankan      html  css  js  c++  java
  • 用gd库画矩形和椭圆

    画矩形:bool imagerectangle ( resource $image画布资源 , int $x1左上角的坐标 , int $y1 , int $x2 右下角坐标, int $y2 , int $col颜色 )

    填充颜色用imagefilledrectangle();参数和上面的一样

    画椭圆:bool imageellipse ( resource $image , int $cx中心坐标 , int $cy , int $width宽度 , int $height高度 , int $color颜色)

    画圆弧:bool imagearc ( resource $image , int $cx中心坐标 , int $cy , int $width宽度 , int $height高度 , int $start起始角度 , int $end结束角度 , int $color颜色)顺时针计算

    画圆弧填充颜色,bool imagefilledarc ( resource $image , int $cx , int $cy , int $width , int $height , int $start , int $end , int $color , int $style 样式)

    style

    值可以是下列值的按位或(OR):

    1. IMG_ARC_PIE
    2. IMG_ARC_CHORD
    3. IMG_ARC_NOFILL
    4. IMG_ARC_EDGED

    可以用数字相加来叠加多个方式的效果

    <?php
    //画矩形和椭圆
    
    //画布
    $rs=imagecreatetruecolor(600,400);
    
    //颜料
    $gray=imagecolorallocate($rs,200,200,200);
    $red=imagecolorallocate($rs,255,0,0);
    $green=imagecolorallocate($rs,0,255,0);
    $blue=imagecolorallocate($rs,0,0,255);
    
    
    //绘画
    //画矩形
    imagerectangle($rs,100,50,500,350,$gray);
    //填充颜色
    imagefill($rs,0,0,$red);
    
    //画椭圆
    imagefilledellipse($rs,300,200,400,300,$green);
    imagefilledellipse($rs,300,200,300,300,$blue);
    imagefilledellipse($rs,300,200,200,300,$green);
    imagefilledellipse($rs,300,200,100,300,$blue);
    //输出
    header('content-type:image/jpeg');
    imagejpeg($rs);
    
    
    //销毁对象
    imagedestroy($rs);
    
    
    ?>
    
    
    <?php
    //画圆弧
    
    //画布
    $rs=imagecreatetruecolor(600,400);
    
    //颜料
    $gray=imagecolorallocate($rs,200,200,200);
    $red=imagecolorallocate($rs,255,0,0);
    $green=imagecolorallocate($rs,0,255,0);
    $blue=imagecolorallocate($rs,0,0,255);
    
    
    //绘画
    //画矩形
    imagerectangle($rs,100,50,500,350,$gray);
    //填充颜色
    imagefill($rs,0,0,$red);
    
    //画圆弧
    imagearc($rs,300,200,200,150,90,180,$green);
    
    //如果填充颜色用
    imagefilledarc($rs,300,200,200,150,185,275,$blue,1+4);
    //输出
    header('content-type:image/jpeg');
    imagejpeg($rs);
    
    
    //销毁对象
    imagedestroy($rs);
    
    
    
    ?>
    
  • 相关阅读:
    几个不错的网页载入页面
    .NET 中关于日期时间的格式化处理
    防止网站内容被人小偷和采集的ASP代码
    .Net学习资源集
    Net程序如何防止被注入(整站通用)
    一个采集入库生成本地文件的几个FUCTION
    网页数据采集小偷
    浅谈自动采集程序及入库
    网页图片处理JS代码整理
    spark导入工程后,出现一些错误
  • 原文地址:https://www.cnblogs.com/lzzhuany/p/4793096.html
Copyright © 2011-2022 走看看