Solved

PHP Fade

Posted on 2012-04-02
5
244 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

691 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