nvgRotate();

Iv’e been trying to get a nvgRect to rotate in a stationary position on a panel.

nvgRotate(context, float angle); Does this even work on basic shapes or is there something missing from the code. note commented code has been tried.
snippet from v1 but also tried in 0.6.x

		//TestPanel *module;
		float pos1 = 0.f;
		NVGcolor blackTransparent = nvgRGBA(0, 0, 0, 35);
		nvgBeginPath(rect.vg);
		// context, float x, float y, float w, float h
		nvgRect(rect.vg, pos1, pos1 - 6.f, 30.f, 25.f);
		//nvgSkewX(rect.vg, 60.f);////does nothing
		//nvgSkewY(rect.vg, 60);////does nothing
		//nvgQuadTo(rect.vg, pos1, pos1 - 20, 30, 30);////does something, no rotation
		nvgFillColor(rect.vg, blackTransparent);
		nvgFill(rect.vg);
		nvgRotate(rect.vg, 30.f);
		nvgClosePath(rect.vg);
		//nvgSave(rect.vg);
		//nvgRestore(rect.vg);

from the doc it says: Rotates current coordinate system. Angle is specified in radians.

If nvgRect does not rotate any ideas of another way to create a square/rectangle with NVG and get it rotated by a certain angle in a stationary position?

You haven’t called nvgRotate when you call nvgRect, so the coordinate system hasn’t been rotated yet. Also, nvgClosePath is unnecessary because nvgRect closes the path.

1 Like

Christ that’s been a few hours wasted… nvgRotate first then nvgRect :rofl:

Would I need nvgClosePath if I wanted to add another shape?

Would not have thought that would work like that, rotating angles before they are created are all angle manipulations like that in NVG, very strange to me.

Not sure how it would be possible to work any other way. How would nanovg know what transformation to apply to what?

No. nvgRect already closes the path.

If that’s how it is good to know. Will be harder to forget anyway, so not such a waste of time. Thanks!