Radial Gradient

Yep, this color will make image blank. It is strange.

@anon98020523 the effect is ok, we can not see the same result as simulator is because the background color of simulator is black, and render texture’s background color is white. If you do it like this:

LayerRadialGradient *gradient = LayerRadialGradient::create(Color4B(179, 232, 184, 89), Color4B(0, 90, 128, 0), 200, Vec2(200, 200), 0.0f);
    addChild(gradient);
    RenderTexture* render = RenderTexture::create((int)Director::getInstance()->getWinSize().width,
                                                  (int)Director::getInstance()->getWinSize().height, Texture2D::PixelFormat::RGBA8888);
    
    render->beginWithClear(0, 0, 0, 255);
    gradient->visit();
    render->end();
    render->saveToFile("ololo.png",Image::Format::PNG);

Then the effect is the same.

Thats again strange, but when bg is black, image is ok. It’s full and bright. But I need a transparent bg color, so I’m doing render->beginWithClear(0, 0, 0, 0); and with it - image is very poor.

render->beginWithClear(0, 0, 0, 255);

output this image(not edited):

But, changing bg opacity to 0:

render->beginWithClear(0, 0, 0, 0);

output this (I edited file in Photoshop afterwards - just added black background under rendered image):

And if you take a look carefully - on the top of this image there are a little bit some color…

@zhangxm I get back to this now. Problem with render my gradient is because of this bug renderTexture saveToFile artifacts can you please take a look? Bug already created on github.

Could you please paste the github issue link? I will take a look after releasing v3.16.

@anon98020523 thanks.

Also, Just take code and images from zip file to test from this post - renderTexture saveToFile artifacts it’s reproduced easily.

@Joseph39 Hey, I’m trying to use your super smart solution and match with my gradient:
LayerRadialGradient::create( Color4B(179, 232, 184, 89), Color4B(0, 90, 128, 0), 200, Vec2(200, 200), 0.0f);

With it I get current result:

07

But I’m trying your method using same colors from this post and get:

06

Color looks cool :slight_smile: but it’s really different from what I specified:

Color4B borderColor1(Color4B(179, 232, 184, 89));
Color4B centerColor1(Color4B(0, 90, 128, 0));