Vector graphics with NanoVG and NanoSVG

Use of external libraries (DLLs) from ZGE.

Moderator: Moderators

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Vector graphics with NanoVG and NanoSVG

Postby Rado1 » Fri Oct 14, 2016 11:34 pm

Dream became reality. You can now use external library ZgeNano for fast antialiased 2D vector drawing in ZGE. The library uses NanoVG and part of NanoSVG libraries. Current version implements:
  • almost whole NanoVG API - basic shapes, composite shapes, fonts, pictures, ... (functions for transformations based on float[6] matrices, nvgTextGlyphPositions and nvgTextBreakLines are excluded due to relatively complicated processing of outputs)
  • NanoSVG functions for importing SVG files
  • my own simple renderer of SVG to NanoSVG primitives; the current version does not support gradients; advanced SVG (clipping, masking, effects, filters) will probably never support

The API is relatively simple and the results are quite nice. For details about API see NanoVG header file. One big advantage is the possibility to read resources (pictures and SVG data) from files in runtime. Alternatively, you can embed them in File components and read the content from memory. Just see my interactive demo:
scr.png
scr.png (26.75 KiB) Viewed 3594 times

To play with it just move mouse and click around - you can even sink the steam boat.

The demo project file with DLL can be downloaded from here. Please use it with latest ZGE beta.

As next, I plan to add gradients in rendering SVG, add compiling to 64bit + Android, and publish ZgeNano on GitHub. Later, I'll maybe add some NanoVG-based GUI components.

Any comments are welcome.

zondarg
Posts: 12
Joined: Fri Jan 01, 2016 12:17 pm

Re: Vector graphics with NanoVG and NanoSVG

Postby zondarg » Thu Oct 20, 2016 8:27 pm

Wow, this looks great, I need to have a deeper look at this. I once had the idea of somehow using Inkskape-style graphics but dismissed it as being too complicated (missing a svg interpreter), but with this... :shock: :D
Another great addition to ZGE! Thanks!

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Re: Vector graphics with NanoVG and NanoSVG

Postby Rado1 » Fri Oct 21, 2016 5:50 am

Dear zondarg, I'm glad you like it. After some improvements of the library I'm working on now, I'll create my first SVG+2D physics game. I already made some experiments and it seems to be promising technology producing really nice look.

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Re: Vector graphics with NanoVG and NanoSVG

Postby Rado1 » Sat Oct 22, 2016 2:34 pm

You can now use update of the ZgeNano library with new features:

  • SVG import can use also linear an radial gradients with some restrictions - just 2 colors in one gradient and radial gradient does not support stretching and rotation
  • SVG picture can be rendered to an array and later used as a texture
  • SVG rendering to NanoVG allows to filter particular parts of the SVG file - this can be used to store more pictures or animations or animation parts of the same object to one SVG file
Here you can download the updated DLL and 3 demo models.

Demo 1 - interactive picture with boat
Demo 2 - demonstrates rendering of more than 1000 objects (used for performance testing - 150 FPS on AMD FirePro M2000 in fullscreen)
Demo 3 - import/rendering of SVG with gradients and filtering of SVG shapes - 2 pictures in one file

scr2.png
Screenshots of ZgeNano demo 2 and demo 3 screenshots
scr2.png (113.59 KiB) Viewed 3558 times

User avatar
VilleK
Site Admin
Posts: 1918
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Vector graphics with NanoVG and NanoSVG

Postby VilleK » Sun Oct 23, 2016 7:06 am

Cool! All three demo projects work fine here. I've been wanting to add nice quality 2d-vector features for ZGE and you seem to have found the perfect match here in Nano-libs! Thanks for your work.

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Re: Vector graphics with NanoVG and NanoSVG

Postby Rado1 » Sun Oct 23, 2016 5:34 pm

Thanks Ville.

FYI I added ZgeNano to GitHub: https://github.com/Rado-1/ZgeNano. From now, all sources, demo projects and binaries can be downloaded from this repository. You can also put your issues there.

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Re: Vector graphics with NanoVG and NanoSVG

Postby Rado1 » Thu Dec 22, 2016 2:12 pm

New version 1.0 of ZgeNano library can import also SVGZ (compressed SVG) files. Download the DLL form here.


Return to “Extensions”

Who is online

Users browsing this forum: No registered users and 1 guest