In PixiJS, is it possible to have blend modes applied in a transparent render texture work with the layer behind? - pixi.js

If sprites are rendered into a transparent render texture with different blend modes and some are rendered against the transparent parts, they render black when on top of a background.
Is it possible to get blend modes to work against the background i.e something set as add or multiply inside the render texture will add or multiply with the background? I'd probably have to put each blend mode into its own render texture and set the whole render texture to use that blend mode.
Assuming it's not possible to have the blend modes work with a single render texture, is it possible to make the black parts transparent? Multiply or add against transparent renders black in a render texture by default.

Related

Is there a way to put a background inside SVG

I need to make an SVG that is to be used as a background-image with "cover", so the tile in the mosaic could be rescaled.
I'd like to have the icon at a fixed size and the posibility to always fill with a background color, because, to make matters more complicated, my image is going to be inside a container that is inside the tile
this is my example
my icon should go inside that red outlined box, fixed size and the background in gray
could i get that done?

How to transform a Grayscale background SVG, to white or black colors

I have Gray SVG icons next to each Menu item (inherited from another project) and displaied as background.
I need to show them black or white but I don't how to achieve this.
As backgrounds I can't use fill css property. I tried with filter:brightness(100) to make them white but I loose anti-aliasing (and analogue with filter:brightness(0) to make them black).
Mask has still serious compatibility issues (e.g. Firefox does not allow external svg).
I tried also to import them as data-uri with LESS feature, but it was unuseful, so.... any suggestion?

LibGDX - change the inside color, not border

I have a rounded square texture, drawn in paint, with black border. How can I change only the inner color without changing the border color?
EDIT: I did it, but I want to ask if it can be done without using another texture? I also wonder if there is a connection between this and 9patch as in scaling. Can we use that or is there something like that?
You can tint whatever it is what you are drawing, using SpriteBatch. This means that color you specify is multiplied with the color of the image. For example if your image is a white rounded rectangle with a black border and you tint it using the color purple then the inside will be purple and the border will remain black. You didn't provide enough information to be more specific. But if you are for example using the Sprite class then you can use the setColor method to tint it. Likewise if you are using the Image class. If you are drawing the "texture" directly using SpriteBatch then you can use the setColor method of the SpriteBatch.

color blending with GDI+

I am refering to a older question saying color blending with GDI+
Using GDI+ with Windows Forms, I want to be able to draw with a pen and blend color based on the destination pixel color.
For example, if I draw a line and it passes over black pixels, I want it to be a lighter color (like white for example) so that it's visible. When that same line passes over white pixels, it should be a darker color (black for example) so that it's still clearly visible.
the answers says to use a color matrix for transformation
so i started implementing it..
My image is present in raw data format in rgb48
Gdiplus::Bitmap image(input.width,input.height,input.width*6,PixelFormat48bppRGB,(unsigned char*)rgb48);
Gdiplus::Image *images= image.GetThumbnailImage(input.width,input.height);
Gdiplus::TextureBrush brush(images);
Gdiplus::Pen pen(&brush);
Gdiplus::ColorMatrix matrix={
-1.0f,0.0f,0.0f,0.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,0.0f,
0.0f,0.0f,-1.0f,0.0f,0.0f,
0.0f,0.0f,0.0f,1.0f,0.0f,
1.0f,1.0f,1.0f,0.0f,1.0f,
};
Gdiplus::Graphics gfx(&image1);
Gdiplus::ImageAttributes imageAttr;
imageAttr.SetColorMatrix(&matrix);
gfx.DrawImage(images,Gdiplus::Rect(0,0,input.width,input.height),0,0,1024,1024,Gdiplus::UnitPixel,&imageAttr);
I am not getting what i expect..Can some one help me in finding the mistake i m doing.
You can use the alpha component of a color to specify transparency, so that colors can be combined. However, if you want the combination to be something other than the alpha blend, you must draw the pixels yourself. You could first draw into a transparent bitmap, then render that onto the destination pixel by pixel.

Transparent colors, how does it work?

Just a question across programming languages. If I make a color transparent in an image, does it mean that affected pixels are not displayed at all? Ie the processing just skips the pixels with color that is set as transparent?
When the image is displayed on top of a background (be it a plain background or another image), the background will be visible through the transparent pixels of your image.

Resources