问题标签 [color-blending]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
6416 浏览

flutter - 在颤动中使图像的边缘变暗?

如何在颤动的图像边缘添加阴影,以便白色叠加文本可读?我希望它看起来就像在联系人应用程序中一样: 阴影边缘

我已经检查了 Image 类,但我看到的只有colorcolorBlendMode,我敢肯定,这不是最简单的方法。

0 投票
1 回答
92 浏览

colors - Fastest approach to colorize pixel by other pixel

Subject. I want to achieve colorization of one pixel by other pixel like "Color" blending mode in Photoshop (with 100% opacity). What I do now:

  1. get hue of mask pixel;
  2. convert source pixel from RGB to HSL;
  3. replace hue and convert back to RGB;

If you are interested in the formula - check this: Please explain this color blending mode formula so I can replicate it in PHP/ImageMagick

But for this task converting back'n'forth from/to HSL/RGB seems too excessive.

So I am looking for a faster approach. I guess there should be way to calculate RGB-multiplying coefficients somehow and then for source pixel just simply do something like this:


UPD: Actually I don't need it to be exactly like in Photoshop. I mentioned PS blending mode just for example. I use it in my custom convolving routine, so I want it to be fast, but precision is not important, so it even if it could be approximated by a few percents. It's just that I want to find an approach to change pixel's tone without these complex HSL/RGB conversions...


UPD2: After some tests I've realized that my approach (replacing hue) is actually pretty far from what I wanted. Also after some digging I've found that "Color" blend-mode in PS replaces not only Hue but also Saturation. And surprisingly that makes algorithm not more complex, but on a contrary a bit simpler (faster):

  1. we need to get not only Hue, but also Saturation of mask-pixel
  2. but now we don't need to convert src-pixel from RGB to HSL, cuz all we need is luminocity which calculated much faster than full RGB->HSL routine...
  3. with src-Luminocity, mask-Hue and Sat. we convert it to RGB...

It is still pretty complex though, and I still believe it could be simplified.

0 投票
1 回答
631 浏览

webgl - 图元的Regl颜色和alpha混合

我试图弄清楚如何使用Regl实现基元之间的颜色和 alpha 混合。

我知道 Regl 命令有一个blend属性,并且我尝试复制以下 webgl 设置来解决问题:

blend在 Regl 中使用以下设置:

但是混合似乎只对背景颜色起作用,而不是在点之间。(请参见下面的示例。)

示例:http: //jsfiddle.net/8gyf7pek/13/

难道我做错了什么?我怎样才能实现与纯 webgl 代码产生的相同类型的混合?谢谢!

0 投票
4 回答
642 浏览

javascript - 在值之间混合颜色

我正在尝试使用画布弧创建时间倒计时,绘图还可以,但是弧将具有笔触颜色,我想将其混合。

我绘制弧线的方式是使用 0 到 100 之间的数字,100 基本上是完整的弧线,0 什么都不是。当值大于 66 且小于(或等于)100 时,它将是绿色和橙色之间的混合,100 是总绿色,66 是总橙色。65 及以下将是橙色和红色的混合,其中总红色为 0。

我不知道从哪里开始,不知道要搜索什么来研究如何获得价值。

有人可以指出我正确的方向吗?

到目前为止,这是我的代码 x)

编辑:这是我正在寻找的结果。它现在完全按照我想要的方式工作。干杯。

https://youtu.be/IeR_zMzSaAU

0 投票
1 回答
102 浏览

core-image - componentMax CIBlendKernel 与lighten 或lighterColor 有何不同?

CIBlendKernel提供了一个 componentMax 混合模式,“使用两个图像的最大值创建一个图像”。

它与做同样事情的 lighten 或lighterColor 混合模式有何不同?componentMax 能达到这两者不能达到的结果吗?

类似地,componentMin 是否可以实现与 darken 或 darkerColor 不同的结果?

0 投票
0 回答
130 浏览

css - 将不透明颜色转换为半透明颜色 [混合模式]

CSS领域的问题。

假设我有一个不透明的颜色color= rgb(3, 169, 244)

如何使用 CSSmix-blend-modebackground-blend-mode影响 alpha 通道并以某种透明变体绘制这种颜色作为background-color

感谢所有帮助的人

0 投票
1 回答
367 浏览

directx - 如何使用 DirectX 11 调整透明度?

我正在尝试制作像彩色玻璃或水一样的透明物体,我成功地制作了它。但我不知道如何调整它的透明度。我在尝试做不可能的事吗?

通过简单的颜色和光照计算来渲染场景。并且不在此程序中使用纹理映射

我尝试更改混合状态描述、混合因子、样本蒙版

但我不确定它是否正确。

这是我的 Blendstate 描述

和设置

0 投票
1 回答
221 浏览

graphics - 禁用 Three.js 中特定对象之间的颜色混合

我正在为 Three.js 中的 2D 对象开发可视化工具。

就像显示的示例一样,我想采用正交相机渲染的一组 2D 形状,因为每个较大的形状都“包含”较小的形状,所以我一直在使用 z 坐标来渲染它们,使得更大的形状对象被渲染在较小的对象后面。

这样可行。但是,我想禁用颜色混合,就好像我不是每次都绘制完整的对象,而是像上面的示例一样绘制它的增量/减量。此外,我希望每个都与现有内容混合,例如下面示例中显示的背景或地图。

问题本质上是:是否可以禁用一组对象之间的颜色混合,同时允许这些对象与其他对象(例如背景)之间的颜色混合?

例子

0 投票
1 回答
217 浏览

opengl - OpenGL handling float color saturation ("color overflow")?

I'm woking on a scientific visualisation using openGL where I try to basically create a "coloured fog" to illustrate a multidimensional field. I want the hue of the color to represent the direction of the field and the luminosity of the color to correspond to the intensity of the field.

I use GL_BLEND with glBlendFunc(GL_ONE, GL_ONE) to achieve additive blending of colors of the surfaces I create. The problem is: in some places the colors get saturated. For example:
(1, 0, 0) + (1, 0, 0) = (2, 0, 0), and when this is rendered it just becomes (1, 0, 0) (i.e. the "overflow" is just chopped off). And this is not the way I would like it to be handled. I would like to handle the overflow by preserving hue and luminocity, i.e.

(2, 0, 0) should be translated into (1, 0.5, 0.5) (i.e. a lighter red, red with twice the luminocity of "pure" red).

Is there any way to achieve this (or something similar) with OpenGL?

0 投票
0 回答
74 浏览

image - 如何在颤动中重新着色图像?

我有人脸特征的图像,如眼睛、鼻子、嘴巴,我想用不同的肤色重新着色。我试过colorBlendMode了,但这并没有给出预期的输出。所以,我想知道有没有什么库或方法可以帮助我改变颜色?

在此处输入图像描述

这就是图像看起来像我想将它们混合成单色的样子,这样它看起来应该像一个实际的图像