Jump to content

To color text in an image created using php...


chanchelkumar

Recommended Posts

Hi all,

 

I tried to create an curved image with the given  text..

using..

<?php

header("Content-type: image/png");
$im = imagecreate(400,200);
$white = imagecolorallocate($im, 255,255,255);
$black = imagecolorallocate($im, 0,0,0);

$cx = 100;
$cy = 100;
$cr = 60;
$font=$font = '../fonts/Varsity.ttf';
$fontsize = 40;
/*$cx = 0;
$cy = $fontsize-2;
$cr = 80;*/
if (isset($_REQUEST["text"])) {
    $text = $_REQUEST["text"];
} else {
    $text = 'HELLO WORLD';
}

$length = strlen($text);
$degDelta = 180 / $length;
if ($length > 0) {
    $color = $black;
    for ($x = 0; $x < $length; $x++) {
        // Circular Text
        $AX = $cx - cos(deg2rad($degDelta * $x)) * $cr;
        $AY = $cy - sin(deg2rad($degDelta * $x)) * $cr;

        imagettftext($im,$fontsize, -($degDelta * $x + $degDelta / 2)+90 , $AX, $AY, $color, $font, $text[$x]);

    }
}

imagepng($im);
imagedestroy($im);

?>

 

This is working fine.. when i tried to change the font color , it also changes.. but i want to change the border color of the font along with the inner color of the font..

 

Any body can help me on this issue.. to apply two colors to the font..

 

Is It possible.. or please give me hint?

 

thanks in advance..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.