nanovgjs 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ Copyright (c) 2013 Mikko Mononen memon@inside.org
2
+
3
+ This software is provided 'as-is', without any express or implied
4
+ warranty. In no event will the authors be held liable for any damages
5
+ arising from the use of this software.
6
+
7
+ Permission is granted to anyone to use this software for any purpose,
8
+ including commercial applications, and to alter it and redistribute it
9
+ freely, subject to the following restrictions:
10
+
11
+ 1. The origin of this software must not be misrepresented; you must not
12
+ claim that you wrote the original software. If you use this software
13
+ in a product, an acknowledgment in the product documentation would be
14
+ appreciated but is not required.
15
+ 2. Altered source versions must be plainly marked as such, and must not be
16
+ misrepresented as being the original software.
17
+ 3. This notice may not be removed or altered from any source distribution.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # nanovgjs
2
+
3
+ JavaScript port of [NanoVG](https://github.com/memononen/nanovg) by Mikko Mononen.
4
+
5
+ NanoVG is a small antialiased 2D vector graphics rendering library for OpenGL. This is a manual port of the C source to plain JavaScript with a WebGL backend.
6
+
7
+ > Altered source version — ported from C to JavaScript. Not the original software.
8
+
9
+ ## Live Demo
10
+
11
+ [https://1h3a3x7.github.io/nanovgjs/](https://1h3a3x7.github.io/nanovgjs/)
12
+
13
+ Move the mouse around the canvas. Press **Space** to toggle the blowup transform.
14
+
15
+ ## Files
16
+
17
+ | File | Description |
18
+ |------|-------------|
19
+ | `nanovg.js` | Core geometry and path library (port of `nanovg.c` / `nanovg.h`) |
20
+ | `nanovg_gl.js` | WebGL renderer (port of `nanovg_gl.h`) |
21
+ | `example.js` | Port of the original `demo.c` demo |
22
+ | `index.html` | Entry point / GitHub Pages demo |
23
+ | `example/` | Demo assets: fonts (Roboto, Entypo) and images |
24
+
25
+ ## Usage
26
+
27
+ ```html
28
+ <script src="nanovg.js"></script>
29
+ <script src="nanovg_gl.js"></script>
30
+ ```
31
+
32
+ ```js
33
+ const gl = canvas.getContext("experimental-webgl", { stencil: true });
34
+
35
+ const params = new NVGparams();
36
+ params.renderCreate = (ptr) => glnvg__renderCreate(ptr);
37
+ params.renderCreateTexture = (ptr, type, w, h, flags, data) => glnvg__renderCreateTexture(ptr, type, w, h, flags, data);
38
+ params.renderDeleteTexture = (ptr, image) => glnvg__renderDeleteTexture(ptr, image);
39
+ params.renderUpdateTexture = (ptr, image, x, y, w, h, data) => glnvg__renderUpdateTexture(ptr, image, x, y, w, h, data);
40
+ params.renderGetTextureSize= (ptr, image) => glnvg__renderGetTextureSize(ptr, image);
41
+ params.renderViewport = (ptr, w, h, dpr) => glnvg__renderViewport(ptr, w, h, dpr);
42
+ params.renderCancel = (ptr) => glnvg__renderCancel(ptr);
43
+ params.renderFlush = (ctx) => glnvg__renderFlush(ctx);
44
+ params.renderFill = (ptr, paint, co, sc, fr, b, p, n) => glnvg__renderFill(ptr, paint, co, sc, fr, b, p, n);
45
+ params.renderStroke = (ptr, paint, co, sc, fr, sw, p, n)=> glnvg__renderStroke(ptr, paint, co, sc, fr, sw, p, n);
46
+ params.renderTriangles = (ptr, paint, co, sc, v, n, fr) => glnvg__renderTriangles(ptr, paint, co, sc, v, n, fr);
47
+ params.renderDelete = (ptr) => glnvg__renderDelete(ptr);
48
+ params.userPtr = gl;
49
+ params.edgeAntiAlias = true;
50
+ gl.edgeAntiAlias = true;
51
+
52
+ const ctx = nvgCreateInternal(params);
53
+
54
+ // Each frame:
55
+ ctx.nvgBeginFrame(width, height, devicePixelRatio);
56
+ ctx.nvgBeginPath();
57
+ ctx.nvgRect(100, 100, 200, 200);
58
+ ctx.nvgFillColor(NVGcolor.nvgRGBA(255, 128, 0, 255));
59
+ ctx.nvgFill();
60
+ ctx.nvgEndFrame();
61
+ ```
62
+
63
+ ## License
64
+
65
+ zlib license — see [LICENSE](LICENSE).
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file