Solved

PHP Fade

Posted on 2012-04-02
5
242 Views
Last Modified: 2012-04-18
Im looking at a way of creating an image which fades. I know I can use jQuery to create a fade, but Id like to do it in php so I can create shapes with fades.

So my question is, can I produce a rectangle, with a fill fading from one colour to another?

Also is it possible to create a circle, with a filling of transparent?

Thank you
0
Comment
Question by:tonelm54
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37798386
Since all PHP processing is done on the server before the page gets to the browser, I don't see how PHP can help you with this.  You could possibly use AJAX to get each change from a PHP page but that is a lot of network activity accessing the server for each item.
0
 

Author Comment

by:tonelm54
ID: 37798427
Sorry, maybe some confusion, the image I'd like to be static (doesn't change after generated).

I have a template of a site which is yellow, which fades out to white or transparent (depends on the image), what I'm trying to do is create a script that will generate the image for me, so I can pass it the yellow parameter to draw the image fading to transparent, or I can pass it blue and it generates an image fading from blue to transparent.

I know it might be easier to create all the possible images, but doing it in code means I can quickly make it a shade darker or lighter without much effort.

Thank you
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37798452
I think thats normally called a 'gradient' where it blends from one color to another.  Note that PNG and GIF support transparency but JPEG does not.  Here's a page that talks about it: http://www.bradshawenterprises.com/blog/2010/dynamically-drawing-gradients-with-php/
0
 
LVL 7

Accepted Solution

by:
designatedinitializer earned 500 total points
ID: 37798464
What you need is usually called a "gradient".
Check out this class, as it does exactly what you are trying to do:
http://planetozh.com/blog/my-projects/images-php-gd-gradient-fill/
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 37798935
If what you're looking for is a gradient, it looks something like this.Gradient from Red to White VerticallyAnd you would be doing everyone a favor if you create static images one pixel wide (or high, depending on the direction of the gradient).  Use CSS to repeat the image across the gradient area.  Generating a gradient on the server for every request is like putting new tires on your car every time you want to take a drive.  Sure, you can do it -- it just doesn't make sense in the real world.

If what you want is a fading effect like what happens to the captions on the banner images (onMouseOut) here, you can use jQuery.  Just use view source and copy my code.
http://www.landonbaseball.com/
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question