简体   繁体   English

Java 相当于.NET的ColorBlend

[英]Java equivalent to .NET's ColorBlend

What is the closest equivalent of .NET's ColorBlend /InterpolationColors in Java? Java 中 .NET 的ColorBlend /InterpolationColors 最接近的等价物是什么?

Update: See my own solution below.更新:请参阅下面我自己的解决方案。 Also, I needed this for my Android App.另外,我的 Android 应用程序需要这个。

Nearest seems to be java.awt.最近的似乎是 java.awt。 GradientPaint 渐变漆

I think I got the answer.我想我得到了答案。 I was actually looking this for Android for drawing a linear gradient line with multiple colors at various stops.我实际上是在寻找 Android 以在各个站点绘制一条带有多个 colors 的线性渐变线。 Turns out Android's LinearGradient 's constructor takes parameters for both colors and positions.原来 Android 的LinearGradient的构造函数采用 colors 和位置的参数。 To imitate .net's ColorBlend I'll just create a ColorBlend class with setter/getters for positions and colors.为了模仿 .net 的 ColorBlend,我将创建一个 ColorBlend class,其中包含用于位置的设置器/获取器和 colors。

For Java SE:对于 Java SE:

http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/ext/awt/LinearGradientPaint.html http://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/ext/awt/LinearGradientPaint.html

(Sun has sponsored this Apache project. It is also part of their JavaFX product line.) (Sun 赞助了这个 Apache 项目。它也是他们 JavaFX 产品线的一部分。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM