Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radial Gradient not working #612

Closed
MatijaBrown opened this issue Mar 16, 2021 · 6 comments
Closed

Radial Gradient not working #612

MatijaBrown opened this issue Mar 16, 2021 · 6 comments

Comments

@MatijaBrown
Copy link

The title says it all:
When running following code, no gradient appears inside the rectangle.


        nvgRect(vg, 900, 100, 300, 500);
        nvgFillPaint(vg, nvgRadialGradient(vg, 1050, 350, 100, 200, nvgRGBAf(1, 0, 0, 1), nvgRGBAf(1, 1, 0, 1)));
        nvgFill(vg);

Is there a reason for this? Am I doing something wrong?
Anyway, have a good day.

@mulle-kybernetik-tv
Copy link

I tried out your code and got this after I did one weird trick, that I am gonna share with you.
Screenshot from 2021-03-17 12-27-44

Trick: I went into the nanovg demo and checked how it's supposed to be done by searching for nvgRadialGradient.

@MatijaBrown
Copy link
Author

MatijaBrown commented Mar 17, 2021

And how do you suppose I got this nvgRadialGradient(vg, 1050, 350, 100, 200, nvgRGBAf(1, 0, 0, 1), nvgRGBAf(1, 1, 0, 1)) in the first place? I looked at the demo - and other demos I found. To be precise, I used the following example to find the radial gradient code:
https://openplanet.nl/tutorials/nanovg-introduction

(scroll down to find it).

@mulle-kybernetik-tv
Copy link

I am not clairvoyant and don't know what you did. But if you copy/paste the code from the demo and don't reorder it or leave crucial parts out, it will work.

@MatijaBrown
Copy link
Author

Well, that is all the rendering code I'm running per frame apart from calling nvgBeginFrame(vg) and nvgEndFrame(vg) - so it should work. (I have tried moving the rectangle about as well, the paint is definitely not there!)

@memononen
Copy link
Owner

memononen commented Mar 17, 2021 via email

@MatijaBrown
Copy link
Author

You're missing nvgBeginPath(vg) before the rect.

On Tue, Mar 16, 2021 at 8:22 PM MatijaBrown @.***> wrote: The title says it all: When running following code, no gradient appears inside the rectangle. nvgRect(vg, 900, 100, 300, 500); nvgFillPaint(vg, nvgRadialGradient(vg, 1050, 350, 100, 200, nvgRGBAf(1, 0, 0, 1), nvgRGBAf(1, 1, 0, 1))); nvgFill(vg); Is there a reason for this? Am I doing something wrong? Anyway, have a good day. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#612>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIBXSFAS3KLWFDLZDSH5STTD6OUTANCNFSM4ZJCQE4Q .

Well thank you for the answer. I have no idea if I really did forget it, at least I can't remember, but the code is long gone now.
Might as well have been the problem though. (but doesn't it usually work for the first render without nvgBeginPath(vg)?, as far as I know EndFrame clears the path cache?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants