openvg-canvas v1.1.7
node-openvg-canvas
Canvas implementation on node-openvg
This module implements a HTML5 Canvas on OpenVG (node-openvg). It is targeted to the raspberry-pi. By using the OpenVG APIs on the Raspberry PI, all graphics code will run on the GPU with hardware acceleration.
This library aims for API compatibility with node-canvas where it applies / makes sense. While node-canvas is targeted to create images off screen, node-openvg-canvas is targeted to on screen usage, but not yet for user interaction.
Currently there are only plans to implement the 2d context. Implementing the 3d context (web gl) should be possible by mapping OpenGL/ES.
0. Installation
This module is targeted for node 0.8.x. Node >= 0.8.10 will compile out of the box on the raspberry.
Fetch the source:
git clone https://github.com/luismreis/node-openvg-canvas.git
Build the package:
cd node-openvg-canvas
npm install
To test:
export PATH=$PWD/bin:$PATH
examples/swissClock.js
1. Documentation
Canvas implementation status (by WHATWG Canvas IDL class/interface definition)
- CanvasRenderingContext2D
- state - save/restore (done)
- matrix transformations: scale, transform, etc (done)
- compositing - alpha, composite operation (done)
- image smoothing (done)
- stroke/fill style
- gradients (done)
- patterns (to do)
- shadows (to do - after v. 1.0)
- clear/fill/stroke rect (done)
- beginPath, fill, stroke /default path/ (done)
- fill, stroke /custom path/ (to do)
- focus ring (no plan to implement)
- scrollPathIntoView (no plan to implement)
- clip/reset clip (to do)
- isPointInPath (to do - after v. 1.0 - help appreciated)
- fill/stroke/measure text (done)
- drawImage (done)
- hit regions (no plan to implement)
- create/get/put image data (done)
- CanvasDrawingStyles
- drawing styles - line width, cap, join, miter limit (done)
- dashed lines (to do)
- text - font, textAlign, textBaseline (done)
- CanvasPathMethods (only implemented for the context's currentDefaultPath)
- closePath() (done)
- moveTo, lineTo (done)
- quadraticCurveTo, bezierCurveTo (done - untested)
- arcTo (to do)
- rect (done)
- arc (done)
- ellipse (done - rotation parameter ignored)
- CanvasGradient (done)
- CanvasPattern (to do)
- TextMetrics (done)
- HitRegionOptions (no plan to implement)
- ImageData (done)
- Path (to do)
Differences from the HTML5 Canvas object / node-canvas
The HTML5 Canvas is used inside the browser runtime, so, its rendering is controlled automatically (and implicitly) by the browser.
node-canvas code explicitly calls toBuffer or similar functions to render images.
Code running on node-openvg-canvas must explicitly swap display buffers, to do so, either call vg.egl.swapBuffers
from node-openvg or use the included requestAnimationFrame shim (for more information look at the clock examples) that does this after calling your paint (callback) function.
License
(The MIT License)
Copyright (c) 2012 Luis Reis
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.