site help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tasheeta@gmail.com

    #1

    site help

    ok something is missing or what not... its driving me nuts.
    stupidralph, i recall that u are a coder. what is missing???

    <?

    class textPNG {
    var $font = 'fonts/TIMES.TTF';
    var $msg = "undefined" ;
    var $size = 24;
    var $rot = 0;
    var $pad = 0;
    var $transparent = 1;
    var $red = 0;
    var $grn = 0;
    var $blu = 0;
    var $bg_red = 255;
    var $bg_grn = 255;
    var $bg_blu = 255;

    function draw() {
    $width = 0;
    $height = 0;
    $offset_x = 0;
    $offset_y = 0;
    $bounds = array();
    $image = "";

    $bounds = ImageTTFBBox($t his->size, $this->rot, $this->font, "W");
    if ($this->rot < 0) {
    $font_height = abs($bounds[7]-$bounds[1]);
    } else if ($this->rot > 0) {
    $font_height = abs($bounds[1]-$bounds[7]);
    } else {
    $font_height = abs($bounds[7]-$bounds[1]);
    }

    $bounds = ImageTTFBBox($t his->size, $this->rot, $this->font,
    $this->msg);
    if ($this->rot < 0) {
    $width = abs($bounds[4]-$bounds[0]);
    $height = abs($bounds[3]-$bounds[7]);
    $offset_y = $font_height;
    $offset_x = 0;

    } else if ($this->rot > 0) {
    $width = abs($bounds[2]-$bounds[6]);
    $height = abs($bounds[1]-$bounds[5]);
    $offset_y = abs($bounds[7]-$bounds[5])+$font_height;
    $offset_x = abs($bounds[0]-$bounds[6]);

    } else {
    $width = abs($bounds[4]-$bounds[6]);
    $height = abs($bounds[7]-$bounds[1]);
    $offset_y = $font_height;;
    $offset_x = 0;
    }

    $image = imagecreate($wi dth+($this->pad*2)+1,$heig ht+($this->pad*2)+1);

    $background = ImageColorAlloc ate($image, $this->bg_red, $this->bg_grn,
    $this->bg_blu);
    $foreground = ImageColorAlloc ate($image, $this->red, $this->grn,
    $this->blu);

    if ($this->transparent) ImageColorTrans parent($image, $background);
    ImageInterlace( $image, false);

    ImageTTFText($i mage, $this->size, $this->rot, $offset_x+$this->pad,
    $offset_y+$this->pad, $foreground, $this->font, $this->msg);

    imagePNG($image );
    }
    }

    $text = new textPNG;

    if (isset($msg)) $text->msg = $msg;
    if (isset($font)) $text->font = $font;
    if (isset($size)) $text->size = $size;
    if (isset($rot)) $text->rot = $rot;
    if (isset($pad)) $text->pad = $pad;
    if (isset($red)) $text->red = $red;
    if (isset($grn)) $text->grn = $grn;
    if (isset($blu)) $text->blu = $blu;
    if (isset($bg_red) ) $text->bg_red = $bg_red;
    if (isset($bg_grn) ) $text->bg_grn = $bg_grn;
    if (isset($bg_blu) ) $text->bg_blu = $bg_blu;
    if (isset($tr)) $text->transparent = $tr;

    $text->draw();
    ?>

  • Jerry Stuckle

    #2
    Re: site help

    tasheeta@gmail. com wrote:[color=blue]
    > ok something is missing or what not... its driving me nuts.
    > stupidralph, i recall that u are a coder. what is missing???
    >
    > <?
    >
    > class textPNG {
    > var $font = 'fonts/TIMES.TTF';
    > var $msg = "undefined" ;
    > var $size = 24;
    > var $rot = 0;
    > var $pad = 0;
    > var $transparent = 1;
    > var $red = 0;
    > var $grn = 0;
    > var $blu = 0;
    > var $bg_red = 255;
    > var $bg_grn = 255;
    > var $bg_blu = 255;
    >
    > function draw() {
    > $width = 0;
    > $height = 0;
    > $offset_x = 0;
    > $offset_y = 0;
    > $bounds = array();
    > $image = "";
    >
    > $bounds = ImageTTFBBox($t his->size, $this->rot, $this->font, "W");
    > if ($this->rot < 0) {
    > $font_height = abs($bounds[7]-$bounds[1]);
    > } else if ($this->rot > 0) {
    > $font_height = abs($bounds[1]-$bounds[7]);
    > } else {
    > $font_height = abs($bounds[7]-$bounds[1]);
    > }
    >
    > $bounds = ImageTTFBBox($t his->size, $this->rot, $this->font,
    > $this->msg);
    > if ($this->rot < 0) {
    > $width = abs($bounds[4]-$bounds[0]);
    > $height = abs($bounds[3]-$bounds[7]);
    > $offset_y = $font_height;
    > $offset_x = 0;
    >
    > } else if ($this->rot > 0) {
    > $width = abs($bounds[2]-$bounds[6]);
    > $height = abs($bounds[1]-$bounds[5]);
    > $offset_y = abs($bounds[7]-$bounds[5])+$font_height;
    > $offset_x = abs($bounds[0]-$bounds[6]);
    >
    > } else {
    > $width = abs($bounds[4]-$bounds[6]);
    > $height = abs($bounds[7]-$bounds[1]);
    > $offset_y = $font_height;;
    > $offset_x = 0;
    > }
    >
    > $image = imagecreate($wi dth+($this->pad*2)+1,$heig ht+($this->pad*2)+1);
    >
    > $background = ImageColorAlloc ate($image, $this->bg_red, $this->bg_grn,
    > $this->bg_blu);
    > $foreground = ImageColorAlloc ate($image, $this->red, $this->grn,
    > $this->blu);
    >
    > if ($this->transparent) ImageColorTrans parent($image, $background);
    > ImageInterlace( $image, false);
    >
    > ImageTTFText($i mage, $this->size, $this->rot, $offset_x+$this->pad,
    > $offset_y+$this->pad, $foreground, $this->font, $this->msg);
    >
    > imagePNG($image );
    > }
    > }
    >
    > $text = new textPNG;
    >
    > if (isset($msg)) $text->msg = $msg;
    > if (isset($font)) $text->font = $font;
    > if (isset($size)) $text->size = $size;
    > if (isset($rot)) $text->rot = $rot;
    > if (isset($pad)) $text->pad = $pad;
    > if (isset($red)) $text->red = $red;
    > if (isset($grn)) $text->grn = $grn;
    > if (isset($blu)) $text->blu = $blu;
    > if (isset($bg_red) ) $text->bg_red = $bg_red;
    > if (isset($bg_grn) ) $text->bg_grn = $bg_grn;
    > if (isset($bg_blu) ) $text->bg_blu = $bg_blu;
    > if (isset($tr)) $text->transparent = $tr;
    >
    > $text->draw();
    > ?>
    >[/color]

    It would help if you told us what you're expecting, and what you're getting!

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    Working...