在PHP中具有不透明度的径向渐变 [英] Radial gradients with opacity in PHP

查看:133
本文介绍了在PHP中具有不透明度的径向渐变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个具有不透明度的PNG径向渐变。我已经通过GDLib看过,但我无法看到生成径向渐变的方法。有谁知道用GDlib或PHP的任何其他图形库的方式吗?

我想最坏的情况是我可以使用GDLib逐像素地生成它,但是怎么做一个甚至开始做这个数学?



目标是为网页生成性感照明效果背景PNG。效果的一个例子可以在标题中看到,它使用此背景图片。我已经尝试了通用的白色灯光效果PNG,但它看起来并没有像有色照明一样好,所以我生成的PNG会考虑网站的颜色方案。



我认为服务器端是要走的路,因为浏览器支持 CSS径向渐变是如此patchy。

解决方案

为什么不使用 imagecolorallocatealpha() imageellipse () imagefilledellipse()



编辑:

请参阅这个课程为我的意思的例子。你应该可以扩展它以支持alpha。

Edit2:



我对上面的类进行了一些修改以产生alpha支持。这不是完美的,但它适用于省略号等:

http: //codepad.org/1eZ3Km0J


I need to create a PNG radial gradient with opacity. I've looked through GDLib but I can't see a way to generate radial gradients. Does anyone know of a way with GDlib or any other graphics library for PHP?

I suppose worst-case I could generate it pixel-by-pixel using GDLib but how does one even start to do the math on that?

The goal is to generate sexy lighting effect background PNGs for web pages. An example of the effect can be seen on the header here which uses this background image. I've tried generic white lighting effect PNGs but it doesn't look anywhere near as good as tinted lighting, so my generated PNGs will take into account the website's color scheme.

I assume server-side is the way to go because browser support for CSS radial gradients is so patchy.

解决方案

Why not use a combination of imagecolorallocatealpha() and imageellipse() or imagefilledellipse()?

Edit:

See this class for an example of what I mean. You should be able to extend this to support alpha.

Edit2:

I have made some modifications to the class above to yield alpha support. It's not perfect, but it works for ellipses and such:

http://codepad.org/1eZ3Km0J

这篇关于在PHP中具有不透明度的径向渐变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