ExpertAlmost Posted January 29, 2009 Share Posted January 29, 2009 Good morning! I create several images in several different functions in several different files. I use imagecolorallocate() for 15 colors in every function for every image. What a mess! Is there some way to clean that up? Is there some way to make colors global: 1) For a single image across functions? 2) For ALL images and across functions?? I try variations of the following but nothing works: func_one() { // create $Img1 $black = imagecolorallocate($Img1, 0, 0, 0); // more code follows } func_two() { global $black; //this works for other variables but not for colors it seems. // more code==> BUT $black color is NOT recognized for $Img1 or any other image, even if I pass $Img1 into func_two. } Any help to clean up my code would be greatly appreciated! Thank you Experts-One-And-All Link to comment https://forums.phpfreaks.com/topic/142936-allocating-colors-globally/ Share on other sites More sharing options...
trq Posted January 29, 2009 Share Posted January 29, 2009 Maybe constants will help you out, I'm really not sure what your actual question is though. Link to comment https://forums.phpfreaks.com/topic/142936-allocating-colors-globally/#findComment-749426 Share on other sites More sharing options...
ExpertAlmost Posted January 29, 2009 Author Share Posted January 29, 2009 My apologies for the poorly communicated question! How do I use imagecolorallocate() to allocate colors with a GLOBAL scope for a single image across functions (passing the image as a function input)? AND, how can I allocate a single color for multiple images without calling imagecolorallocate() multiple times for the same color but a different image name? Hope this is more clear. Thank you for your patience and guidance! Link to comment https://forums.phpfreaks.com/topic/142936-allocating-colors-globally/#findComment-749556 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.