www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Release: nanovega.d rendering lib like html5 canvas

reply Adam D. Ruppe <destructionator gmail.com> writes:
https://github.com/adamdruppe/arsd

nanovega.d

depends on: simpledisplay.d, color.d, and ttf.d (latter only on 
Windows)

Should also be present in v1.3 of the dub package 
http://code.dlang.org/packages/arsd-official

API docs (includes an example to get you started)
http://dpldocs.info/experimental-docs/arsd.nanovega.html

This module's primary author is ketmar. What follows is his 
description:


NanoVega is a fork of the famous NanoVG rendering library. it was 
ported to D, and then updgraded with various features.

NanoVega is using OpenGL for rendering (i.e. no intermediate 
rasterize-to-picture step), and its API modelled after HTML5 
canvas API.

most interesting *new* features are:

  * clipping to paths

  * support for non-zero and even-odd fill rules. original NanoVG 
only
supported non-zero (despite what it's README says).

  * fontconfig support on Posix systems.

  * full-featured picking API: you can check if your mouse cursor 
is inside of a filled path, or on the border of a stroked path. 
you don't need to render your pathes for this, and you can do 
your tests *before* rendering (to change colors of UI elements on 
mouse hover, for example). it is quite fast,  and is using 
quad-tree to further speed up the tests.

  * NanoVega is completely  nogc!

  * easy to use and powerful text API: accepts `char`, `wchar`, 
and `dchar` strings, so you don't need to convert your text back 
and forth! provides iterators and callback-based API to get 
various text metrics.

  * doesn't require any dependencies besides ARSD modules.

  * extensive DDoc documentation and sample code.

  * comes with Blendish port to make your UI rendering easy and 
fun. <http://dpldocs.info/experimental-docs/arsd.blendish.html> 
(see blendish.d in the arsd repo)

there is also standalone SVG parser and rasterizer, based on 
NanoSVG project. it was forked, ported to D, and made even better 
than the original! 
<http://dpldocs.info/experimental-docs/arsd.svg.html>

  * completely standalone, doesn't require any other modules.

  * converts your SVGs to drawing commands or cubic bezier curves.

  * supports standalone "style" tag.

  * has better and faster XML parser.

  * has builtin rasterizer, so you can convert your icons to 
images for speed.

  * can be used with NanoVega to render SVGs without prior 
rasterizing.

  * FAST! and  nogc!


enjoy, and happy hacking. ;-)
Mar 07 2018
next sibling parent reply WebFreak001 <d.forum webfreak.org> writes:
On Thursday, 8 March 2018 at 03:55:35 UTC, Adam D. Ruppe wrote:
 https://github.com/adamdruppe/arsd

 nanovega.d

 [...]
AMAZING! I think this will revolutionize how we do GUI and rendering in D, especially nogc. You can make really cool effects and renders very quickly. Got some cool project ideas how you could use this already. You could make a WPF clone in D for example if you put in a lot of time, but it would probably be far superior than all other currently existing GUI toolkits if you get the data binding and event layer right.
Mar 08 2018
parent reply aberba <karabutaworld gmail.com> writes:
On Thursday, 8 March 2018 at 19:24:43 UTC, WebFreak001 wrote:
 On Thursday, 8 March 2018 at 03:55:35 UTC, Adam D. Ruppe wrote:
 https://github.com/adamdruppe/arsd

 nanovega.d

 [...]
AMAZING! I think this will revolutionize how we do GUI and rendering in D, especially nogc. You can make really cool effects and renders very quickly. Got some cool project ideas how you could use this already. You could make a WPF clone in D for example if you put in a lot of time, but it would probably be far superior than all other currently existing GUI toolkits if you get the data binding and event layer right.
And theming. Especially with a subset of CSS.
Mar 08 2018
parent WebFreak001 <d.forum webfreak.org> writes:
On Thursday, 8 March 2018 at 22:08:30 UTC, aberba wrote:
 On Thursday, 8 March 2018 at 19:24:43 UTC, WebFreak001 wrote:
 On Thursday, 8 March 2018 at 03:55:35 UTC, Adam D. Ruppe wrote:
 https://github.com/adamdruppe/arsd

 nanovega.d

 [...]
