问题标签 [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.
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:
- get hue of mask pixel;
- convert source pixel from RGB to HSL;
- 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):
- we need to get not only Hue, but also Saturation of mask-pixel
- 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...
- 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.
webgl - 图元的Regl颜色和alpha混合
我试图弄清楚如何使用Regl实现基元之间的颜色和 alpha 混合。
我知道 Regl 命令有一个blend
属性,并且我尝试复制以下 webgl 设置来解决问题:
blend
在 Regl 中使用以下设置:
但是混合似乎只对背景颜色起作用,而不是在点之间。(请参见下面的示例。)
示例:http: //jsfiddle.net/8gyf7pek/13/
难道我做错了什么?我怎样才能实现与纯 webgl 代码产生的相同类型的混合?谢谢!
javascript - 在值之间混合颜色
我正在尝试使用画布弧创建时间倒计时,绘图还可以,但是弧将具有笔触颜色,我想将其混合。
我绘制弧线的方式是使用 0 到 100 之间的数字,100 基本上是完整的弧线,0 什么都不是。当值大于 66 且小于(或等于)100 时,它将是绿色和橙色之间的混合,100 是总绿色,66 是总橙色。65 及以下将是橙色和红色的混合,其中总红色为 0。
我不知道从哪里开始,不知道要搜索什么来研究如何获得价值。
有人可以指出我正确的方向吗?
到目前为止,这是我的代码 x)
编辑:这是我正在寻找的结果。它现在完全按照我想要的方式工作。干杯。
core-image - componentMax CIBlendKernel 与lighten 或lighterColor 有何不同?
CIBlendKernel提供了一个 componentMax 混合模式,“使用两个图像的最大值创建一个图像”。
它与做同样事情的 lighten 或lighterColor 混合模式有何不同?componentMax 能达到这两者不能达到的结果吗?
类似地,componentMin 是否可以实现与 darken 或 darkerColor 不同的结果?
css - 将不透明颜色转换为半透明颜色 [混合模式]
CSS领域的问题。
假设我有一个不透明的颜色color= rgb(3, 169, 244)
如何使用 CSSmix-blend-mode
或background-blend-mode
影响 alpha 通道并以某种透明变体绘制这种颜色作为background-color
感谢所有帮助的人
directx - 如何使用 DirectX 11 调整透明度?
我正在尝试制作像彩色玻璃或水一样的透明物体,我成功地制作了它。但我不知道如何调整它的透明度。我在尝试做不可能的事吗?
通过简单的颜色和光照计算来渲染场景。并且不在此程序中使用纹理映射
我尝试更改混合状态描述、混合因子、样本蒙版
但我不确定它是否正确。
这是我的 Blendstate 描述
和设置
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?