ashrobbins87 Posted March 20, 2009 Share Posted March 20, 2009 I have created an image in php and the size of it gets updated depending on a variable from my DB. I want to use it as a kind of totaliser, as it is displaying the amount of money that has been raised to date, therefore I want the image to start at the bottom and grow upwards. I know how to start it at the bottom of the canvas but I want to know how to draw the height of the image upwards, instead of it going down the page and off the bottom of the canvas. Sorry if that explanation isnt very clear!! //create the canvas $image = ImageCreate(30, 400); //set up colours $blue = ImageColorAllocate($image, 0, 0, 255); $red = ImageColorAllocate($image, 255, 0 , 0); //draw rectangle ImageFilledRectangle($image, 1, 299, 28, $figure, $red); //output image to browser header ("Content-type: image/png"); ImagePng($image); //clean up ImageDestroy($image); $figure is the variable that sets the height of the image. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted March 20, 2009 Share Posted March 20, 2009 Well it's just simple maths, right? If 0 is the top of the canvas, x is the bottom of it and we need the top of the image to be drawn with height h, it's just x-h. Quote Link to comment Share on other sites More sharing options...
ashrobbins87 Posted March 20, 2009 Author Share Posted March 20, 2009 i really dont understand that 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.