Jump to content
xisto Community
Sign in to follow this  
beeseven

Using The Image Editing Functions Of Php Specifically, lines or regular polygons.

Recommended Posts

I've been experimenting a little with PHP's image functions and I was trying to see if I could make something that looked 3D, so I started with a cube because it's simple. To make an isometric picture of a cube, you need to start with a regular hexagon. However, making a regular hexagon isn't the easiest thing. Is there a function to create a regular polygon, or specify an angle and magnitude for a vector?

Share this post


Link to post
Share on other sites

PHP has image editing functions?! >_>; I never even knew that. I mean, I knew it had tons of mail functions and all that good stuff but never image editing functions. The most recent thing that I have learned that have to do with shapes is something that you add in CSS. It's like this:

-moz-border-radius: #px;

I had no idea you could edit pictures with PHP...

Share this post


Link to post
Share on other sites

Yeah, you can do stuff but it's pretty complicated. Here's an example:

http://forums.xisto.com/no_longer_exists/

The code is:

<?phpheader("Content-type: image/png");$img = imagecreate(500,500);$topleft = imagecolorallocate($img,255,0,0);$bottomright = imagecolorallocate($img,255,255,0);$topright = imagecolorallocate($img,0,0,255);$bottomleft = imagecolorallocate($img,0,255,0);$middle = imagecolorallocate($img,255,0,255);$border = imagecolorallocate($img,0,0,0);$diamond = imagecolorallocate($img,255,128,0);imagefilledrectangle($img,0,0,250,250,$topleft);imagefilledrectangle($img,250,0,500,250,$topright);imagefilledrectangle($img,0,250,250,500,$bottomleft);imagefilledrectangle($img,250,250,500,500,$bottomright);imagefilledrectangle($img,125,125,375,375,$middle);$points = array(125,250,250,125,375,250,250,375);imagefilledpolygon($img,$points,4,$diamond);imagerectangle($img,0,0,499,499,$border);imagepng($img);imagedestroy($img);?>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.