Node.js drawing on screen [closed]
Asked Answered
K

4

24

I've been looking all over the internet for this. I'd like to know if there is any Node.js packages/bindigs/libraries that allow you to make an application that draws on the screen without node-webkit(NW.js)/Electron or other implementations based on browsers. Maybe something that binds to opengl with support for 2D graphics?

Let me know if you know some names or links. If not I might have to write something myself.

Thank you guys.

Kenning answered 8/11, 2015 at 16:38 Comment(15)
I think three.js is what you looking forLarousse
That's for the browser canvas @lolioKenning
Yes that's true ,but then I don't understand your question :( maybe you can give me an example on what you are trying to achieveLarousse
I'm trying to do a desktop application with node-js (like a game). I mean without a browser, just using node-js (server/desktop javascript)Kenning
Where do you want this application to run? In your console?Dispermous
I want to run node my-app.js and have it create a window (or go fullscreen), display some graphics, and even better get some keyboard/mouse input and audio. Basically let's say I want to make a videogame for a desktop computer in JavaScript. But I don't want to rely on a specific browser platform, just on Node.JS and the V8 Engine. Are there any bidings to GL or something similar?Kenning
I found V8-GL,which is a Toolkit for creating Desktop Hardware Accelerated Graphics with JSLarousse
Here is a link,but I don't know,if this works correctly github.com/philogb/V8-GLLarousse
that's actually very interesting, I will look and see how it works :DKenning
@Kenning Why cant you use nw.js and phaser for example? ships chromium, so you know the platform and the rest.. just works.. it also gives you the whole build system and shipping to all platforms.Atlantis
I could do that. But I was interested to know if there were valid alternatives or notKenning
Three.js uses WebGL, not OpenGL. @lolio. OP is asking for opengl bindings using Javascript.Toxin
Some Qt bindings for node like this one might be a good option as wellKenning
take a look at Node-gir (recent project): github.com/Place1/node-gir - allows you to use any Gnome lib from Node, especially GTK etc. What you are really looking for is a native GUI lib binding in Node ... you should extend your search to those terms instead of just drawing ... since you wont be able to "draw" without something like a native UI window handle of some sort, at least on most common desktop platforms.Elbertine
@Kenning Node Vulkan API for JavaScript/TypeScript github.com/maierfelix/nvkAlbertina
L
9

There is an experimental project : https://github.com/creationix/node-sdl

This basically provides bindings to the SDL library:

Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.

If you can get it compiled, you can try the example scripts in nodejs.

Liggett answered 18/11, 2015 at 12:4 Comment(0)
P
4

node-opencv or OpenCV in general should allow you this. At least it has a HighGUI class, which gives you native window contexts to display image data. With a lot of hacking you can build something you require. But I would suggest using browser contexts and HTMLCanvas anyhow. It gives you all you need out of the box. You just need to set it up properly.

Edit: As per @Zorgatone's suggestion, GTK could be a very good library for that purpose, though node bindings are very stale.

Putnam answered 8/11, 2015 at 17:42 Comment(4)
It kinda sucks for me to rely on a browser anyway.. I believe there should be some bindings of Cairo/GTK out there that I could use, but I haven't tried those though.Kenning
GTK is a really good suggestion. I think the bindings though are really old. But do investigate on it or write your own. Should be a very good path.Putnam
Ok, I will try. ThanksKenning
I think opencv doesn't actually implement any rendering - as you said it depends on DOM canvas int he browser/node and on third party on the server to actually rendering to a display or even to files.Digitate
H
4

There are projects that brings

but unfortunately the last commits seem to be for old node.js versions.

It will be substantial work to make the bindings work with a recent version of node but those a interesting starting points.

Haroldharolda answered 18/11, 2015 at 13:40 Comment(1)
Found this GUI framework: github.com/nodegui/nodeguiKenning
L
2

V8-GL intends to provide bindings for creating 2D-3D graphics on the desktop with javascript.The Status is not completed yet, but maybe it is enough for what you are trying to do https://github.com/philogb/V8-GL Another thing i just found out is, that it actually uses immediate mode, which is deprecated but still works.

Larousse answered 12/11, 2015 at 17:26 Comment(1)
FYI: last commit was in 2011.Phyfe

© 2022 - 2024 — McMap. All rights reserved.