PHP 3D Text

Results 1 to 4 of 4
  1. #1
    Account Upgraded | Title Enabled! Exiled Hero is offline
    MemberRank
    Nov 2008 Join Date
    Multiple PlacesLocation
    202Posts

    PHP 3D Text

    I got really lazy on this.

    This class can render text with a 3D perspective and the possibility to change the text rotation and position parameters.

    This can be used to generate sequences of images with different views of the same text to produce impressive animations.

    PHP Code:
    <?php

    class 3d 
    {
        var 
    $_193;
        var 
    $_584;
        var 
    $_479;
        var 
    $_350;
        var 
    $_895;
        var 
    $_822;
        var 
    $_746;
        var 
    $_601;
        var 
    $_607;
        var 
    $_166;
        var 
    $_531;
        var 
    $_377;
        var 
    $_571;
        var 
    $_450;
        var 
    $_710;
        var 
    $_663;
        var 
    $_174;
        var 
    $_858;
        var 
    $_988;
        var 
    $_445;
        var 
    $_999;
        var 
    $_008;
        var 
    $_004;
        var 
    $_111;
        var 
    $_112;
        var 
    $_113;
        var 
    $_114;
        var 
    $_115;
        var 
    $_116;

        var 
    $_014 = Array();
        var 
    $_147 = Array();
        var 
    $_364 = Array();
        var 
    $_091 = Array();
        var 
    $_303 = Array();
        var 
    $_513 = Array();
        var 
    $_352 = Array();
        var 
    $_726 = Array();
        var 
    $_165 = Array();
        var 
    $_057 = Array();


        var 
    $PI 3.1415926535897931;

        function 
    __construct$j$k$p$q$r$rgb1$rgb2$font$fontsize$text )
        {
            
    $this->_116 = ( $j 10 ) + 2.0;
            
    $this->_350 $j <= 128 $j << 4;
            
    $this->_822 $k <= 15 $k;
            
    $this->_746 45500;
            
    $this->_895 2;
            
    $this->_584 1;
            
    $this->_479 0;
            
    $this->_111 $font;
            
    $this->_112 $fontsize;
            
    $this->_113 $text;

            
    $i $p 256;
            
            if( 
    $i )
                
    $i += 0x16800;

            
    $this->_601 $i // ROTX

            
    $i $q 256;

            if( 
    $i )
                
    $i += 0x16800;

            
    $this->_607 $i// ROTY

            
    $i $r 256;

            if( 
    $i )
                
    $i += 0x16800;

            
    $this->_166 $i// ROTZ

            
    $i 256;

            if( 
    $i )
                
    $i += 0x16800;

            
    $this->_531 $i;

            
    $i 256;

            if( 
    $i )
                
    $i += 0x16800;

            
    $this->_377 $i;

            
    $i 256;

            if( 
    $i )
                
    $i += 0x16800;

            
    $this->_571 $i;

            for( 
    $i 0$i 181$i++ )
                
    $this->_726$i ] = floorsin( ( (double)$i 180 ) * $this->PI ) * 256 );

            
    $this->_450 $this->rgb2int$rgb1 );
            
    $this->_352] = $this->rgb2int($ rgb2 );

            
    $ad] = $rgb2];
            
    $ad] = $rgb2];
            
    $ad] = $rgb2];

            
    $ad1] = ( (double)$rgb1] - $ad] ) / 110;
            
    $ad1] = ( (double)$rgb1] - $ad] ) / 110;
            
    $ad1] = ( (double)$rgb1] - $ad] ) / 110;

            for( 
    $i 0$i 64$i++ )
                
    $this->_352$i ] = $this->rgb2int( Array( 
                                                        
    => floor$ad] += $ad1] ), 
                                                        
    => floor$ad] += $ad1] ), 
                                                        
    => floor$ad] += $ad1] ) ) 
                                                        );

            switch( 
    $this->_479 )
            {
                case 
    1:
                    
    $this->_663 51;
                    break;
                case 
    0:
                    
    $this->_663 40;
                    break;
            }

            switch( 
    $this->_584 )
            {
                case 
    2:
                    
    $this->_174 $this->_350 $this->_663;
                    break;
                case 
    1:
                    
    $this->_174 $this->_822 << 8;
                    break;
            }

            
    $this->_858 $this->_746 $this->_174;
            
    $this->_174 /= 32;
            
    $this->_555();
            
    $this->_888();
        }

        function 
    _888()
        {
            
    $w $this->_114 $this->_822;
            
    $h $this->_115 $this->_822;
            
    $this->_988 $w 2;
            
    $this->_445 $h 2;
            
    $this->_999 imageCreateTrueColor$w$h );

            
    imageFill$this->_99900imageColorAllocate$this->_999, ( $this->_450 >> 16 ) & 0xFF, ( $this->_450 >> ) & 0x00FF$this->_450 0x0000FF ) );

            
    $this->_266();
            
    $this->_457();
        }

        function 
    _266()
        {
            
    $this->_837();
            
    $this->_377 += $this->_607;

            if( 
    $this->_377 0x16800 )
                
    $this->_377 -= 0x16800;

            
    $this->_531 += $this->_601;

            if( 
    $this->_531 0x16800 )    
                
    $this->_531 -= 0x16800;

            
    $this->_571 += $this->_166;

            if( 
    $this->_571 0x16800 )
                
    $this->_571 -= 0x16800;

            
    $i $this->_377 >> 8;
            
    $l $this->_531 >> 8;
            
    $j1 $this->_571 >> 8;
            
    $l1 = ( $this->_925$i ) * $this->_925$j1 ) >> ) + ( $this->_955$i ) * $this->_955$l ) * $this->_955$j1 ) >> 16 );
            
    $i2 $this->_925$l ) * $this->_955$j1 ) >> 8;
            
    $j2 = ( $this->_925$i ) * $this->_955$l ) * $this->_955$j1 ) >> 16 ) - ( $this->_955$i ) * $this->_925$j1 ) >> );
            
    $k2 = ( $this->_955$i ) * $this->_955$l ) * $this->_925$j1 ) >> 16 ) - ($this->_955$j1 ) * $this->_925$i ) >> );
            
    $l2 $this->_925$l ) * $this->_925($j1) >> 8;
            
    $i3 = ( $this->_955$i ) * $this->_955$j1 ) >> ) + ( $this->_925$i ) * $this->_955$l ) * $this->_925$j1 ) >> 16 );
            
    $j3 $this->_955$i ) * $this->_925$l ) >> 8;
            
    $k3 = -$this->_955$l );
            
    $l3 $this->_925$i ) * $this->_925$l ) >> 8;
            
            for( 
    $j 0$j $this->_563$j++ )
            {
                
    $this->_014$j ] = $this->_147$j ] * $l1 $this->_364$j ] * $i2 $this->_091$j ] * $j2 >> 8;
                
    $this->_303$j ] = $this->_147$j ] * $k2 $this->_364$j ] * $l2 $this->_091$j ] * $i3 >> 8;
                
    $this->_513$j ] = ( $this->_147$j ] * $j3 $this->_364$j ] * $k3 $this->_091$j ] * $l3 >> ) + $this->_746;
            }

            for( 
    $k 0$k $this->_563 1$k++ )
            {
                for( 
    $i1 $k 1$i1 $this->_563$i1++ )
                {
                    if( 
    $this->_513$this->_165$i1 ] ] > $this->_513$this->_165$k ] ] )
                    {
                        
    $k1 $this->_165$i1 ];
                        
    $this->_165$i1 ] = $this->_165$k ];
                        
    $this->_165$k ] = $k1;
                    }
                }
            }
        }

        function 
    _837()
        {
            
    $l3 0;
            
    $l7 0;

            for( 
    $l1 1$l1 <= $this->_057]; $l1 += )
            {
                
    $this->_364$l3 ] = $this->_057$l1 ] * $this->_350;
                
    $this->_147$l3 ] = $this->_822 $this->_955$l7 $this->_057$l1 ] * $this->_895 );
                
    $this->_091$l3 ] = -$this->_822 $this->_925$l7 $this->_057$l1 ] * $this->_895 );
                
    $l3++;
            }

            
    $this->_563 $l3;

            for( 
    $k3 0$k3 $this->_563$k3++ )
                
    $this->_165$k3 ] = $k3;
        }

        function 
    _457()
        {
            for( 
    $i1 0$i1 $this->_563$i1++ )
            {
                
    $k $this->_165$i1 ];
                
    $l $this->_710 $this->_513$k ];

                if( 
    $l )
                    
    $l 2;

                
    $i = ( $this->_988 + ( $this->_014$k ] << ) / $this->_513$k ] ) - ( $l >> );
                
    $j = ( $this->_445 + ( $this->_303$k ] << ) / $this->_513$k ] ) - ( $l >> );
                
    $c $this->_352[ ( $this->_513$k ] - $this->_858 ) / $this->_174 ];

                
    imagefilledellipse$this->_999$i$j$l$limageColorAllocate$this->_999, ( $c >> 16 ) & 0xFF, ( $c >> ) & 0x00FF$c 0x0000FF ) );
            }
        }

        function 
    _555()
        {
            
    $b1 imageTTFBbox$this->_1120$this->_111$this->_113 );
            
    $b2 $b1];
            
    $b3 abs$b1] );
            
    $im imageCreateTrueColor$b14] , abs$b1] ) + );
            
            
    imageFill$im00imageColorAllocate$im255255255 ) );
            
    imagettftext$im$this->_11200$b3imageColorAllocate$im00), $this->_111$this->_113 );

            
    $this->_114 $x imageSX$im );
            
    $this->_115 $y imageSY$im );
            
    $c 0;
            
    $q 1;
            
    $this->_057] = 0;

            for( 
    $i 0$i $x$i++ )
            {
                for( 
    $j 0$j $y$j++ )
                {
                    
    $p imageColorsForIndex$imimageColorAt$im$i$j ) );

                    if( 
    $p'red' ] < 128 && $p'green' ] < 128 && $p'blue' ] < 128 )
                    {
                        
    $this->_057$q ] = $i;
                        
    $this->_057$q ] = $j;
                        
    $q += 2;
                        
    $c += 2;
                    }
                }
            }

            
    $this->_057] = $c;
            
    $this->_435$this->_116 );
        }

        function 
    _435$i )
        {
            for( 
    $j 2$j <= $this->_057]; $j += )
                
    $this->_057$j ] -= $i;
        }

        function 
    _955($i)
        {
            
    $j $this->_726$i 180 ];

            if( 
    $i 180 )
                
    $j *= -1;

            return 
    $j;
        }

        function 
    _925$i )
        {
            
    $j $this->_726[ ( $i 90 ) % 180 ];

            if( 
    $i 90 && $i 270 )
                
    $j *= -1;

            return 
    $j;
        }

        function 
    rgb2int$rgb )
        {
            return 
    $rgb] << 16 $rgb] << $rgb];
        }

        function 
    getImage()
        {
            return 
    $this->_999;
        }
    }

    /* EOF */
    Example:

    The example uses Gifmerge that helps create the GIF image which can be found here.

    PHP Code:
    set_time_limit);

    header'Content-type: image/gif' );

    require 
    '3d ';
    require 
    'GifMerge.class.php';

    $j 0;
    $k 0;

    for( 
    $i 360$i 0$i-- )
    {
        if( 
    $j++ == 10 )
        {
            $
    3d = new 3d16960$i0, array( => 22=> 22=> 22), array( => 255=> 255=>), "fonts/arial.ttf"16"Exiled Hero is hawt!" );
            
            
    ob_start();
            
            
    imageGif( $3d->getImage() );

            
    $frame$k ] = ob_get_contents();
            
    $delay$k ] = 10;

            
    ob_end_clean();
            
            
    $j 0;
            
    $k++;
        }
    }

    $anim = new GifMerge$frame000, -10$delay00'C_MEMORY' );
    echo 
    $anim->getAnimation(); 
    Quick documentation:

    PHP Code:
    $3d = new text3dint distanceint radiusint rotxint rotyint rotz, array background color, array text colorstring fontint fontsizestring text ); 
    int distance can be used to change height distance between pixels.
    Distance to increase when this integer major and distance to decrease when this integer minor.

    int radius can be used to change radius.
    Radius to increase when this integer major and radius to decrease when this integer minor.

    The rotx, roty, and rotz ints can be used to define the rotate angles.
    Values of these integers keep from 0 to 360.

    rotx can be used to define vertical rotate.
    roty can be used to define horizontal rotate.
    rotz can be used to define circle rotate.

    array background and text colour parameters can be used to set the background and text color.
    These parameters are array type and the values are decimal from 0 to 255.

    PHP Code:
    array( => 255=> 255=> 255 


  2. #2
    Pee Aitch Pee Dave is offline
    MemberRank
    Mar 2011 Join Date
    The NetherlandsLocation
    722Posts

    Re: PHP 3D Text

    Didn't know this section was also used to show off the work of other people.

    Text 3D for Graph & Chart - free PHP 3d gif image text Script
    Text3D.class.php at Text 3D - Free PHP Code
    Last edited by Dave; 19-06-12 at 09:46 PM.

  3. #3
    [R8]ℓσℓ32 caja is offline
    MemberRank
    Oct 2008 Join Date
    Here!Location
    1,502Posts

    Re: PHP 3D Text

    Sir, I think you've forgotten the copyright.

  4. #4
    Hm. foxx is offline
    MemberRank
    Sep 2006 Join Date
    Czech RepublicLocation
    5,257Posts

    Re: PHP 3D Text

    funny



Advertisement