AMAZING! I think this will revolutionize how we do GUI and rendering in D, especially nogc. You can make really cool effects and renders very quickly. Got some cool project ideas how you could use this already. You could make a WPF clone in D for example if you put in a lot of time, but it would probably be far superior than all other currently existing GUI toolkits if you get the data binding and event layer right.
And theming. Especially with a subset of CSS.
Yeah you can make really cool effects: https://wfr.moe/fFYvHH.png --- string txt = "Text me up."; float[4] bounds; nvg.fontFace = "Roboto"; nvg.fontSize = 32; nvg.textBounds(64, 64, txt, bounds[]); nvg.beginPath(); nvg.roundedRect(bounds[0] - 32, bounds[1] - 8 + 8, bounds[2]-bounds[0] + 64, bounds[3]-bounds[1] + 16, 4); nvg.fillPaint = nvg.linearGradient(bounds[0], bounds[1], bounds[2], bounds[3], NVGColor("#c50 nvg.fill(); nvg.beginPath(); nvg.roundedRect(bounds[0] - 32, bounds[1] - 8, bounds[2]-bounds[0] + 64, bounds[3]-bounds[1] + 16, 4); nvg.fillPaint = nvg.linearGradient(bounds[0], bounds[1], bounds[2], bounds[3], NVGColor("#f70"), NVGColor("#a90")); nvg.fill(); nvg.fillPaint = pattern; nvg.fill(); nvg.beginPath(); nvg.roundedRect(bounds[0] - 32, bounds[1] - 8, bounds[2]-bounds[0] + 64, bounds[3]-bounds[1] + 16 + 8, 4); nvg.strokeColor = NVGColor.white; nvg.strokeWidth = 2; nvg.stroke(); nvg.fillColor = NVGColor.black; nvg.text(64, 64, txt);
Mar 09 2018
prev sibling next sibling parent reply aberba <karabutaworld gmail.com> writes:
On Thursday, 8 March 2018 at 03:55:35 UTC, Adam D. Ruppe wrote:
 https://github.com/adamdruppe/arsd

 nanovega.d

 [...]
Why is there NVG* everything? That's code noise. Anyways, its well documented.
Mar 08 2018
parent Adam D. Ruppe <destructionator gmail.com> writes:
On Thursday, 8 March 2018 at 22:16:50 UTC, aberba wrote:
 Why is there NVG* everything? That's code noise.
It is a fork and port from a C codebase. Fairly little of that is used in the public api though.
Mar 08 2018
prev sibling next sibling parent reply Adam D. Ruppe <destructionator gmail.com> writes:
Now also on dub:

http://code.dlang.org/packages/arsd-official%3Ananovega
Mar 09 2018
parent reply drug <drug2004 bk.ru> writes:
09.03.2018 18:38, Adam D. Ruppe пишет:
 Now also on dub:
 
 http://code.dlang.org/packages/arsd-official%3Ananovega
