kernelgpf Posted March 23, 2007 Share Posted March 23, 2007 Basically, on my website, you can own dragons. Now, there are MANY MANY colors of dragons. I have a default picture I want to be used, but depending on the color, I want PHP to color the dragon. Basic colors, like red, blue, and yellow, but also complicated things like "cheetah spotted" and "cloudy" and still, the image must be shaded. I can get all of the "skins" drawn, but is there some way [without using absolute positioning in CSS/HTML] to make the skin over-lap the dragon perfectly, where it would appear the default picture covered with the skin was really one picture? Kind of confusing, but please help. Thanks. =] Quote Link to comment Share on other sites More sharing options...
Hell Toupee Posted March 23, 2007 Share Posted March 23, 2007 Make it once picture, read the default dragon image into a temporary png file, aswell as the skin - a transparent png file with only the necessary colours and shading non transparent, and then map the png file on top, the same way one would put a watermarked image on a bigger image, except the two would be exactly the same size. Is that the kinda thing you're looking for? Quote Link to comment Share on other sites More sharing options...
kernelgpf Posted March 24, 2007 Author Share Posted March 24, 2007 Yes, yes. =D Quote Link to comment Share on other sites More sharing options...
DeathStar Posted March 24, 2007 Share Posted March 24, 2007 thats the simple(kinda) way! Think this may also work: http://us3.php.net/manual/en/ref.image.php Quote Link to comment Share on other sites More sharing options...
kernelgpf Posted March 24, 2007 Author Share Posted March 24, 2007 ..what part of that page, DeathStar? I haven't done anything with images, so if I'm not sure what part to read up on. =/ Quote Link to comment Share on other sites More sharing options...
DeathStar Posted March 24, 2007 Share Posted March 24, 2007 The whole page actualy! Ask "fert" he knows bit more about this stuff.. Quote Link to comment Share on other sites More sharing options...
Barand Posted March 25, 2007 Share Posted March 25, 2007 For this code you need a dragon image that is a silhouette on a white background. You also need a gif file to supply the "skin" for the dragon. The code uses the dragon image (dragon.phg) as a stencil. I have attached a couple of sample images to use with the code ::page on which dragon appears:: <img src="dragon.php?skin=bluetexture.gif" /> ::dragon.php:: <?php $skinfile = $_GET['skin']; $skin = imagecreatetruecolor(107,130); $tile = imagecreatefromgif($skinfile); imagesettile($skin, $tile); imagefill($skin, 54, 65, IMG_COLOR_TILED); $dragon = imagecreatefrompng('dragon.png'); $bgd = imagecolorat($dragon,0,0); $white = imagecolorallocate ($skin, 255,255,255); for ($x=0; $x<107; $x++) { for ($y=0; $y<130; $y++) { if (imagecolorat($dragon,$x,$y) == $bgd) { imagesetpixel($skin,$x,$y,$white); } } } header("content-type: image/png"); imagepng($skin); imagedestroy($skin); imagedestroy($dragon); imagedestroy($tile); ?> [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.