notlion / cinder-nanovg Goto Github PK
View Code? Open in Web Editor NEWA C++11 wrapper for NanoVG meant for use with Cinder
A C++11 wrapper for NanoVG meant for use with Cinder
Is an NV context coupled to a GL context? I'm trying to use Cinder-NanoVG for general UI components and want to better understand the scope and management of the NV Context being drawn into.
This is a great wrapper! The shapes look so nice. I'm really looking forward to diving in deeper.
I added a simple ci::Timer to get the number of milliseconds spent per frame in the RenderToTexture sample, and found that the NanoVG performance is generally better than the Texture Proxy performance (on a Mac Pro w/ AMD Firepro card). When running in Release with 512 shapes, I see the following frame times:
Texture Proxies: ~10.0 ms
NanoVG: ~ 2.8 ms
My guess is that the proxies aren't really worth it unless the underlying shape is very complex.
When I draw a string(text) using : ctx->text(pos,text)
and choose for example
(0,0)
as the position the resulting text rect drawn does not have that position.
In case of (0,0)
it gets negative x,y values.
To force the text to be drawn at the intended position I can do:
// setup preferred position and text
vec2 intendedPos{0,0};
string text{"this is a test"};
Rectf r = ctx->textBounds(0, 0, text);
// correct text pos
vec2 correctedPos{intendedPos.x - r.x1, intendedPos.y - r.y1} ;
// correct rect
r = ctx->textBounds(correctedPos.x, correctedPos.y, text);
// draw Text
ctx->beginPath();
ctx->fillColor(ColorAf{0.2, 0.2, 0.2});
ctx->text(correctedPos,text);
Is this intended behaviour or a bug? I believe what's confusing about this is that it behaves
unexpected in context of other cinder stuff.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.