Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://puzzlum.net/Roe_Web_Builder/mk11TILES.php
- <?php
- function combotoc($path = 'bsaves/out' )
- {
- $nen=nen_ini();
- $return = '';
- $toc = fasttoc( $path, array( '.png' ) );
- $toc_index = 0;
- while($toc_index < count( $toc ))
- {
- $toc[ $toc_index ] = str_replace( '.png', '', $toc[ $toc_index ] );
- $toc[ $toc_index ] = substr($toc[ $toc_index ], 0, strlen( $toc[ $toc_index ] ) - 4 );
- $return.= '<tr><td><h3>'. htmlentities( $toc[ $toc_index ] ). '</h3></td><td style="background-color:springgreen;">'. combo( $toc[ $toc_index ], 127 ). '</td></tr>';
- if( $toc_index < count( $toc ) - 1 )
- {
- $toc_index++;
- }
- else
- {
- break;
- }
- }
- return '<table>'.$return.'</table>';
- }
- function combo($filename='dtbykick', $alpha = 127 )
- {
- $nen = nen_ini();
- $vga = vga_ini();
- $return = '';
- $return.= '<img src="./bsaves/out/'. $filename. '.24x.png">';
- $image[ 'rgb' ] = imagecreatefrompng( $nen['root']. 'bsaves/out/'. $filename. '.24x.png' );
- $return.= '<img src="./bsaves/out/'. $filename. '.24y.png">';
- $image[ 'mask' ] = imagecreatefrompng( $nen['root']. 'bsaves/out/'. $filename. '.24y.png' );
- $image [ 'combo' ] = imagecreatetruecolor( imagesx( $image[ 'rgb' ] ), imagesy( $image[ 'rgb' ] ) );
- imagetruecolortopalette( $image[ 'combo' ], false, 255 );
- imagealphablending( $image[ 'combo' ], false );
- imagesavealpha( $image[ 'combo' ], false );
- for( $color = 0; $color < 256; $color++ )
- {
- $vga[ 'color' ][ $color ] = imagecolorallocate(
- $image[ 'combo' ],
- ( $vga[ 'table' ][ $color ] >> 16 ) & 0xFF,
- ( $vga[ 'table' ][ $color ] >> 8 ) & 0xFF,
- ( $vga[ 'table' ][ $color ] >> 0 ) & 0xFF
- );
- }
- $vga[ 'color' ][ 255 ] = imagecolorallocatealpha(
- $image[ 'combo' ],
- ( $vga[ 'table' ][ 255 ] >> 16 ) & 0xFF,
- ( $vga[ 'table' ][ 255 ] >> 8 ) & 0xFF,
- ( $vga[ 'table' ][ 255 ] >> 0 ) & 0xFF,
- 127
- );
- imagefill( $image[ 'combo' ], 0, 0, $vga[ 'color' ][ 255 ] );
- $width = imagesx( $image[ 'combo' ] );
- $height = imagesy( $image[ 'combo' ] );
- //loop through width and height of source image
- $row=0;
- while( $row < $height )
- {
- $col=0;
- while( $col < $width )
- {
- //get color in image $image[ 'mask' ] at pixel ($col, $row)
- $pix[ 'mask' ] = imagecolorat( $image[ 'mask' ], $col, $row );
- //get color in image $image[ 'rgb' ] at pixel ($col, $row)
- $pix[ 'rgb' ] = imagecolorat( $image[ 'rgb' ], $col, $row );
- //if pixel in $image['mask'] at ($cow, $row) is white:
- if ( $pix[ 'mask' ] === $vga[ 'color' ][ 15 ] )
- {
- //set pixel based on Mask layer's ($col, $row) as fully transparent
- $pix[ 'combo' ] = $vga[ 'color' ][ 255 ];
- }
- //else
- else
- {
- //set pixel based on RGB layer's ($col, $row) with full opacity
- $pix[ 'combo' ] = $pix[ 'rgb' ];
- }
- //assign pixel data to $image['combo'] at ($col , $row)
- imagesetpixel( $image[ 'combo' ], $col, $row, ( $pix[ 'combo' ] % 256 ) + 1 );
- if( $col === $width - 1 )
- {
- break;
- }
- $col++;
- }
- if( $row === $height - 1 )
- {
- break;
- }
- $row++;
- }
- //save resulting image as new file
- imagepng( $image[ 'combo' ], $nen['root']. 'bsaves/combo/'. $filename. '.png' );
- $return.= '<img src="./bsaves/combo/'. $filename. '.png">';
- return $return;
- }
- function alphaColor($hexColor,$alpha)
- {
- return bindec(decbin($alpha).decbin(hexdec($hexColor)));
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement