Closed BusyStudent closed 5 months ago
That's pretty vague. The answer is probably NO.
I assume you mean you want to use only a certain rectangle of an image as the fill ? You could do this by "zooming" into the imagePattern, with the nvgImagePattern
function like in this test:
The math to get this to do exactly what you want, might be too tricky to be useful though.
Also it may not look so great. In this test case, there are non-transparent pixels in the image borders. So the clamping of OpenGL makes the ugly green line.
You couldn't get a replicating pattern out of the image, as NVG_IMAGE_REPEATX|NVG_IMAGE_REPEATY
applies to the whole image.
At least that's how I understand it. I am not a graphics authority :smile:
The header declaration of the function is misleading, as ex
ey
should be w
h
.
NVGpaint nvgImagePattern(NVGcontext* ctx, float ox, float oy, float ex, float ey,
float angle, int image, float alpha);
As they are in the source file file.
NVGpaint nvgImagePattern(NVGcontext* ctx,
float cx, float cy, float w, float h, float angle,
int image, float alpha)
Yes. Using zooming is the way I was using for slove it.too tricky
Maybe we should add a api like nvgSubImagePattern
@memononen ?
Is it possible to implement it in nanovg?
It there any way to use a part of image as pattern? not the whole image.