Qt的:如何让我的2D插值颜色的领域? [英] Qt: how do I make a field of 2d-interpolated colors?
问题描述
我用C ++不少初学者,尤其是图形化有关。 我想作的动画背景,我graphicsview,看起来有点像这样的:
I'm quite a beginner with c++, especially graphically related. I would like to make an animated background for my graphicsview which looks kind of like this:
再$ P $图片psents气流过一个对象的动荡。 颜色必须基于值的矩阵
The picture represents the turbulence of an airflow over an object. The colors must be based on a matrix of values.
我只能找到如何做单方向的梯度与QT。
I can only find how to do single-direction gradients with QT.
我如何设置呢?我如何获得双向梯度?
How do I set this up? How do I get two-directional gradients?
/ *编辑 它已被指出清楚,从技术上讲,这不是一个梯度,但在节点的二维数组的颜色插值。 * /
/*edit It has been pointed out well that technically speaking this is not a gradient, but an color interpolation on a 2d array of nodes. */
推荐答案
那么你没有提供的输入数据,因此没有人知道你真正想实现!
Well you have not provided the input data so no one knows what you really want to achieve !
-
如果您有流动轨迹和大众
if you have the flow trajectories and mass
- ,那么你可以使用一些粒子系统+重bluring /平滑滤波达到这个
- 沿着轨迹情节抖动圆圈的颜色取决于质量/温度/速度...和色阶 任何已知点
- 在中间的固体和透明的边缘
- 渲染只是模糊/平滑图像数次后
- 这应该是它
- 少点使用的大圆圈必须很好地覆盖面积
- 也可以做多通和改变点坐标随机改善随机性的形象...
- then you can use some particle system + heavy bluring/smoothing filtering to achieve this
- for any known point along the trajectory plot a dithered circle with color depend on the mass/temp/velocity... and color scale
- solid in the middle and transparent on the edges
- after rendering just blur/smooth the image few times
- and that should be it
- less points used the bigger the circles must be to cover the area nicely
- also can do it in multi pass and change the points coordinates randomly to improve randomness in the image...
如果您有磁场强度/速度/温度或什么都网格值
if you have field strength/speed/temp or what ever grid values
- 则是类似于1
- 而不是粒子系统,你也可以做到通过四边形/平方渲染
-
二维线性渐变被称为双线性过滤
c00 -- x --> c01
|
|
y c(x,y)
|
|
V
c10 c11
C00,C01,C10,C11的角上的颜色
c00,c01,c10,c11 are corner colors
双线性插值是3倍线性插值:
Bilinear interpolation is 3x linear interpolation:
c0=c(x,0)=c00+((c01-c00)*x)
c1=c(x,1)=c10+((c11-c10)*x)
c(x,y) =c0 +((c1 -c0 )*y)
所以呈现正方形的所有像素与上面计算的颜色,这就是你寻找
so render all pixels of the square with above computed colors and that is what you seek
这篇关于Qt的:如何让我的2D插值颜色的领域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!