Hasn't somebody started porting nanogui (https://github.com/wjakob/nanogui)? I'd like to do it, but don't want to duplicate efforts.
Apr 02 2018
next sibling parent Adam D. Ruppe <destructionator gmail.com> writes:
On Monday, 2 April 2018 at 07:55:26 UTC, drug wrote:
 Hasn't somebody started porting nanogui 
 (https://github.com/wjakob/nanogui)? I'd like to do it, but 
 don't want to duplicate efforts.
I don't know.
Apr 02 2018
prev sibling parent reply Andrew Edwards <edwards.ac gmail.com> writes:
On Monday, 2 April 2018 at 07:55:26 UTC, drug wrote:
 09.03.2018 18:38, Adam D. Ruppe пишет:
 Now also on dub:
 
 http://code.dlang.org/packages/arsd-official%3Ananovega
Hasn't somebody started porting nanogui (https://github.com/wjakob/nanogui)? I'd like to do it, but don't want to duplicate efforts.
I made an attempt last year but not much came of it. Would like to help out if you don’t mind slowing your pace a bit to provide some mentoring when the need arises. Andrew
Apr 02 2018
next sibling parent drug <drug2004 bk.ru> writes:
03.04.2018 04:44, Andrew Edwards пишет:
 
 I made an attempt last year but not much came of it. Would like to help 
 out if you don’t mind slowing your pace a bit to provide some mentoring 
 when the need arises.
 
 Andrew
My pace isn't fast, unfortunately. In fact porting is rather simple, the problem is testing and some things I was forced to made more D-idiomatic. For example wjakob uses passing args as const reference all over the place, even bool. I've changed it by passing by value. All types are less or equal to pointer size so there is no sense to pass them by reference I think. Also it lets avoid const qualifier on D side, because passing by value is equal to passing with const qualifier, but of course it's debatable. And I'd like to instead of Screen class, that based on glfw library under hood, use several classes based on arsd.simpledisplay, sdl2, glfw, sfml etc... Now my code is mess, I need to clean it before pushing but more probably it'll happens only on the weekends. Anyway, you're welcome!
Apr 04 2018
prev sibling next sibling parent reply drug <drug2004 bk.ru> writes:
https://github.com/drug007/nanogui

I would be glad if you take a look
Apr 07 2018
next sibling parent reply bauss <jj_1337 live.dk> writes:
On Saturday, 7 April 2018 at 09:13:06 UTC, drug wrote:
 https://github.com/drug007/nanogui

 I would be glad if you take a look
The documentation should probably be updated to match ddoc.
Apr 11 2018
parent drug <drug2004 bk.ru> writes:
11.04.2018 16:30, bauss пишет:
 The documentation should probably be updated to match ddoc.
Sure, of course, but it has low priority now. It is just proof of concept. First of all I'm interested in estimation of changes I've made. For example I'm trying to keep const qualifier as most as possible and either I use passing by value (most of all) or change api to allow using const qualifier on D side too (in fact one time). Is it worth effort, has it some caveats?
Apr 11 2018
prev sibling next sibling parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Saturday, 7 April 2018 at 09:13:06 UTC, drug wrote:
 https://github.com/drug007/nanogui

 I would be glad if you take a look
Do you have a complete example I can just compile and run to get started?
Apr 11 2018
next sibling parent drug <drug2004 bk.ru> writes:
11.04.2018 16:59, Adam D. Ruppe пишет:
 
 Do you have a complete example I can just compile and run to get started?
Yes, but it needs to be pushed. I've ported Window, Widget, Label and Checkbox (may be something else) and interacting by means of mouse (clicking, motion and dragging). But it has lags and I need your advice. I'll push it in 4-5 hours.
Apr 11 2018
prev sibling parent reply drug <drug2004 bk.ru> writes:
11.04.2018 16:59, Adam D. Ruppe пишет:
 On Saturday, 7 April 2018 at 09:13:06 UTC, drug wrote:
 https://github.com/drug007/nanogui

 I would be glad if you take a look
Do you have a complete example I can just compile and run to get started?
That's it - https://github.com/drug007/nanogui/tree/interacting_with_checkbox Window, Label and Checkbox example + dragging (you can move Window) But it lags, so definitely I use arsd.simpledisplay in a wrong way.
Apr 11 2018
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Wednesday, 11 April 2018 at 17:26:19 UTC, drug wrote:
 That's it - 
 https://github.com/drug007/nanogui/tree/interacting_with_checkbox
So MouseEvent is sent on mouse motion too, and redrawing on each motion might back up the queue. Otherwise, nothing obvious jumps out at me so I might have to take a closer look later.
Apr 11 2018
parent drug <drug2004 bk.ru> writes:
11.04.2018 21:13, Adam D. Ruppe пишет:
 On Wednesday, 11 April 2018 at 17:26:19 UTC, drug wrote:
 That's it - 
 https://github.com/drug007/nanogui/tree/interacting_with_checkbox
So MouseEvent is sent on mouse motion too, and redrawing on each motion might back up the queue. Otherwise, nothing obvious jumps out at me so I might have to take a closer look later.
Yes, the reason was spamming events like a crazy, fixed.
Apr 11 2018
prev sibling parent reply Chris <wendlec tcd.ie> writes:
On Saturday, 7 April 2018 at 09:13:06 UTC, drug wrote:
 https://github.com/drug007/nanogui

 I would be glad if you take a look
`nanogui` doesn't compile with dub: No package file found in /nanogui/examples/arsd/, expected one of dub.json/dub.sdl/package.json It says `arsd is submodule now`. Any quick fixes? I don't have time to look into this only to play around with it.
Apr 30 2018
parent drug <drug2004 bk.ru> writes:
30.04.2018 13:33, Chris пишет:
 On Saturday, 7 April 2018 at 09:13:06 UTC, drug wrote:
 https://github.com/drug007/nanogui

 I would be glad if you take a look
`nanogui` doesn't compile with dub: No package file found in /nanogui/examples/arsd/, expected one of dub.json/dub.sdl/package.json It says `arsd is submodule now`. Any quick fixes? I don't have time to look into this only to play around with it.
I update readme with info how to handle submodule.
Apr 30 2018
prev sibling parent reply drug <drug2004 bk.ru> writes:
03.04.2018 04:44, Andrew Edwards пишет:
 
 I made an attempt last year but not much came of it. Would like to help 
 out if you don’t mind slowing your pace a bit to provide some mentoring 
 when the need arises.
 
 Andrew
Ironically, I've made (incomplete) port of nanogui and it works using arsd.simpledisplay and sdl2. But totally failed to run it using glfw like original nanogui does. Al least I've spent more time trying to run using glfw than total time I spent using both simpledisplay and sdl2.
Apr 28 2018
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Saturday, 28 April 2018 at 09:55:17 UTC, drug wrote:
 least I've spent more time trying to run using glfw than total 
 time I spent using both simpledisplay and sdl2.
simpledisplay I find is a lot... well, simpler way to display than any of the alternatives since it sidesteps the dependency hell problem the others have.
Apr 28 2018
parent drug <drug2004 bk.ru> writes:
28.04.2018 17:04, Adam D. Ruppe пишет:
 On Saturday, 28 April 2018 at 09:55:17 UTC, drug wrote:
 least I've spent more time trying to run using glfw than total time I 
 spent using both simpledisplay and sdl2.
simpledisplay I find is a lot... well, simpler way to display than any of the alternatives since it sidesteps the dependency hell problem the others have.
Yes, it is. I just use SDL2 backend in other project so it didn't take too time. But simpledisplay took much less time to take off. P.S. `visibleForTheFirstTime` was unusual for me but nothing more.
Apr 28 2018
prev sibling parent Chris <wendlec tcd.ie> writes:
On Thursday, 8 March 2018 at 03:55:35 UTC, Adam D. Ruppe wrote:

 enjoy, and happy hacking. ;-)
Adam drug Any chance you could add more examples of nanogui and arsed/minigui;minigui_xml? It all looks very promissing!
Apr 30 2018