如何在Java Swing中创建阴影,内部发光和外部发光? [英] How can I create a drop shadow, inner glow and outer glow in Java Swing?

查看:1895
本文介绍了如何在Java Swing中创建阴影,内部发光和外部发光?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Graphics2D界面生成一些图像,偶尔我希望能够在图像上绘制一些文字,并将其应用于Adobe Photoshop中的效果。



现在为文本生成一个阴影,我将文本两次绘制,一次使用原始颜色,一次使用略微(1px)x和y偏移量的黑色。不幸的是,这太简单了,因为我需要更多的控制阴影(不透明度,大小,分布)。

关于内发光和外发光,我不确定在哪里开始;一个面具/渐变涂料/ alpha混合?



是否有用于生成这些类型效果的Java库?如果不是,你会如何去创建这些效果?

/filthyrichclients.org/rel =noreferrer>肮脏的富客户端。第16章谈论阴影。您也可能对此博客文章感兴趣。第17章谈到发光效应。这两个网站上都有示例代码。本书的其余部分也值得一读。阅读时我无法放下这本书。这本书还有许多其他有趣的效果。

jhlabs网站也是一个不错的网站。



编辑:

b
$ b

对于图书馆,我会在 SwingX图书馆中查看Painters。以下是几个教程:


I am generating some images using the Graphics2D interface, and occasionally I'd like to be able to draw some text on the image and apply to it effects like the ones in Adobe Photoshop.

Right now to generate a 'shadow' on the text I am drawing the text twice, once in the original color, and once in black with a slight (1px) x&y offset. Unfortunately this is overly simplistic as I need more control over the shadow (opacity,size, spread).

As for Inner Glows and Outer Glows, I am not really sure where to start; a mask/gradient paint/alpha blending?

Is there a Java library for producing these types of effects? If not how would you go about creating these effects?

解决方案

I would highly recommend the book Filthy Rich Clients. Chapter 16 talks about drop shadows. You also might be interested in the this blog post. Chapter 17 talks about the glowing effect. There is example code on the website for both. The rest of the book is well worth reading as well. I couldn't put the book down when I read it. There are many other fun effects explained and demonstrated in the book.

The jhlabs site is also a good site, as mentioned.

Edit:

For a library, I would look at Painters in the SwingX library. Here are several tutorials:

这篇关于如何在Java Swing中创建阴影,内部发光和外部发光?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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